feat: 노을 탭 3일 하늘 타일 — 히어로 문장·타일 색·피드 카드를 점수 등급 기준으로(잿빛이면 거의 안 보인다고), 타일 누르면 그날로, 다른 날 안내도 등급 기준
This commit is contained in:
1 parent
118a7b29ff
commit
52b79c6de9
9 files changed
+152
-90
No files matched your search
@@ -1701,6 +1701,12 @@ export type ResSky = {
|
||||
*/
|
||||
spots?: Array<SpotData>;
|
||||
plan?: SkyPlanData | null;
|
||||
/**
|
||||
* Plans
|
||||
*
|
||||
* plan 과 같은 종류로 아직 안 끝난 날 최대 3일 (날짜 타일, 누르면 그날로)
|
||||
*/
|
||||
plans?: Array<SkyPlanData>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1905,6 +1911,12 @@ export type Row = {
|
||||
* 위치가 정해진 장소면 지도에서 찾을 이름 (앱이 네이버 지도 링크를 건다)
|
||||
*/
|
||||
place?: string | null;
|
||||
/**
|
||||
* Level
|
||||
*
|
||||
* 자외선 단계 1 낮음 ~ 5 위험. 있으면 앱이 값을 단계 색 칩으로 그린다
|
||||
*/
|
||||
level?: number | null;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+57
-25
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import type { ReactNode } from 'react'
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { getSkyOptions, getSkyRankingOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import type { BestTime, SkyPlanData } from '../api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
@@ -34,34 +34,66 @@ const THREE = [0, 1, 2]
|
||||
const FOUR = [0, 1, 2, 3]
|
||||
const RANK_SKELS = Array.from({ length: 8 }, (_, i) => i)
|
||||
|
||||
/** 히어로엔 답만: 갈 만한지, 몇 시에, 왜(쉬운 말 한 줄). 숫자는 아래 '자세히'로 */
|
||||
/** 점수 등급별 하늘색: 히어로 배경과 3일 타일이 같은 색 */
|
||||
const GRADE_SKY: Record<string, { hero: string; tile: string }> = {
|
||||
잿빛: { hero: 'bg-[linear-gradient(180deg,#6f7690,#9aa0b4_55%,#b9b4c0)]', tile: 'bg-[linear-gradient(160deg,#8f8aa5,#b9b0bf)]' },
|
||||
은은함: { hero: 'bg-[linear-gradient(180deg,#4b5aa8,#7f86c6_40%,#e9b9a8_78%,#ffb27a)]', tile: 'bg-[linear-gradient(160deg,#7f86c6,#e9b9a8_70%,#f6b07a)]' },
|
||||
고움: { hero: 'bg-[linear-gradient(180deg,#5b3f9e,#c2559a_45%,#ff7a6a_78%,#ffb35c)]', tile: 'bg-[linear-gradient(160deg,#5b3f9e,#c2559a_55%,#ff7a6a)]' },
|
||||
붉음: { hero: 'bg-[linear-gradient(180deg,#4a2a8a,#b0306a_40%,#ff4a3a_72%,#ff9a3c)]', tile: 'bg-[linear-gradient(160deg,#4a2a8a,#b0306a_50%,#ff4a3a)]' },
|
||||
}
|
||||
const skyOf = (p?: SkyPlanData) => GRADE_SKY[p?.grade_label ?? ''] ?? GRADE_SKY['은은함']
|
||||
|
||||
/** 히어로엔 답만: 등급에 따라 노을 피크 시각과 어떻게 물드는지, 잿빛이면 왜 안 보이는지 */
|
||||
function HeroBody({ plan }: { plan?: SkyPlanData }) {
|
||||
const v = (node: ReactNode, w: string) => (plan ? node : <Skel className={w} />)
|
||||
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 font-jua text-[28px] leading-tight text-balance">{v(plan?.title, 'w-[230px]')}</p>
|
||||
{/* 보이는 날만 그날 하늘 한 줄 */}
|
||||
{(!plan || plan.situation_label) && <p className="m-0 mt-1.5 font-jua text-[19px]">{v(plan?.situation_label, 'w-[200px]')}</p>}
|
||||
{(!plan || plan.situation_label) && <p className="m-0 mt-1.5 text-[15px] font-bold">{v(plan?.situation_label, 'w-[180px]')}</p>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 점수·구름·예보 모델처럼 궁금한 사람만 볼 숫자 */
|
||||
function Details({ plan, sunAt }: { plan: SkyPlanData; sunAt?: string }) {
|
||||
// 지금 하늘이 아니라 해 질(뜰) 무렵 예보라는 걸 밝힌다
|
||||
const hour = sunAt ? new Date(sunAt).getHours() : null
|
||||
/** 오늘·내일·모레를 그날 예상 하늘색 타일로. 누르면 그날로 */
|
||||
function DayTiles({ plans, day, onPick }: { plans: SkyPlanData[]; day?: string; onPick: (day: string) => void }) {
|
||||
return (
|
||||
<details className="mx-3 mt-2 rounded-[18px] bg-white/70 px-4 py-2.5 text-[13px] font-semibold text-(--ink2)">
|
||||
<summary className="cursor-pointer font-extrabold">자세히</summary>
|
||||
<p className="m-0 mt-1">
|
||||
{plan.kind === 'sunrise' ? '일출' : '노을'} 점수 {plan.score}점 / 100점 · {plan.grade_label}
|
||||
<span className="block text-[12px]">80점 넘으면 붉게, 60점 넘으면 곱게, 40점 넘으면 은은하게 물들어요</span>
|
||||
<div className="mx-3 mt-2.5 grid grid-cols-3 gap-2">
|
||||
{plans.map((p) => (
|
||||
<button
|
||||
key={p.day}
|
||||
type="button"
|
||||
aria-pressed={p.day === day}
|
||||
onClick={() => onPick(p.day)}
|
||||
className={cx(
|
||||
'grid cursor-pointer gap-px rounded-2xl px-2.5 pt-2 pb-2.5 text-left text-white [text-shadow:0_1px_4px_rgb(40_20_50/0.35)]',
|
||||
skyOf(p).tile,
|
||||
p.day === day && 'outline-[3px] outline-offset-2 outline-(--ink) outline-solid',
|
||||
)}
|
||||
>
|
||||
<small className="text-[11.5px] font-extrabold">{p.when}</small>
|
||||
<b className="font-jua text-lg leading-tight font-normal">{p.best_at ? clockShort(p.best_at) : '–'}</b>
|
||||
<span className="text-[11.5px] font-bold">
|
||||
{p.grade_label} {p.score}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 노을 점수 뜻. 지금 하늘이 아니라 해 질(뜰) 무렵 예보라는 것도 */
|
||||
function ScoreHelp({ plan }: { plan: SkyPlanData }) {
|
||||
const sunAt = plan.timeline?.find((t) => t.kind === 'sun')?.at
|
||||
return (
|
||||
<details className="mx-3 mt-1.5 px-1 text-[12px] font-bold text-(--ink2)">
|
||||
<summary className="flex cursor-pointer list-none items-center justify-between [&::-webkit-details-marker]:hidden">
|
||||
노을 점수 100점 만점 · 높을수록 붉어요
|
||||
<span className="grid size-[18px] place-items-center rounded-full bg-white/80 text-[11px] font-extrabold">?</span>
|
||||
</summary>
|
||||
<p className="m-0 mt-1.5 rounded-xl bg-white/70 px-2.5 py-2 leading-snug font-semibold">
|
||||
80점 넘으면 붉게, 60점 넘으면 곱게, 40점 넘으면 은은하게 물들어요.
|
||||
{sunAt && ` 해 ${plan.kind === 'sunrise' ? '뜰' : '질'} 무렵(${new Date(sunAt).getHours()}시) 날씨 예보로 계산했고, 노을 피크 시각은 해 ${plan.kind === 'sunrise' ? '뜨기 10~20분 전' : '지고 10~20분 뒤'}로 어림한 거라 실제와 다를 수 있어요.`}
|
||||
</p>
|
||||
{hour != null && (
|
||||
<p className="m-0 mt-1 text-[12px]">
|
||||
{plan.when} {hour}시 날씨 예보로 계산했어요. 가장 붉은 시각은 해 {plan.kind === 'sunrise' ? '뜨기 10~20분 전' : '지고 10~20분 뒤'}로 어림한 거라 실제와 다를 수 있어요
|
||||
</p>
|
||||
)}
|
||||
</details>
|
||||
)
|
||||
}
|
||||
@@ -145,17 +177,18 @@ export function SkyPage() {
|
||||
const ranking = useQuery(getSkyRankingOptions())
|
||||
const load = loadOf(sky)
|
||||
const rankLoad = loadOf(ranking)
|
||||
const plan = sky.data?.plan ?? undefined
|
||||
const plans = sky.data?.plans ?? []
|
||||
const [picked, setPicked] = useState<string>()
|
||||
// 타일을 누르면 그날, 아니면 다음에 오는 날
|
||||
const plan = plans.find((p) => p.day === picked) ?? sky.data?.plan ?? undefined
|
||||
const spots = (sky.data?.spots ?? []).slice(0, 3)
|
||||
const items = (ranking.data?.items ?? []).slice(0, 8)
|
||||
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'
|
||||
|
||||
return (
|
||||
<section aria-label="노을" aria-busy={load === 'loading'} className={cx('transition-opacity', sky.isPlaceholderData && 'opacity-60')}>
|
||||
{/* 히어로 상자는 불러오는 중·실패·빈 값 모두 같은 크기 */}
|
||||
<div className={cx(HERO, `b-sit-${target?.situation ?? 3}`)}>
|
||||
<div className={cx(HERO, skyOf(plan).hero)}>
|
||||
<i className="b-sit-sun pointer-events-none absolute bottom-6 left-1/2 -ml-[56px] size-[112px] rounded-full" aria-hidden="true" />
|
||||
<div className="b-skyline pointer-events-none absolute inset-0 [--sky-h:22%]" aria-hidden="true" />
|
||||
{plan || load === 'loading' ? (
|
||||
@@ -164,9 +197,8 @@ export function SkyPage() {
|
||||
<StateBox load={load} onRetry={() => sky.refetch()} empty="오늘 노을 정보가 없어요." hold={<HeroBody />} className="inset-x-0 top-1.5 bottom-0" />
|
||||
)}
|
||||
</div>
|
||||
{/* 더 나은 날이 있으면 히어로 바로 아래 */}
|
||||
{plan?.outlook && <p className="mx-3 mt-3 mb-0 rounded-[18px] bg-[#e8f6ee] px-4 py-2.5 text-[14px] font-extrabold text-[#1d6b46]">{plan.outlook}</p>}
|
||||
{plan && <Details plan={plan} sunAt={sunAt} />}
|
||||
{plans.length > 1 && <DayTiles plans={plans} day={plan?.day} onPick={setPicked} />}
|
||||
{plan && <ScoreHelp plan={plan} />}
|
||||
<Sec title="언제 보면 좋을까" />
|
||||
{plan?.timeline?.length || load === 'loading' ? (
|
||||
<Timeline rows={plan?.timeline} kind={plan?.kind} />
|
||||
|
||||
Reference in new issue
Block a user