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

+128 -78
View File
@@ -4,18 +4,18 @@ import { useQuery } from '@tanstack/react-query'
import { getFeedOptions, getWeatherTodayOptions } from '../api/client/@tanstack/react-query.gen'
import type { BandArticle, BandEvent, Hero as HeroData, ResWeatherToday, TopIndex } from '../api/client/types.gen'
import { cx } from '../lib/utils'
import { cardBg, fall, kindOfHour, kst, MEDALS, sidoOf, WEEKDAYS, type TimeKind } from './lib'
import { PostCard } from './Post'
import { cardBg, kindOfHour, kst, type Load, loadOf, MEDALS, type TimeKind, WEEKDAYS } from './lib'
import { PostCard, PostCardSkel } from './Post'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
import { useSky } from './skyContext'
import { Ic, Rail, Sec, StateBox } from './ui'
import { Ic, Rail, Sec, Skel, SkelRail, StateBox, Thumb } from './ui'
import { deg, skyText, slotAt } from './weatherText'
type Mode = 'now' | TimeKind
const MODES: [Mode, string][] = [
['now', '지금 시간'],
['now', '지금'],
['morning', '아침'],
['day', '낮'],
['sunset', '저녁'],
@@ -30,8 +30,8 @@ const PREVIEW: Record<TimeKind, { label: string; clock: string; hour: number }>
night: { label: '밤', clock: '22:10', hour: 22 },
}
const STARS = Array.from({ length: 26 }, (_, i) => ({ left: `${(i * 37) % 100}%`, top: `${(i * 53) % 60}%`, opacity: 0.4 + ((i * 7) % 6) / 10 }))
const ORB_POS = { left: '66%', top: '6px', d: '.5s', f: '4.4s' }
// 불쾌지수는 6~9월에만 뜻이 있고, 그 밖엔 늘 '쾌적'이라 하루 최저·최고(일교차)를 보여 준다
const isMuggySeason = (month: number) => month >= 6 && month <= 9
function useNow(ms = 20000) {
const [now, setNow] = useState(() => new Date())
@@ -42,9 +42,27 @@ function useNow(ms = 20000) {
return now
}
type HeroProps = { hero?: HeroData | null; today?: ResWeatherToday }
// 값이 오기 전엔 그 글자 자리(같은 줄 높이)에 스켈레톤, 못 불러왔거나 값이 없으면 같은 글꼴의 '?'
function heroVal(load: Load, v: ReactNode, skel: string) {
if (v != null) return v
if (load === 'loading')
return (
<>
<Skel className={skel} />
<span className="sr-only">불러오는 중</span>
</>
)
return (
<>
<span className="opacity-50" aria-hidden="true">?</span>
<span className="sr-only">{load === 'ready' ? '정보 없음' : '못 불러왔어요'}</span>
</>
)
}
function Hero({ hero, today }: HeroProps) {
type HeroProps = { hero?: HeroData | null; today?: ResWeatherToday; feedLoad: Load; todayLoad: Load }
function Hero({ hero, today, feedLoad, todayLoad }: HeroProps) {
const { open } = useSheet()
const [mode, setMode] = useState<Mode>('now')
const clock = useNow()
@@ -61,87 +79,85 @@ function Hero({ hero, today }: HeroProps) {
const temp = mode === 'now' && hero ? hero.temp_c : slot?.temp_c
const feels = mode === 'now' && hero ? hero.feels_c : slot?.feels_c
const top1 = hero?.top1
const who = kind === 'night' ? 'bear' : 'rabbit'
const tempLoad = mode === 'now' ? feedLoad : todayLoad
const temps = slots.flatMap((s) => (s.temp_c == null ? [] : [s.temp_c]))
const muggy = isMuggySeason(t.mo)
const feelsLine = temp != null ? `체감 ${deg(feels)}${slot ? ` · ${skyText(slot)}` : ''}` : tempLoad === 'loading' ? null : '체감 ?°'
// 1위 각 이름·점수는 바로 아래 '오늘의 각' 줄에 있으니 히어로는 결론 한 줄만
const gakLine = hero?.bubble ?? (hero ? '오늘은 쉬어 가요' : null)
// 글자 크기는 64(기온)·40(점수)·16(값)·13(라벨) 네 단계. 모든 값은 한 줄이라 로딩·완료·실패 높이가 같다
return (
<div className="b-hero relative mx-3 mt-1 overflow-hidden rounded-[32px] px-[18px] pt-4 pb-[18px]" data-t={kind}>
<div className="b-stars pointer-events-none absolute inset-0" aria-hidden="true">
{STARS.map((s, i) => (
<i key={i} className="absolute size-[3px] rounded-full bg-white shadow-[0_0_6px_#fff]" style={s} />
))}
</div>
<div className="relative z-[3] flex flex-wrap gap-1.5" role="group" aria-label="시간대 배경 미리보기">
<div className="b-hero mx-3 mt-1 rounded-[28px] px-4 pt-3.5 pb-4" data-t={kind}>
<div className="b-seg flex rounded-full p-[3px]" role="group" aria-label="시간대 배경 미리보기">
{MODES.map(([m, l]) => (
<button key={m} type="button" aria-pressed={mode === m} onClick={() => setMode(m)} className={cx('cursor-pointer rounded-full px-2.5 py-[5px] text-xs font-bold', mode === m ? 'bg-(--ink) text-white' : 'bg-white/55 text-(--ink)')}>
<button key={m} type="button" aria-pressed={mode === m} onClick={() => setMode(m)} className="flex-1 cursor-pointer rounded-full py-1 text-[13px] font-bold">
{l}
</button>
))}
</div>
<div className="relative z-[3] mt-3 flex items-end justify-between">
<div>
<p className="mb-1 text-[13.5px] font-bold opacity-85">
{t.mo}월 {t.d}일 {WEEKDAYS[t.wd]}요일 · {mode === 'now' ? '지금' : `${PREVIEW[mode].label} 미리보기`}
<div className="mt-4 flex items-center justify-between gap-3 px-1">
<div className="min-w-0">
<p className="text-[13px] font-bold">
{t.mo}월 {t.d}일 {WEEKDAYS[t.wd]}요일 · {mode === 'now' ? `${String(t.h).padStart(2, '0')}:${String(t.mi).padStart(2, '0')}` : `${PREVIEW[mode].label} ${PREVIEW[mode].clock} 예보`}
</p>
<div className="font-bagel text-[60px] leading-none">{mode === 'now' ? `${String(t.h).padStart(2, '0')}:${String(t.mi).padStart(2, '0')}` : PREVIEW[mode].clock}</div>
<b className="block font-bagel text-[64px] leading-[1.1] font-normal">{heroVal(tempLoad, temp != null ? deg(temp) : null, 'w-[112px]')}</b>
<p className="truncate font-jua text-base">{feelsLine ?? <Skel className="w-[112px]" />}</p>
</div>
<div className="text-right">
<b className="font-bagel text-[42px] leading-none font-normal">{temp != null ? deg(temp) : '--°'}</b>
<span className="block text-[12.5px] font-bold opacity-85">{temp != null ? `체감 ${deg(feels)}${slot ? ` · ${skyText(slot)}` : ''}` : '날씨를 불러오는 중'}</span>
</div>
</div>
<div className="relative z-[3] mt-3 grid grid-cols-2 gap-2.5">
<div className="b-stat flex items-center gap-2.5 rounded-[20px] px-3 py-[9px]">
<Ic name="thermo" className="w-9" />
<div>
<small className="block text-xs font-bold opacity-80">불쾌지수</small>
<b className="font-jua text-lg font-normal">{hero?.discomfort != null ? `${hero.discomfort} · ${hero.discomfort_label ?? ''}` : '-'}</b>
</div>
</div>
<div className="b-stat flex items-center gap-2.5 rounded-[20px] px-3 py-[9px]">
<Ic name="umbrella" className="w-9" />
<div>
<small className="block text-xs font-bold opacity-80">지금 비</small>
<b className="font-jua text-lg font-normal">{hero?.will_rain_2h == null ? '-' : hero.will_rain_2h ? '2시간 안에 비' : '2시간 없음'}</b>
</div>
</div>
</div>
<div className="relative mt-5 h-[286px]">
<span className="b-cloud b-fall top-6 left-[6%] h-[30px] w-[84px]" style={fall('.1s', '6s')} aria-hidden="true" />
<div className="b-sun b-fall absolute top-10 left-1/2 -ml-[82px] grid aspect-square w-[164px] place-items-center rounded-full text-center" style={fall('0s', '5.6s', '8px')}>
<div className="b-sun b-bob grid size-[112px] shrink-0 place-items-center rounded-full text-center">
<span>
<b className="block font-bagel text-[56px] leading-[0.9] font-normal">{hero?.weather_score ?? '-'}</b>
<small className="mt-0.5 block font-jua text-[14.5px]">오늘 날씨 점수</small>
<b className="block font-bagel text-[40px] leading-[1.1] font-normal">{heroVal(feedLoad, hero?.weather_score, 'w-[52px]')}</b>
<small className="block text-[13px] font-bold">날씨 점수</small>
</span>
</div>
<span className="b-cloud b-fall top-[188px] left-[54%] h-10 w-[118px]" style={fall('.25s', '6.4s')} aria-hidden="true" />
{top1 && (
<button
type="button"
onClick={() => open({ type: 'gak', indexId: top1.index_id })}
aria-label={`1위 ${top1.name} ${top1.score}점, 계산 근거 보기`}
className="b-fall absolute z-[2] flex w-24 cursor-pointer flex-col items-center"
style={{ left: ORB_POS.left, top: ORB_POS.top, ...fall(ORB_POS.d, ORB_POS.f) }}
>
<span className="relative w-[78px]">
<Ic name={top1.icon} className="w-full drop-shadow-[0_10px_12px_rgb(40_48_74/0.16)]" />
<Ic name={MEDALS[0]} className="absolute -top-2 -left-3.5 w-[30px]" />
</span>
<span className="b-orb-label font-jua text-sm whitespace-nowrap">
1위 {top1.name} <em className="font-bagel text-(--orange) not-italic">{top1.score}</em>
</div>
<div className="b-stat mt-4 grid grid-cols-2 rounded-[20px]">
<HeroStat icon="umbrella" label="앞으로 2시간">
{heroVal(feedLoad, hero?.will_rain_2h == null ? null : hero.will_rain_2h ? '비, 우산 챙겨요' : '비 안 와요', 'w-[72px]')}
</HeroStat>
<HeroStat icon="thermo" label={muggy ? '불쾌지수' : '오늘 최저·최고'} className="border-l border-current/10">
{muggy
? heroVal(feedLoad, hero?.discomfort != null ? `${hero.discomfort} · ${hero.discomfort_label ?? ''}` : null, 'w-[72px]')
: heroVal(todayLoad, temps.length ? `${deg(Math.min(...temps))} ~ ${deg(Math.max(...temps))}` : null, 'w-[72px]')}
</HeroStat>
{top1 ? (
<button type="button" onClick={() => open({ type: 'gak', indexId: top1.index_id })} aria-label={`오늘의 1위 ${top1.name} ${top1.score}점, 계산 근거 보기`} className="col-span-2 flex cursor-pointer items-center gap-2 border-t border-current/10 px-3.5 py-2.5 text-left">
<HeroGak line={gakLine} load={feedLoad} />
<span className="shrink-0 text-[13px] font-bold opacity-75" aria-hidden="true">
근거 보기 ›
</span>
</button>
) : (
<div className="col-span-2 flex items-center gap-2 border-t border-current/10 px-3.5 py-2.5">
<HeroGak line={gakLine} load={feedLoad} />
</div>
)}
</div>
{hero?.bubble && (
<div className="relative z-[3] flex items-end gap-2">
<Ic name={who} alt={who === 'rabbit' ? '토끼' : '곰'} className="w-[50px] drop-shadow-[0_8px_10px_rgb(40_48_74/0.15)]" />
<span className="mb-3 rounded-[20px_20px_20px_6px] bg-white px-3.5 py-[9px] font-jua text-base text-(--ink) shadow-[0_8px_16px_rgb(40_48_74/0.1)]">{hero.bubble}</span>
</div>
)}
</div>
)
}
function HeroStat({ icon, label, className, children }: { icon: string; label: string; className?: string; children: ReactNode }) {
return (
<div className={cx('flex min-w-0 items-center gap-2.5 px-3.5 py-2.5', className)}>
<Ic name={icon} className="w-7 shrink-0" />
<div className="min-w-0">
<small className="block text-[13px] font-bold opacity-75">{label}</small>
<b className="block truncate font-jua text-base font-normal">{children}</b>
</div>
</div>
)
}
function HeroGak({ line, load }: { line: string | null; load: Load }) {
return (
<span className="min-w-0 flex-1">
<small className="block text-[13px] font-bold opacity-75">오늘의 각</small>
<b className="block truncate font-jua text-base font-normal">{heroVal(load, line, 'w-[128px]')}</b>
</span>
)
}
function Stories({ items }: { items: TopIndex[] }) {
const { open } = useSheet()
return (
@@ -162,6 +178,36 @@ function Stories({ items }: { items: TopIndex[] }) {
)
}
function PostsSkel() {
return (
<>
<PostCardSkel />
<PostCardSkel />
</>
)
}
const STORY_SKELS = Array.from({ length: 6 }, (_, i) => i)
/** Stories 와 같은 칸(68px 동그라미 + 이름 + 점수)을 6개 */
function StoriesSkel() {
return (
<SkelRail>
{STORY_SKELS.map((i) => (
<span key={i} className="flex w-[72px] flex-col items-center gap-1">
<Skel shape className="size-[68px] rounded-full" />
<b className="font-jua text-[13px] font-normal">
<Skel className="w-12" />
</b>
<em className="font-bagel text-[12.5px] leading-none not-italic">
<Skel className="w-6" />
</em>
</span>
))}
</SkelRail>
)
}
function Band({ tone, title, sub, to, children }: { tone: 1 | 2 | 3; title: string; sub: string; to: string; children: ReactNode }) {
return (
<section className={cx('mt-3.5 pt-4 pb-3.5', `b-band-${tone}`)} aria-label={title}>
@@ -172,16 +218,14 @@ function Band({ tone, title, sub, to, children }: { tone: 1 | 2 | 3; title: stri
}
function EventsBand({ events }: { events: BandEvent[] }) {
const { region } = useRegion()
return (
<Band tone={1} title={`이번 주 ${sidoOf(region.name)} 행사`} sub="날씨까지 같이 보고 골라요" to="/week">
<Band tone={1} title="이번 주 가까운 행사" sub="30km 안 · 날씨까지 같이 보고 골라요" to="/week">
<Rail>
{events.map((e, i) => (
<Link key={e.event_id} to="/week" className="w-[200px] overflow-hidden rounded-[22px] bg-white shadow-[inset_0_-5px_0_var(--shade),0_8px_16px_rgb(40_48_74/0.06)]">
<span className={cx('relative grid h-[116px] place-items-center', `b-bg-${cardBg(e.icon, i)}`)}>
<Thumb image={e.image} icon={e.icon} credit={e.image_credit} className={cx('h-[116px]', `b-bg-${cardBg(e.icon, i)}`)} iconClassName="w-[76px]">
<span className={cx('absolute top-2.5 left-2.5 rounded-full px-2 py-[3px] text-[11.5px] font-extrabold text-white', e.status_label === '진행 중' ? 'bg-[#1f9d62]' : 'bg-(--orange)')}>{e.status_label}</span>
<Ic name={e.icon} className="w-[76px]" />
</span>
</Thumb>
<span className="block px-3 pt-2.5 pb-3">
<b className="block font-jua text-[16.5px] leading-snug font-normal">{e.name}</b>
</span>
@@ -241,6 +285,7 @@ export function TodayPage() {
const stories = f?.stories ?? []
const bands = f?.bands
const nowAt = f?.hero?.now_at
const load = loadOf(feed)
// 디자인대로 3·6·9번째 글 뒤에 띠를 넣고, 글이 모자라면 남은 띠는 맨 뒤에 붙인다
const bandAt: [number, ReactNode][] = [
@@ -250,12 +295,17 @@ export function TodayPage() {
]
return (
<section aria-label="오늘">
<Hero hero={f?.hero} today={today.data} />
<section aria-label="오늘" aria-busy={load === 'loading'} className={cx('transition-opacity', feed.isPlaceholderData && 'opacity-60')}>
<Hero hero={f?.hero} today={today.data} feedLoad={load} todayLoad={loadOf(today)} />
<Sec title="오늘의 각" sub="누르면 계산 근거를 보여 줘요" more={{ to: '/gak' }} />
{stories.length ? <Stories items={stories} /> : <StateBox loading={feed.isPending} error={feed.error} onRetry={() => feed.refetch()} empty="오늘 계산된 각이 없어요." />}
<StateBox loading={feed.isPending} error={feed.error} onRetry={() => feed.refetch()} empty={feed.isSuccess && !posts.length ? '오늘 올라온 글이 아직 없어요.' : undefined} />
{/* 실패 안내는 여기 한 번만, 각 줄 스켈레톤과 같은 크기로 */}
{stories.length ? <Stories items={stories} /> : load === 'loading' ? <StoriesSkel /> : <StateBox load={load} onRetry={() => feed.refetch()} empty="오늘 계산된 각이 없어요." hold={<StoriesSkel />} className="inset-x-3 top-3 bottom-1" />}
<div>
{load === 'loading' && <PostsSkel />}
{/* 글이 없거나 못 받아도 스켈레톤 두 장 자리는 그대로 둔다 */}
{load !== 'loading' && !posts.length && (
<StateBox load="ready" empty={load === 'ready' ? '오늘 올라온 글이 아직 없어요.' : '글을 불러오지 못했어요.'} hold={<PostsSkel />} className="inset-x-3 top-3.5 bottom-auto" />
)}
{posts.map((p, i) => (
<Fragment key={p.post_id}>
<PostCard post={p} />