feat: 로딩 스켈레톤·행사 사진·전시·주말 예상 점수·노을 탭 재정리 등 화면 전반 개선
- 화면 전체 스켈레톤, 로딩·완료·실패 사이 레이아웃 고정, 값 없음은 '?' - 행사 사진·출처 표시, 문화정보 API 전시 연결, 행사 30km 거리 기준 - 각 상세 점수 칸 오늘/내일/토/일, 단기예보 밖 주말은 중기예보 예상 점수 - 6각 차트 축 이름을 좋은 방향으로, 계산 근거 문구 정리 - 아이콘 오용·뜻 모를 표시·빈 데이터·포스트 본문 반복 수정 - 미세먼지 별도 포스트, 노을 명소 전국 155곳 거리 기준, 노을 탭 결론 중심 재구성 - 밤 다크 테마·별똥별, 댓글·좋아요 대기·실패 표시 - 주말 전국 랭킹·당일치기 카드, 계절 이야기 사진 수집 - 문서: 포스트 타입별 내용, 각 데이터 정리, TODO 진행 순서
This commit is contained in:
1 parent
296a09d6db
commit
ddf05aeb5c
97 files changed
+5475
-720
No files matched your search
+226
-27
@@ -1,11 +1,137 @@
|
||||
import { useState } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getWeekOptions, listEventsOptions, listPlacesOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import { getWeekOptions, getWeekRankingOptions, listEventsOptions, listPlacesOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { cardBg, dateRange, sidoOf } from './lib'
|
||||
import { cardBg, dateRange, loadOf, shortDay, sidoOf } from './lib'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { Ic, Rail, Sec, StateBox } from './ui'
|
||||
import { Chips, Ic, Rail, Sec, Skel, SkelRail, StateBox, Thumb } from './ui'
|
||||
|
||||
const TEN = Array.from({ length: 10 }, (_, i) => i)
|
||||
const THREE = [0, 1, 2]
|
||||
const DAY_BTN = 'flex w-[calc((100%-24px)/7)] shrink-0 snap-start flex-col items-center gap-0.5 rounded-[18px] pt-[9px] pb-2 text-xs font-extrabold'
|
||||
const PLACE_CARD = 'w-[178px] overflow-hidden rounded-[22px] bg-white text-left shadow-[inset_0_-5px_0_var(--shade),0_8px_16px_rgb(40_48_74/0.06)]'
|
||||
const EVENT_CARD = 'mx-3 mt-2.5 grid grid-cols-[84px_1fr] items-center gap-3 rounded-[22px] bg-white p-3 shadow-[inset_0_-5px_0_var(--shade)]'
|
||||
|
||||
function DaysSkel() {
|
||||
return (
|
||||
<div className="flex gap-1 overflow-hidden px-3 pt-3" aria-hidden="true">
|
||||
{TEN.map((i) => (
|
||||
<span key={i} className={cx(DAY_BTN, 'bg-white shadow-[inset_0_-4px_0_var(--shade)]')}>
|
||||
<span>
|
||||
<Skel className="w-3" />
|
||||
</span>
|
||||
<Skel shape className="size-7 rounded-full" />
|
||||
<b className="font-jua text-sm font-normal">
|
||||
<Skel className="w-6" />
|
||||
</b>
|
||||
<span className="px-0.5 text-[9.5px]">
|
||||
<Skel className="w-5" />
|
||||
</span>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function PickSkel() {
|
||||
return (
|
||||
<div className="mx-3 mt-3 flex items-center gap-3.5 rounded-3xl bg-white p-4 shadow-[inset_0_-5px_0_var(--shade)]" aria-hidden="true">
|
||||
<Skel shape className="size-16 shrink-0 rounded-full" />
|
||||
<div className="flex-1">
|
||||
<b className="block font-jua text-[19px] font-normal">
|
||||
<Skel className="w-32" />
|
||||
</b>
|
||||
<p className="mt-0.5 text-[13.5px] font-semibold">
|
||||
<Skel className="w-4/5" />
|
||||
</p>
|
||||
<p className="mt-2 font-jua text-base">
|
||||
<Skel className="w-36" />
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function PlacesSkel() {
|
||||
return (
|
||||
<SkelRail>
|
||||
{THREE.map((i) => (
|
||||
<span key={i} className={PLACE_CARD}>
|
||||
<Skel shape className="h-[104px]" />
|
||||
<span className="block px-3 pt-2.5 pb-3">
|
||||
<span className="text-[11.5px] font-extrabold">
|
||||
<Skel className="w-16" />
|
||||
</span>
|
||||
<b className="block font-jua text-[16.5px] font-normal">
|
||||
<Skel className="w-24" />
|
||||
</b>
|
||||
<small className="block text-[12.5px] leading-snug font-semibold">
|
||||
<Skel className="w-full" />
|
||||
<br />
|
||||
<Skel className="w-20" />
|
||||
</small>
|
||||
</span>
|
||||
</span>
|
||||
))}
|
||||
</SkelRail>
|
||||
)
|
||||
}
|
||||
|
||||
function EventSkel() {
|
||||
return (
|
||||
<div className={EVENT_CARD} aria-hidden="true">
|
||||
<Skel shape className="h-[84px] rounded-2xl" />
|
||||
<span className="min-w-0">
|
||||
<b className="block h-[2lh] font-jua text-[17px] leading-snug font-normal">
|
||||
<Skel className="w-40" />
|
||||
<br />
|
||||
<Skel className="w-20" />
|
||||
</b>
|
||||
<small className="block text-[12.5px] font-semibold">
|
||||
<Skel className="w-44" />
|
||||
</small>
|
||||
<span className="mt-[5px] block h-[1lh] text-xs font-extrabold">
|
||||
<Skel className="w-24" />
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const RANK_ROW = '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'
|
||||
// 불러오는 동안에도 탭 줄 높이를 지키려고 같은 칩을 미리 그린다
|
||||
const RANK_TABS_HOLD = [
|
||||
['토', '토요일'],
|
||||
['일', '일요일'],
|
||||
] as const
|
||||
|
||||
function RankSkel() {
|
||||
return (
|
||||
<ul className="mx-3 mt-1.5 flex flex-col" aria-hidden="true">
|
||||
{TEN.map((i) => (
|
||||
<li key={i} className={RANK_ROW}>
|
||||
<span className="text-center font-bagel text-xl">
|
||||
<Skel className="w-5" />
|
||||
</span>
|
||||
<span className="min-w-0">
|
||||
<b className="block font-jua text-[17px] font-normal">
|
||||
<Skel className="w-24" />
|
||||
</b>
|
||||
<small className="block text-[12.5px] font-semibold">
|
||||
<Skel className="w-40" />
|
||||
</small>
|
||||
<Skel shape className="mt-[5px] h-1.5 rounded-full" />
|
||||
</span>
|
||||
<em className="flex items-center gap-1 font-jua text-base not-italic">
|
||||
<Skel shape className="size-6 rounded-full" />
|
||||
<Skel className="w-9" />
|
||||
</em>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
const PLACE_BG: Record<string, string> = { picnic: 'mint', walk: 'mint', sunset: 'dusk', chimaek: 'peach', photo: 'butter', bulb: 'lilac' }
|
||||
|
||||
@@ -22,11 +148,21 @@ export function WeekPage() {
|
||||
const sel = days.find((d) => d.day === picked) ?? days.find((d) => d.weekday === '토') ?? days[0]
|
||||
const places = useQuery({ ...listPlacesOptions({ query: { region: region.code, day: sel?.day, area: area === '전체' ? undefined : area } }), enabled: !!sel })
|
||||
const events = useQuery(listEventsOptions({ query: { region: region.code } }))
|
||||
const ranking = useQuery(getWeekRankingOptions())
|
||||
const rankDays = ranking.data?.days ?? []
|
||||
const [rankPick, setRankPick] = useState<string | null>(null)
|
||||
const rankDay = rankDays.find((d) => d.day === rankPick) ?? rankDays[0]
|
||||
const rankItems = (rankDay?.items ?? []).slice(0, 10)
|
||||
const rankLoad = loadOf(ranking)
|
||||
const sido = sidoOf(region.name)
|
||||
const areas = places.data?.areas ?? []
|
||||
const rainy = places.data?.rainy ?? sel?.is_rainy
|
||||
const placeList = places.data?.places ?? []
|
||||
const eventList = events.data?.events ?? []
|
||||
const weekLoad = loadOf(week)
|
||||
const eventLoad = loadOf(events)
|
||||
// 날씨(고른 날)가 와야 명소를 부를 수 있다
|
||||
const placeLoad = sel ? loadOf(places) : weekLoad === 'loading' ? 'loading' : 'ready'
|
||||
|
||||
const sendPlan = () => {
|
||||
if (!sel) return
|
||||
@@ -34,10 +170,10 @@ export function WeekPage() {
|
||||
}
|
||||
|
||||
return (
|
||||
<section aria-label="주말·행사">
|
||||
<section aria-label="주말·행사" aria-busy={weekLoad === 'loading'}>
|
||||
<Sec title="열흘 날씨" sub="날짜를 누르면 그날 추천이 바뀌어요" />
|
||||
{days.length ? (
|
||||
<div className="flex snap-x gap-1 overflow-x-auto px-3 pt-3 [scrollbar-width:none]" role="group" aria-label="날짜 고르기">
|
||||
<div className={cx('flex snap-x gap-1 overflow-x-auto px-3 pt-3 transition-opacity [scrollbar-width:none]', week.isPlaceholderData && 'opacity-60')} role="group" aria-label="날짜 고르기">
|
||||
{days.map((d) => {
|
||||
const on = d.day === sel?.day
|
||||
const weekend = d.weekday === '토' || d.weekday === '일' || !!d.holiday
|
||||
@@ -47,18 +183,34 @@ export function WeekPage() {
|
||||
type="button"
|
||||
aria-pressed={on}
|
||||
onClick={() => setPicked(d.day)}
|
||||
className={cx('flex w-[calc((100%-24px)/7)] shrink-0 cursor-pointer snap-start flex-col items-center gap-0.5 rounded-[18px] pt-[9px] pb-2 text-xs font-extrabold', on ? 'bg-(--ink) text-white' : cx('bg-white shadow-[inset_0_-4px_0_var(--shade)]', weekend ? 'text-[#d6457a]' : 'text-(--ink2)'))}
|
||||
className={cx(DAY_BTN, 'cursor-pointer', on ? 'bg-(--ink) text-white' : cx('bg-white shadow-[inset_0_-4px_0_var(--shade)]', weekend ? 'text-[#d6457a]' : 'text-(--ink2)'))}
|
||||
>
|
||||
<span>{d.weekday}</span>
|
||||
<Ic name={d.icon} className="w-7" />
|
||||
<b className={cx('font-jua text-sm font-normal', on ? 'text-white' : 'text-(--ink)')}>{d.temp_max_c != null ? `${Math.round(d.temp_max_c)}°` : '-'}</b>
|
||||
<b className={cx('font-jua text-sm font-normal', on ? 'text-white' : 'text-(--ink)')}>{d.temp_max_c != null ? `${Math.round(d.temp_max_c)}°` : <span className="opacity-50" aria-label="기온 정보 없음">?</span>}</b>
|
||||
<span className={cx('max-w-full truncate px-0.5 text-[9.5px]', on ? 'text-[#ffb3c4]' : 'text-[#d6457a]')}>{d.holiday ? d.holiday.replace(/\(.*\)/, '') : `${Number(d.day.slice(8))}일`}</span>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
) : weekLoad === 'loading' ? (
|
||||
<>
|
||||
<DaysSkel />
|
||||
<PickSkel />
|
||||
</>
|
||||
) : (
|
||||
<StateBox loading={week.isPending} error={week.error} onRetry={() => week.refetch()} empty="날씨가 아직 없어요." />
|
||||
<StateBox
|
||||
load={weekLoad}
|
||||
onRetry={() => week.refetch()}
|
||||
empty="날씨가 아직 없어요."
|
||||
hold={
|
||||
<>
|
||||
<DaysSkel />
|
||||
<PickSkel />
|
||||
</>
|
||||
}
|
||||
className="inset-x-3 top-3 bottom-0"
|
||||
/>
|
||||
)}
|
||||
{sel && (
|
||||
<div className="mx-3 mt-3 flex items-center gap-3.5 rounded-3xl bg-[linear-gradient(180deg,#e9fbf2,#fff)] p-4 shadow-[inset_0_-5px_0_var(--shade)]" aria-live="polite">
|
||||
@@ -66,27 +218,27 @@ export function WeekPage() {
|
||||
<div>
|
||||
<b className="block font-jua text-[19px] font-normal">{sel.headline}</b>
|
||||
<p className="mt-0.5 text-[13.5px] font-semibold text-(--ink2)">{sel.summary}</p>
|
||||
<p className="mt-2 font-jua text-base text-(--ink)">추천: {sel.pick}</p>
|
||||
<p className="mt-2 font-jua text-base text-(--ink)">{sel.pick}</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{areas.length > 0 && (
|
||||
{(sel || weekLoad !== 'ready') && (
|
||||
<div className="mx-3 mt-3.5 flex items-center justify-between">
|
||||
<label htmlFor="b-area" className="text-[13.5px] font-bold text-(--ink2)">
|
||||
{sido} · 데이트 명소
|
||||
</label>
|
||||
<select id="b-area" value={area} onChange={(e) => setAreaPick({ region: region.code, area: e.target.value })} className="rounded-full bg-white px-3 py-[7px] font-bold text-(--ink) shadow-[inset_0_-3px_0_var(--shade)]">
|
||||
<select id="b-area" value={area} onChange={(e) => setAreaPick({ region: region.code, area: e.target.value })} disabled={!areas.length} className="rounded-full bg-white px-3 py-[7px] font-bold text-(--ink) shadow-[inset_0_-3px_0_var(--shade)] disabled:opacity-60">
|
||||
{['전체', ...areas].map((a) => (
|
||||
<option key={a}>{a}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
<Sec title="날씨 맞춤 데이트 명소" sub={sel ? `${sel.weekday}요일은 ${rainy ? '비가 와서 실내 명소를 먼저' : '맑아서 야외 명소를 먼저'} 보여 줘요` : undefined} className="pt-3" />
|
||||
<Sec title="날씨 맞춤 데이트 명소" sub={sel ? `${sel.weekday}요일은 ${rainy ? '비가 와서 실내 명소를 먼저' : sel.icon === 'sun' ? '맑아서 야외 명소를 먼저' : '비 소식이 없어 야외 명소를 먼저'} 보여 줘요` : weekLoad === 'loading' ? <Skel className="w-56" /> : '날씨에 맞춰 골라 보여 줘요'} className="pt-3" />
|
||||
{placeList.length ? (
|
||||
<Rail>
|
||||
<Rail className={cx('transition-opacity', places.isPlaceholderData && 'opacity-60')}>
|
||||
{placeList.map((p, i) => (
|
||||
<div key={p.place_id} className="w-[178px] overflow-hidden rounded-[22px] bg-white text-left shadow-[inset_0_-5px_0_var(--shade),0_8px_16px_rgb(40_48_74/0.06)]">
|
||||
<div key={p.place_id} className={PLACE_CARD}>
|
||||
<span className={cx('relative grid h-[104px] place-items-center', `b-bg-${PLACE_BG[p.icon] ?? (p.is_outdoor ? 'mint' : cardBg(p.icon, i))}`)}>
|
||||
{p.is_good && <span className={cx('absolute top-2.5 left-2.5 rounded-full px-2 py-[3px] text-[11.5px] font-extrabold text-white', p.is_outdoor ? 'bg-[#1f9d62]' : 'bg-(--rain)')}>{p.is_outdoor ? '오늘 딱' : '비 와도 OK'}</span>}
|
||||
<Ic name={p.icon} className="w-[62px]" />
|
||||
@@ -105,33 +257,80 @@ export function WeekPage() {
|
||||
</div>
|
||||
))}
|
||||
</Rail>
|
||||
) : placeLoad === 'loading' ? (
|
||||
<PlacesSkel />
|
||||
) : (
|
||||
<StateBox loading={places.isPending && !!sel} error={places.error} onRetry={() => places.refetch()} empty={`${sido} 데이트 명소는 아직 준비 중이에요.`} />
|
||||
<StateBox load={placeLoad} onRetry={() => places.refetch()} empty={sel ? `${sido} 데이트 명소는 아직 준비 중이에요.` : '날씨를 불러오면 명소를 골라 드려요.'} hold={<PlacesSkel />} className="inset-x-3 top-3 bottom-1" />
|
||||
)}
|
||||
<Sec title={`${sido} 축제·행사`} sub="앞으로 30일 · 그날 날씨까지 같이 봐요" className="pt-[18px]" />
|
||||
<Sec title="이번 주말 전국 날씨 순위" sub="낮 10~17시 나들이 날씨 · 대표 지역 30곳 중 10위까지" className="pt-[18px]" />
|
||||
{rankDays.length ? (
|
||||
<Chips label="순위 볼 날" items={rankDays.map((d) => [d.day, `${d.weekday}요일 ${shortDay(d.day)}`] as const)} value={rankDay?.day ?? ''} onChange={setRankPick} />
|
||||
) : (
|
||||
<Chips label="순위 볼 날" items={RANK_TABS_HOLD} value="토" onChange={() => {}} />
|
||||
)}
|
||||
{rankItems.length ? (
|
||||
<ul className={cx('mx-3 mt-1.5 flex flex-col transition-opacity', ranking.isPlaceholderData && 'opacity-60')}>
|
||||
{rankItems.map((r) => {
|
||||
const mine = r.region_code === region.code
|
||||
return (
|
||||
<li key={r.region_code} className={cx(RANK_ROW, mine && 'rounded-2xl bg-white')}>
|
||||
<span className="text-center font-bagel text-xl text-(--orange)">{r.rank}</span>
|
||||
<span className="min-w-0">
|
||||
<b className="block truncate font-jua text-[17px] font-normal">
|
||||
{r.name}
|
||||
{mine && <small className="ml-1.5 font-sans text-xs font-extrabold text-(--rain)">내 지역</small>}
|
||||
</b>
|
||||
<small className="block truncate text-[12.5px] font-semibold text-(--ink2)">
|
||||
{r.reason}
|
||||
{r.estimated && ' · 예상'}
|
||||
</small>
|
||||
<span className="mt-[5px] block h-1.5 overflow-hidden rounded-full bg-[#eef1f6]">
|
||||
<s className="block h-full bg-[linear-gradient(90deg,#9be7c4,#1f9d62)]" style={{ width: `${r.score}%` }} />
|
||||
</span>
|
||||
</span>
|
||||
<em className="flex items-center gap-1 font-jua text-base not-italic">
|
||||
<Ic name={r.icon} className="size-6" />
|
||||
{r.score}점
|
||||
</em>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
) : rankLoad === 'loading' ? (
|
||||
<RankSkel />
|
||||
) : (
|
||||
<StateBox load={rankLoad} onRetry={() => ranking.refetch()} empty="주말 예보가 아직 없어요." hold={<RankSkel />} className="inset-x-3 top-1.5 bottom-0" />
|
||||
)}
|
||||
<Sec title="가까운 축제·행사" sub="30km 안 · 앞으로 30일 · 그날 날씨까지 같이 봐요" className="pt-[18px]" />
|
||||
{eventList.length ? (
|
||||
eventList.map((e, i) => (
|
||||
<div key={e.event_id} className="mx-3 mt-2.5 grid grid-cols-[84px_1fr] items-center gap-3 rounded-[22px] bg-white p-3 shadow-[inset_0_-5px_0_var(--shade)]">
|
||||
<span className={cx('grid h-[84px] place-items-center rounded-2xl', `b-bg-${cardBg(e.icon, i)}`)}>
|
||||
<Ic name={e.icon} className="w-14" />
|
||||
</span>
|
||||
<span>
|
||||
<span className={cx('mr-1.5 inline-block rounded-full px-[7px] py-0.5 align-[2px] text-[11px] font-extrabold', e.status === 'live' ? 'bg-[#dff5ea] text-[#1f7a4f]' : 'bg-[#ffe8dc] text-[#c2471b]')}>{e.status_label}</span>
|
||||
<b className="inline font-jua text-[17px] leading-snug font-normal">{e.name}</b>
|
||||
<small className="block text-[12.5px] font-semibold text-(--ink2)">
|
||||
{dateRange(e.start_date, e.end_date)} · {e.place_name}
|
||||
<div key={e.event_id} className={cx(EVENT_CARD, 'transition-opacity', events.isPlaceholderData && 'opacity-60')}>
|
||||
<Thumb image={e.image} icon={e.icon} credit={e.image_credit} className={cx('h-[84px] rounded-2xl', `b-bg-${cardBg(e.icon, i)}`)} iconClassName="w-14" />
|
||||
{/* 이름 두 줄·정보 한 줄·날씨 한 줄로 고정해 카드 높이가 데이터와 무관하게 같다 */}
|
||||
<span className="min-w-0">
|
||||
<b className="line-clamp-2 h-[2lh] font-jua text-[17px] leading-snug font-normal">
|
||||
<span className={cx('mr-1.5 inline-block rounded-full px-[7px] py-0.5 align-[2px] font-sans text-[11px] leading-normal font-extrabold', e.status === 'live' ? 'bg-[#dff5ea] text-[#1f7a4f]' : 'bg-[#ffe8dc] text-[#c2471b]')}>{e.status_label}</span>
|
||||
{e.name}
|
||||
</b>
|
||||
<small className="block truncate text-[12.5px] font-semibold text-(--ink2)">
|
||||
{[dateRange(e.start_date, e.end_date), e.place_name].filter(Boolean).join(' · ')}
|
||||
{!e.is_confirmed && ' · 일정 확인 필요'}
|
||||
</small>
|
||||
{e.fit && <span className={cx('mt-[5px] inline-block text-xs font-extrabold', e.fit.includes('비') ? 'text-[#d6457a]' : 'text-[#1f9d62]')}>{e.fit}</span>}
|
||||
<span className={cx('mt-[5px] block h-[1lh] text-xs font-extrabold', e.fit?.includes('비') ? 'text-[#d6457a]' : 'text-[#1f9d62]')}>{e.fit}</span>
|
||||
</span>
|
||||
</div>
|
||||
))
|
||||
) : eventLoad === 'loading' ? (
|
||||
THREE.map((i) => <EventSkel key={i} />)
|
||||
) : (
|
||||
<StateBox loading={events.isPending} error={events.error} onRetry={() => events.refetch()} empty="이 지역 행사는 아직 없어요. 다른 지역을 골라 보세요." />
|
||||
<StateBox load={eventLoad} onRetry={() => events.refetch()} empty="30km 안에 열리는 행사가 아직 없어요. 다른 지역을 골라 보세요." hold={THREE.map((i) => <EventSkel key={i} />)} className="inset-x-3 top-2.5 bottom-0" />
|
||||
)}
|
||||
{/* 행사 수가 정해진 뒤에 붙여 목록이 늘어날 때 밀리지 않게 */}
|
||||
{eventLoad !== 'loading' && (
|
||||
<button type="button" onClick={sendPlan} disabled={!sel} className="mx-3 mt-4 block w-[calc(100%-24px)] cursor-pointer rounded-full bg-(--orange) p-[13px] font-jua text-[17px] text-white shadow-[inset_0_-5px_0_var(--orange-deep)] disabled:opacity-60">
|
||||
이번 주말 일정 보내기
|
||||
</button>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user