feat: 날씨 점수 근거 버튼을 구름에 가리던 해 구석 '?'에서 상태 줄 끝 '점수 근거 ›'로(해를 눌러도 열림), 근거 창에 지금 상태(습도·불쾌지수·자외선·미세먼지) 실제 값과 기준 추가
This commit is contained in:
1 parent
1888dd6cf3
commit
eb84a72c2f
6 files changed
+80
-30
No files matched your search
@@ -373,30 +373,29 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps
|
||||
<path d={moonPath(moon.pct, 1, false)} fill={kind === 'sunset' ? 'rgb(96 40 86 / .55)' : 'rgb(34 30 86 / .62)'} transform={moon.waning ? 'scale(-1,1)' : undefined} />
|
||||
</svg>
|
||||
)}
|
||||
<span className={cx('relative', moon && '[text-shadow:0_0_6px_#fff,0_0_12px_#fff]')}>
|
||||
<small className="block font-jua text-[12px]">
|
||||
{failed(feedLoad) ? '점수를 못 불러왔어요' : `${tmr && mode !== 'now' ? `내일 ${PREVIEW[mode].label}` : slotScore != null && mode !== 'now' ? PREVIEW[mode].label : '지금'} 날씨 점수`}
|
||||
</small>
|
||||
<b className="block font-bagel text-[52px] leading-[0.95] font-normal">{heroVal(feedLoad, score, 'w-[84px]')}</b>
|
||||
</span>
|
||||
{why && score != null && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
open({
|
||||
type: 'weatherWhy',
|
||||
why: { label: whyLabel, score, why },
|
||||
})
|
||||
}
|
||||
aria-label={`${whyLabel} 날씨 점수 ${score}점, 어떻게 나왔는지 보기`}
|
||||
className={cx(
|
||||
'absolute right-0 bottom-1 z-[2] grid size-7 cursor-pointer place-items-center rounded-full bg-white font-jua text-[16px] text-(--orange-deep) shadow-[0_2px_6px_rgb(40_48_74/0.25)]',
|
||||
TAP44,
|
||||
)}
|
||||
>
|
||||
?
|
||||
</button>
|
||||
)}
|
||||
{/* 점수 근거가 있으면 해를 눌러도 근거 창: 구석 버튼은 구름에 가려져서 상태 줄 끝으로 옮김 */}
|
||||
{(() => {
|
||||
const body = (
|
||||
<>
|
||||
<small className="block font-jua text-[12px]">
|
||||
{failed(feedLoad) ? '점수를 못 불러왔어요' : `${tmr && mode !== 'now' ? `내일 ${PREVIEW[mode].label}` : slotScore != null && mode !== 'now' ? PREVIEW[mode].label : '지금'} 날씨 점수`}
|
||||
</small>
|
||||
<b className="block font-bagel text-[52px] leading-[0.95] font-normal">{heroVal(feedLoad, score, 'w-[84px]')}</b>
|
||||
</>
|
||||
)
|
||||
const cls = cx('relative', moon && '[text-shadow:0_0_6px_#fff,0_0_12px_#fff]')
|
||||
if (!why || score == null) return <span className={cls}>{body}</span>
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => open({ type: 'weatherWhy', why: { label: whyLabel, score, why, status } })}
|
||||
aria-label={`${whyLabel} 날씨 점수 ${score}점, 어떻게 나왔는지 보기`}
|
||||
className={cx(cls, 'flex cursor-pointer flex-col items-center')}
|
||||
>
|
||||
{body}
|
||||
</button>
|
||||
)
|
||||
})()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -429,6 +428,11 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps
|
||||
</span>
|
||||
</Fragment>
|
||||
))}
|
||||
{why && score != null && (
|
||||
<button type="button" onClick={() => open({ type: 'weatherWhy', why: { label: whyLabel, score, why, status } })} aria-label={`${whyLabel} 날씨 점수 ${score}점, 어떻게 나왔는지 보기`} className={cx('relative cursor-pointer whitespace-nowrap text-(--orange-deep)', TAP44)}>
|
||||
· 점수 근거 ›
|
||||
</button>
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import type { WeatherWhy } from '../api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
|
||||
export type WeatherWhyPayload = { label: string; score: number; why: WeatherWhy[] }
|
||||
/** status: 히어로 상태 줄 그대로 (단계 이름, 실제 값) */
|
||||
export type WeatherWhyPayload = { label: string; score: number; why: WeatherWhy[]; status?: { label: string; value: string; tone?: string; detail?: string | null }[] }
|
||||
|
||||
// 조건마다 같은 색을 막대 칸과 아래 줄 점에 같이 써서 이어 보이게
|
||||
const COLOR: Record<string, string> = {
|
||||
@@ -13,6 +15,14 @@ const COLOR: Record<string, string> = {
|
||||
}
|
||||
const colorOf = (label: string) => COLOR[label] ?? '#9aa3b8'
|
||||
|
||||
// 상태 줄 항목마다 단계를 나누는 기준 (backend/services/hero_stats.py 와 같은 값)
|
||||
const RULE: Record<string, string> = {
|
||||
습도: '30% 아래는 건조, 60% 넘으면 습함이에요',
|
||||
불쾌지수: '68 아래는 쾌적, 75부터 불쾌예요',
|
||||
자외선: '3 아래는 낮음, 6부터 높음이에요',
|
||||
미세먼지: '에어코리아 기준 등급이에요',
|
||||
}
|
||||
|
||||
/** 날씨 점수 근거: 비중만큼 나눈 막대(채운 만큼 얻은 점수)와 조건별 지금 값 */
|
||||
export function WeatherWhySheet({ d }: { d: WeatherWhyPayload }) {
|
||||
return (
|
||||
@@ -46,6 +56,30 @@ export function WeatherWhySheet({ d }: { d: WeatherWhyPayload }) {
|
||||
))}
|
||||
</ul>
|
||||
|
||||
{d.status && d.status.length > 0 && (
|
||||
<>
|
||||
<h4 className="m-0 mt-5 font-jua text-[17px] font-normal">지금 상태</h4>
|
||||
<ul className="m-0 mt-2 flex list-none flex-col gap-1.5 p-0">
|
||||
{d.status.map((s) => (
|
||||
<li key={s.label} className="flex items-center gap-3 rounded-2xl bg-[#f5f8fc] px-3.5 py-2.5">
|
||||
<span className="min-w-0 flex-1">
|
||||
<b className="block font-jua text-[16px] leading-tight font-normal">{s.label}</b>
|
||||
{RULE[s.label] && <small className="block text-[12.5px] font-semibold text-(--ink3)">{RULE[s.label]}</small>}
|
||||
</span>
|
||||
<span className="shrink-0 text-right">
|
||||
<b className={cx('block font-jua text-[18px] leading-tight font-normal', s.tone === 'warn' && 'b-warn')}>{s.value}</b>
|
||||
{s.detail?.split(' · ').map((x) => (
|
||||
<small key={x} className="block text-[12px] font-bold whitespace-nowrap text-(--ink2) tabular-nums">
|
||||
{x}
|
||||
</small>
|
||||
))}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
|
||||
<p className="m-0 mt-3 text-[13px] leading-relaxed font-semibold text-(--ink2)">
|
||||
조건마다 점수를 매겨 비중대로 합쳐요. 유난히 아쉬운 조건이 있으면 조금 더 깎고, 모든 조건이 완벽할 때만 만점이 나와요.
|
||||
</p>
|
||||
|
||||
Reference in new issue
Block a user