feat: 로딩 스켈레톤·행사 사진·전시·주말 예상 점수·노을 탭 재정리 등 화면 전반 개선

- 화면 전체 스켈레톤, 로딩·완료·실패 사이 레이아웃 고정, 값 없음은 '?'
- 행사 사진·출처 표시, 문화정보 API 전시 연결, 행사 30km 거리 기준
- 각 상세 점수 칸 오늘/내일/토/일, 단기예보 밖 주말은 중기예보 예상 점수
- 6각 차트 축 이름을 좋은 방향으로, 계산 근거 문구 정리
- 아이콘 오용·뜻 모를 표시·빈 데이터·포스트 본문 반복 수정
- 미세먼지 별도 포스트, 노을 명소 전국 155곳 거리 기준, 노을 탭 결론 중심 재구성
- 밤 다크 테마·별똥별, 댓글·좋아요 대기·실패 표시
- 주말 전국 랭킹·당일치기 카드, 계절 이야기 사진 수집
- 문서: 포스트 타입별 내용, 각 데이터 정리, TODO 진행 순서
This commit is contained in:
minaChoi committed 2026-10-06 16:36:11 +09:00
1 parent 296a09d6db
commit ddf05aeb5c
97 files changed
+5475 -720

No files matched your search

+170 -74
View File
@@ -1,10 +1,11 @@
import { useQuery } from '@tanstack/react-query'
import type { ReactNode } from 'react'
import { getSkyOptions, getSkyRankingOptions } from '../api/client/@tanstack/react-query.gen'
import type { RegionData, SpotData } from '../api/client/types.gen'
import type { BestTime, RegionData, SkyPlanData, SpotData } from '../api/client/types.gen'
import { cx } from '../lib/utils'
import { clockShort, dayLabel, timeWords } from './lib'
import { clockShort, compass, dayLabel, loadOf } from './lib'
import { useRegion } from './regionContext'
import { Rail, Sec, StateBox } from './ui'
import { Sec, Skel, StateBox } from './ui'
const W = 400
const H = 260
@@ -45,7 +46,7 @@ function SpotMap({ region, spots, azimuth }: { region: RegionData; spots: SpotDa
<path d={`M${cx0} ${cy0} L${dir(260, -0.3).join(' ')} L${dir(260, 0.3).join(' ')} Z`} fill="#ff8e4e" opacity=".18" />
<path d={`M${cx0} ${cy0} L${tip.join(' ')}`} stroke="#ff7a45" strokeWidth="3" strokeDasharray="7 6" />
<text x={Math.min(W - 110, Math.max(8, label[0] - 50))} y={label[1] + 26} fontFamily="Jua,sans-serif" fontSize="14" fill="#d4552a">
해 지는 쪽 {azimuth}°
해 지는 {compass(azimuth)}쪽
</text>
</>
)}
@@ -67,21 +68,124 @@ function SpotMap({ region, spots, azimuth }: { region: RegionData; spots: SpotDa
)
}
function Li({ no, title, sub, right, meter, mine = false }: { no: number; title: string; sub?: string | null; right: string; meter?: number; mine?: boolean }) {
function LiSkel({ ghost = false }: { ghost?: boolean }) {
return (
<li className={cx('grid grid-cols-[34px_1fr_auto] items-center gap-2.5 border-b-[1.5px] border-(--line) px-1 py-3 last:border-b-0', ghost && 'invisible')} aria-hidden="true">
<span className="text-center font-bagel text-xl">
<Skel className="w-5" />
</span>
<span>
<b className="block font-jua text-[17px] font-normal">
<Skel className="w-24" />
</b>
<small className="block truncate text-[12.5px] font-semibold">
<Skel className="w-40" />
</small>
</span>
<em className="font-jua text-base not-italic">
<Skel className="w-9" />
</em>
</li>
)
}
const HERO = 'relative mx-3 mt-1 min-h-[350px] overflow-hidden rounded-[32px] bg-[linear-gradient(180deg,#7e6fe6,#f08aa2_58%,#ffc28a)] px-5 pt-5 pb-16 text-white'
const THREE = [0, 1, 2]
const FOUR = [0, 1, 2, 3]
const RANK_SKELS = Array.from({ length: 8 }, (_, i) => i)
/** 결론 → 왜 → 몇 시에 어디로 → 점수(보조). 글자 줄 수를 고정해 스켈레톤과 크기가 같다 */
function HeroBody({ plan }: { plan?: SkyPlanData }) {
const v = (node: ReactNode, w: string) => (plan ? node : <Skel className={w} />)
const place = plan && (plan.spot ? `${plan.spot.name} · ${plan.spot.distance_km}km` : plan.verdict === 'rest' ? '오늘은 나가지 않아도 돼요' : '30km 안에 등록된 명소가 없어요')
return (
<div aria-hidden={plan ? undefined : true}>
<p className="relative m-0 mt-1.5 font-jua text-[38px] leading-[1.1]">{v(plan?.headline, 'w-[200px]')}</p>
<div className="relative z-[1] mt-3 rounded-[20px] bg-[rgb(45_36_64/0.55)] px-4 py-3">
<p className="m-0 line-clamp-2 h-[2lh] text-[14.5px] leading-snug font-bold">{v(plan?.reason, 'w-[250px]')}</p>
<div className="mt-2.5 grid grid-cols-[auto_1fr] items-center gap-x-3 border-t border-white/25 pt-2.5">
<b className="row-span-2 font-bagel text-[30px] leading-none font-normal">{v(plan?.best_at && clockShort(plan.best_at), 'w-[76px]')}</b>
<span className="text-[13px] font-extrabold">{v(plan && '가장 붉을 때', 'w-20')}</span>
<span className="truncate text-[13px] font-bold">{v(place, 'w-36')}</span>
</div>
<p className="m-0 mt-2.5 border-t border-white/25 pt-2 text-[12.5px] leading-snug font-bold">
{v(plan && `노을 점수 ${plan.score}점 · ${plan.grade_label}`, 'w-32')}
<small className="block text-[12px] font-semibold">{v(plan && '해 지는 쪽 구름 높이·양으로 매겨요. 60점부터 나가 볼 만해요', 'w-56')}</small>
</p>
</div>
</div>
)
}
/** 일몰 전 골든아워 → 해 짐 → 가장 붉을 때 → 블루아워, 한 줄 */
function Timeline({ rows }: { rows?: BestTime[] }) {
return (
<ol className="relative mx-3 mt-3 grid grid-cols-4 rounded-[22px] bg-white px-2 pt-4 pb-3 shadow-[inset_0_-5px_0_var(--shade)]" aria-hidden={rows ? undefined : true}>
<span className="absolute inset-x-[12.5%] top-[22px] h-0.5 bg-(--line)" aria-hidden="true" />
{(rows ?? FOUR.map(() => undefined)).map((t, i) => (
<li key={t?.kind ?? i} className="relative flex flex-col items-center text-center">
<span className={cx('size-3 rounded-full border-2 border-(--line) bg-white', t?.kind === 'peak' && 'border-[#d6457a] bg-[#d6457a]')} />
<b className={cx('mt-1.5 font-bagel text-lg leading-tight font-normal', t?.kind === 'peak' && 'text-[#d6457a]')}>{t ? clockShort(t.at) : <Skel className="w-12" />}</b>
<span className="text-[12px] font-bold text-(--ink2)">{t ? t.label : <Skel className="w-11" />}</span>
</li>
))}
</ol>
)
}
function SpotsSkel() {
return (
<>
<Skel shape className="mx-3 mt-3 aspect-[400/260] rounded-[26px]" />
<ul className="mx-3 mt-1.5 flex flex-col">
{THREE.map((i) => (
<LiSkel key={i} />
))}
</ul>
</>
)
}
function DaysSkel() {
return (
<div className="grid grid-cols-3 gap-2 p-3" aria-hidden="true">
{THREE.map((i) => (
<div key={i} className="rounded-[20px] bg-white p-3 text-center shadow-[inset_0_-5px_0_var(--shade)]">
<small className="block text-[12.5px] font-extrabold">
<Skel className="w-10" />
</small>
<b className="block font-bagel text-[30px] font-normal">
<Skel className="w-10" />
</b>
<span className="block text-xs font-bold">
<Skel className="w-12" />
</span>
</div>
))}
</div>
)
}
function RankSkel() {
return (
<ul className="mx-3 mt-1.5 flex flex-col" aria-hidden="true">
{RANK_SKELS.map((i) => (
<LiSkel key={i} />
))}
</ul>
)
}
function Li({ no, title, sub, right, mine = false }: { no: number; title: string; sub?: string | null; right: string; mine?: boolean }) {
return (
<li className={cx('grid grid-cols-[34px_1fr_auto] items-center gap-2.5 border-b-[1.5px] border-(--line) px-1 py-3 last:border-b-0', mine && 'rounded-2xl bg-white')}>
<span className="text-center font-bagel text-xl text-(--orange)">{no}</span>
<span>
<span className="min-w-0">
<b className="block font-jua text-[17px] font-normal">
{title}
{mine && <small className="ml-1.5 font-sans text-xs font-extrabold text-(--rain)">내 지역</small>}
</b>
{sub && <small className="text-[12.5px] font-semibold text-(--ink2)">{sub}</small>}
{meter != null && (
<span className="mt-[5px] block h-1.5 overflow-hidden rounded-full bg-[#eef1f6]">
<s className="block h-full bg-[linear-gradient(90deg,#ffc86e,#ff6f8e)]" style={{ width: `${meter}%` }} />
</span>
)}
<small className="block truncate text-[12.5px] font-semibold text-(--ink2)">{sub || '\u00a0'}</small>
</span>
<em className="font-jua text-base not-italic">{right}</em>
</li>
@@ -92,57 +196,54 @@ export function SkyPage() {
const { region } = useRegion()
const sky = useQuery(getSkyOptions({ query: { region: region.code } }))
const ranking = useQuery(getSkyRankingOptions())
const s = sky.data?.sunset
const times = s?.best_times ?? []
const peak = times.find((t) => t.kind === 'peak')
const spots = sky.data?.spots ?? []
const load = loadOf(sky)
const rankLoad = loadOf(ranking)
const plan = sky.data?.plan ?? undefined
const spots = (sky.data?.spots ?? []).slice(0, 3)
const days = sky.data?.days ?? []
const items = (ranking.data?.items ?? []).slice(0, 8)
const target = Math.max(0, days.findIndex((d) => d.day === plan?.day))
const best = days.reduce<number>((b, d, i) => (d.score > days[b].score ? i : b), target)
// 서버 outlook 과 같은 기준: 10점 넘게 나을 때만 더 나은 날로 표시
const better = days.length > 0 && days[best].score - days[target].score > 10 ? best : -1
return (
<section aria-label="노을">
{s ? (
<div className="relative mx-3 mt-1 min-h-[300px] overflow-hidden rounded-[32px] bg-[linear-gradient(180deg,#7e6fe6,#f08aa2_58%,#ffc28a)] px-5 pt-5 pb-16 text-white">
<div className="b-skyline pointer-events-none absolute inset-0 [--sky-h:22%]" aria-hidden="true" />
<p className="relative m-0 text-[13px] font-extrabold opacity-90">오늘 노을 · {region.name}</p>
<b className="relative mt-1.5 block font-bagel text-[96px] leading-[0.9] font-normal">{s.score}</b>
<p className="relative m-0 font-jua text-[29px] leading-tight">
{s.grade_label}
{peak && ` · ${timeWords(peak.at)}이 절정`}
</p>
{times.length > 0 && (
<div className="relative z-[1] mt-[18px]">
<div className="h-2.5 rounded-full bg-[linear-gradient(90deg,#ffd27a,#ff7a6e_50%,#6a5bd6)]" />
<div className="mt-1.5 flex justify-between text-[12.5px] font-extrabold">
{times.map((t, i) => (
<span key={t.kind} className={cx(i === 1 && 'text-center', i === times.length - 1 && i > 0 && 'text-right')}>
<b className="block font-bagel text-lg font-normal">{clockShort(t.at)}</b>
{t.label}
</span>
))}
</div>
</div>
)}
</div>
<section aria-label="노을" aria-busy={load === 'loading'} className={cx('transition-opacity', sky.isPlaceholderData && 'opacity-60')}>
{/* 히어로 상자는 불러오는 중·실패·빈 값 모두 같은 크기 */}
<div className={HERO}>
<div className="b-skyline pointer-events-none absolute inset-0 [--sky-h:16%]" aria-hidden="true" />
<p className="relative m-0 text-[13px] font-extrabold">
{plan?.when ?? '오늘'} 노을 · {region.name}
</p>
{plan || load === 'loading' ? (
<HeroBody plan={plan} />
) : (
<StateBox load={load} onRetry={() => sky.refetch()} empty="오늘 노을 정보가 없어요." hold={<HeroBody />} className="inset-x-0 top-1.5 bottom-0" />
)}
</div>
<Sec title="언제 보면 좋을까" sub={plan ? `${plan.when} 해 지는 시간 기준` : '\u00a0'} />
{plan?.timeline?.length || load === 'loading' ? (
<Timeline rows={plan?.timeline} />
) : (
<StateBox loading={sky.isPending} error={sky.error} onRetry={() => sky.refetch()} empty="오늘 노을 정보가 없어요." />
<StateBox load="ready" empty={load === 'ready' ? '노을 시간 정보가 없어요.' : '노을 시간을 불러오지 못했어요.'} hold={<Timeline />} className="inset-x-3 top-3 bottom-0" />
)}
{times.length > 0 && (
<>
<Sec title="오늘의 노을 3컷" sub="옆으로 넘겨 보세요" />
<Rail label="오늘의 노을 3컷">
{times.map((t, i) => (
<div key={t.kind} className={cx('b-skyline relative h-[150px] w-[230px] overflow-hidden rounded-[22px] px-3.5 py-2.5 font-bagel text-2xl text-white [--sky-h:30%]', `b-cut-${Math.min(i + 1, 3)}`)}>
<span className="relative z-[1]">
{clockShort(t.at)}
<small className="block font-jua text-sm">{t.label}</small>
</span>
</div>
))}
</Rail>
</>
<Sec title="내일·모레가 더 나을까" sub={plan?.outlook || '\u00a0'} />
{days.length > 0 ? (
<div className="grid grid-cols-3 gap-2 p-3">
{days.map((d, i) => (
<div key={d.day} className={cx('rounded-[20px] bg-white p-3 text-center shadow-[inset_0_-5px_0_var(--shade)]', i === better && 'ring-2 ring-[#d6457a] ring-inset')}>
<small className="block text-[12.5px] font-extrabold text-(--ink2)">{dayLabel(d.day, i)}</small>
<b className={cx('block font-bagel text-[30px] font-normal', d.score < 60 ? 'text-(--ink2)' : 'text-[#d6457a]')}>{d.score}</b>
<span className="block text-xs font-bold text-(--ink2)">{d.grade_label}</span>
</div>
))}
</div>
) : load === 'loading' ? (
<DaysSkel />
) : (
<StateBox load="ready" empty={load === 'ready' ? '앞으로 3일 노을 정보가 없어요.' : '앞으로 3일 노을을 불러오지 못했어요.'} hold={<DaysSkel />} className="inset-3" />
)}
<Sec title="가까운 노을 명소" sub={sky.data?.sunset_azimuth != null ? `해 지는 쪽 ${sky.data.sunset_azimuth}° · 서쪽이 트인 곳` : '서쪽이 트인 곳'} />
<Sec title="가까운 노을 명소" sub={sky.data?.sunset_azimuth != null ? `해 지는 ${compass(sky.data.sunset_azimuth)}쪽이 트인 곳, 가까운 순` : '서쪽이 트인 곳, 가까운 순'} />
{spots.length ? (
<>
<SpotMap region={region} spots={spots} azimuth={sky.data?.sunset_azimuth} />
@@ -150,34 +251,29 @@ export function SkyPage() {
{spots.map((p) => (
<Li key={p.no} no={p.no} title={p.name} sub={p.description} right={`${p.distance_km}km`} />
))}
{/* 3곳이 안 되면 빈 줄로 스켈레톤 높이를 지켜 아래 순위가 밀리지 않게 */}
{THREE.slice(spots.length).map((i) => (
<LiSkel key={`ghost-${i}`} ghost />
))}
</ul>
</>
) : load === 'loading' ? (
<SpotsSkel />
) : (
<StateBox loading={sky.isPending} error={sky.error} empty="이 지역은 아직 등록된 노을 명소가 없어요." />
// 실패 안내·다시 시도는 위 히어로에 한 번만. 여기는 지도·목록 자리만 지킨다
<StateBox load="ready" empty={load === 'ready' ? '근처에 등록된 노을 명소가 없어요.' : '명소 정보를 불러오지 못했어요.'} hold={<SpotsSkel />} className="inset-x-3 top-3 bottom-0" />
)}
<Sec title="전국 노을 순위" sub={items[0] ? `오늘 기준 · 1위 ${items[0].name} ${items[0].score}점` : '오늘 기준'} />
<Sec title="전국 노을 순위" sub="오늘 기준" />
{items.length ? (
<ul className="mx-3 mt-1.5 flex flex-col">
{items.map((r) => (
<Li key={r.region_code} no={r.rank} title={r.name} sub={r.note} right={String(r.score)} meter={r.score} mine={r.region_code === region.code} />
<Li key={r.region_code} no={r.rank} title={r.name} sub={r.note} right={`${r.score}점`} mine={r.region_code === region.code} />
))}
</ul>
) : rankLoad === 'loading' ? (
<RankSkel />
) : (
<StateBox loading={ranking.isPending} error={ranking.error} onRetry={() => ranking.refetch()} empty="순위가 아직 없어요." />
)}
{days.length > 0 && (
<>
<Sec title="앞으로 3일" />
<div className="grid grid-cols-3 gap-2 p-3">
{days.map((d, i) => (
<div key={d.day} className="rounded-[20px] bg-white p-3 text-center shadow-[inset_0_-5px_0_var(--shade)]">
<small className="text-[12.5px] font-extrabold text-(--ink2)">{dayLabel(d.day, i)}</small>
<b className={cx('block font-bagel text-[30px] font-normal', d.score < 50 ? 'text-(--ink3)' : 'text-[#d6457a]')}>{d.score}</b>
<span className="text-xs font-bold text-(--ink2)">{d.grade_label}</span>
</div>
))}
</div>
</>
<StateBox load={rankLoad} onRetry={() => ranking.refetch()} empty="순위가 아직 없어요." hold={<RankSkel />} className="inset-x-3 top-1.5 bottom-0" />
)}
</section>
)