feat: 노을 탭 히어로에 점수 크게, 일출일 땐 일출 문구·시간표·용어 설명으로
This commit is contained in:
1 parent
5c4f23c01a
commit
97ebfe2d36
4 files changed
+52
-29
No files matched your search
+42
-27
@@ -33,13 +33,19 @@ const HERO = 'relative mx-3 mt-1 min-h-[230px] overflow-hidden rounded-[32px] px
|
||||
const THREE = [0, 1, 2]
|
||||
const RANK_SKELS = Array.from({ length: 8 }, (_, i) => i)
|
||||
|
||||
/** 히어로엔 해 지는 시각과 하늘 상황 한 줄만. 결론·이유는 아래 카드로 */
|
||||
function HeroBody({ plan, sunset }: { plan?: SkyPlanData; sunset?: string }) {
|
||||
/** 히어로엔 점수를 크게, 아래에 해 지는(뜨는) 시각과 하늘 상황 한 줄. 결론·이유는 아래 카드로 */
|
||||
function HeroBody({ plan, sunAt }: { plan?: SkyPlanData; sunAt?: string }) {
|
||||
const v = (node: ReactNode, w: string) => (plan ? node : <Skel className={w} />)
|
||||
const rise = plan?.kind === 'sunrise'
|
||||
return (
|
||||
<div className="relative z-[1] [text-shadow:0_2px_10px_rgb(50_25_70/0.35)]" aria-hidden={plan ? undefined : true}>
|
||||
<p className="m-0 mt-2.5 font-bagel text-[52px] leading-none">{v(sunset && clockShort(sunset), 'w-[150px]')}</p>
|
||||
<p className="m-0 mt-1.5 font-jua text-[21px]">{v(plan?.situation_label ?? plan?.headline, 'w-[190px]')}</p>
|
||||
<p className="m-0 mt-2.5 flex items-baseline gap-1.5">
|
||||
<b className="font-bagel text-[64px] leading-none font-normal">{v(plan?.score, 'w-[110px]')}</b>
|
||||
{plan && <span className="font-jua text-[20px]">점 · {plan.grade_label}</span>}
|
||||
</p>
|
||||
<p className="m-0 mt-1.5 font-jua text-[19px]">
|
||||
{v(plan && [sunAt && `${clockShort(sunAt)} ${rise ? '해 떠요' : '해 져요'}`, plan.situation_label ?? plan.headline].filter(Boolean).join(' · '), 'w-[220px]')}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -54,13 +60,24 @@ function Verdict({ plan }: { plan?: SkyPlanData }) {
|
||||
<b className="mr-1.5 font-jua text-[17px] font-normal">{v(plan?.headline, 'w-20')}</b>
|
||||
{v(plan?.reason, 'w-[220px]')}
|
||||
</p>
|
||||
<small className="mt-1 block text-[12px] font-bold text-(--ink2)">{v(plan && [agree, `노을 점수 ${plan.score}`].filter(Boolean).join(' · '), 'w-48')}</small>
|
||||
<small className="mt-1 block text-[12px] font-bold text-(--ink2)">{v(plan && (agree || '\u00a0'), 'w-48')}</small>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 골든아워 → 해 짐 → 블루아워 */
|
||||
function Timeline({ rows }: { rows?: BestTime[] }) {
|
||||
const TERMS = {
|
||||
sunset: {
|
||||
golden: '해가 낮게 떠 햇빛이 금빛으로 물드는 시간, 해 지기 전 약 30분~1시간',
|
||||
blue: '해가 진 뒤 하늘이 짙은 푸른빛으로 남는 시간, 적힌 시각쯤 어두워져요',
|
||||
},
|
||||
sunrise: {
|
||||
blue: '해 뜨기 전 하늘이 짙은 푸른빛인 시간, 적힌 시각쯤부터 밝아져요',
|
||||
golden: '해가 막 떠 햇빛이 금빛으로 물드는 시간, 적힌 시각까지',
|
||||
},
|
||||
} as const
|
||||
|
||||
/** 노을: 골든아워 → 해 짐 → 블루아워. 일출: 블루아워 → 해 뜸 → 골든아워 */
|
||||
function Timeline({ rows, kind = 'sunset' }: { rows?: BestTime[]; kind?: SkyPlanData['kind'] }) {
|
||||
return (
|
||||
<div className="mx-3 mt-3 rounded-[22px] bg-white px-2 pt-4 pb-3 shadow-[inset_0_-5px_0_var(--shade)]" aria-hidden={rows ? undefined : true}>
|
||||
<ol className="relative grid grid-cols-3">
|
||||
@@ -75,18 +92,14 @@ function Timeline({ rows }: { rows?: BestTime[] }) {
|
||||
</ol>
|
||||
{rows && (
|
||||
<dl className="mx-2 mt-3 flex flex-col gap-1 border-t-[1.5px] border-(--line) pt-2.5 text-[12px] leading-snug text-(--ink2)">
|
||||
{rows.some((t) => t.kind === 'golden') && (
|
||||
<div>
|
||||
<dt className="inline font-extrabold text-(--ink)">골든아워</dt>
|
||||
<dd className="ml-1.5 inline">해가 낮게 떠 햇빛이 금빛으로 물드는 시간, 해 지기 전 약 30분~1시간</dd>
|
||||
</div>
|
||||
)}
|
||||
{rows.some((t) => t.kind === 'blue') && (
|
||||
<div>
|
||||
<dt className="inline font-extrabold text-(--ink)">블루아워</dt>
|
||||
<dd className="ml-1.5 inline">해가 진 뒤 하늘이 짙은 푸른빛으로 남는 시간, 적힌 시각쯤 어두워져요</dd>
|
||||
</div>
|
||||
)}
|
||||
{rows
|
||||
.filter((t) => t.kind === 'golden' || t.kind === 'blue')
|
||||
.map((t) => (
|
||||
<div key={t.kind}>
|
||||
<dt className="inline font-extrabold text-(--ink)">{t.label}</dt>
|
||||
<dd className="ml-1.5 inline">{TERMS[kind][t.kind as 'golden' | 'blue']}</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
)}
|
||||
</div>
|
||||
@@ -140,8 +153,10 @@ export function SkyPage() {
|
||||
const plan = sky.data?.plan ?? undefined
|
||||
const spots = (sky.data?.spots ?? []).slice(0, 3)
|
||||
const items = (ranking.data?.items ?? []).slice(0, 8)
|
||||
const target = sky.data?.days?.find((d) => d.day === plan?.day)
|
||||
const sunset = plan?.timeline?.find((t) => t.kind === 'sun')?.at
|
||||
const target = plan?.kind === 'sunrise' ? sky.data?.sunrise : sky.data?.days?.find((d) => d.day === plan?.day)
|
||||
const sunAt = plan?.timeline?.find((t) => t.kind === 'sun')?.at
|
||||
const rise = plan?.kind === 'sunrise'
|
||||
const word = rise ? '일출' : '노을'
|
||||
|
||||
return (
|
||||
<section aria-label="노을" aria-busy={load === 'loading'} className={cx('transition-opacity', sky.isPlaceholderData && 'opacity-60')}>
|
||||
@@ -151,25 +166,25 @@ export function SkyPage() {
|
||||
<div className="b-skyline pointer-events-none absolute inset-0 [--sky-h:22%]" aria-hidden="true" />
|
||||
{/* 하늘 위 흰 글씨 대비가 모자라 어두운 바탕을 깐다 */}
|
||||
<p className="relative z-[1] m-0 self-start rounded-full bg-[rgb(30_18_60/0.35)] px-2.5 py-0.5 text-[13px] font-extrabold">
|
||||
{plan?.when ?? '오늘'} 노을 · {region.name}
|
||||
{plan?.when ?? '오늘'} {word} · {region.name}
|
||||
</p>
|
||||
{plan || load === 'loading' ? (
|
||||
<HeroBody plan={plan} sunset={sunset} />
|
||||
<HeroBody plan={plan} sunAt={sunAt} />
|
||||
) : (
|
||||
<StateBox load={load} onRetry={() => sky.refetch()} empty="오늘 노을 정보가 없어요." hold={<HeroBody />} className="inset-x-0 top-1.5 bottom-0" />
|
||||
)}
|
||||
</div>
|
||||
{(plan || load === 'loading') && <Verdict plan={plan} />}
|
||||
<Sec title="언제 보면 좋을까" sub="보통 해 진 뒤 10~20분이 가장 붉어요" />
|
||||
<Sec title="언제 보면 좋을까" sub={rise ? '보통 해 뜨기 10~20분 전이 가장 붉어요' : '보통 해 진 뒤 10~20분이 가장 붉어요'} />
|
||||
{plan?.timeline?.length || load === 'loading' ? (
|
||||
<Timeline rows={plan?.timeline} />
|
||||
<Timeline rows={plan?.timeline} kind={plan?.kind} />
|
||||
) : (
|
||||
<StateBox load="ready" empty={load === 'ready' ? '노을 시간 정보가 없어요.' : '노을 시간을 불러오지 못했어요.'} hold={<Timeline />} className="inset-x-3 top-3 bottom-0" />
|
||||
)}
|
||||
{/* 더 나은 날이 있을 때만 */}
|
||||
{plan?.outlook && <p className="mx-3 mt-3 mb-0 rounded-[22px] bg-[#ffe6ec] px-4 py-3 text-[14px] font-bold text-[#7a2a4a]">{plan.outlook}</p>}
|
||||
<Sec title="가까운 노을 명소" sub="가까운 순 · 방향은 내 동네에서 본 쪽" />
|
||||
{spots.length ? (
|
||||
{!rise && <Sec title="가까운 노을 명소" sub="가까운 순 · 방향은 내 동네에서 본 쪽" />}
|
||||
{rise ? null : spots.length ? (
|
||||
<ul className="mx-3 mt-1.5 flex flex-col">
|
||||
{spots.map((p) => (
|
||||
<Li key={p.no} no={p.no} title={p.name} sub={p.direction ? `${p.direction}쪽` : null} right={`${p.distance_km}km`} place={p.name} />
|
||||
|
||||
Reference in new issue
Block a user