feat: 시안 B 화면을 기본 화면으로, Hey API로 백엔드 연결
- 예전 화면(/, /a)과 목업 데이터를 지우고 시안 B 를 / 로 - @hey-api/openapi-ts 로 타입·TanStack Query 함수 생성, 토큰·401 갱신 처리 - 공유는 기본 공유창, 없으면 링크 복사 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e134295ce5
commit
f8b47f064a
147 files changed
+12350
No files matched your search
@@ -0,0 +1,184 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getSkyOptions, getSkyRankingOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import type { RegionData, SpotData } from '../api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { clockShort, dayLabel, timeWords } from './lib'
|
||||
import { useRegion } from './regionContext'
|
||||
import { Rail, Sec, StateBox } from './ui'
|
||||
|
||||
const W = 400
|
||||
const H = 260
|
||||
const BLOCKS = [
|
||||
[20, 20, 90, 60],
|
||||
[130, 18, 100, 52],
|
||||
[262, 22, 110, 48],
|
||||
[24, 190, 110, 54],
|
||||
[170, 196, 90, 50],
|
||||
[290, 180, 92, 62],
|
||||
]
|
||||
|
||||
/** 내 구 중심을 기준으로 명소를 km 단위로 놓고, 해 지는 방향을 그린다 */
|
||||
function SpotMap({ region, spots, azimuth }: { region: RegionData; spots: SpotData[]; azimuth: number | null | undefined }) {
|
||||
const kx = 111 * Math.cos((region.lat * Math.PI) / 180)
|
||||
const pts = spots.map((s) => ({ no: s.no, x: (s.lon - region.lon) * kx, y: (s.lat - region.lat) * 111 }))
|
||||
const maxX = Math.max(0.5, ...pts.map((p) => Math.abs(p.x)))
|
||||
const maxY = Math.max(0.5, ...pts.map((p) => Math.abs(p.y)))
|
||||
const scale = Math.min(160 / maxX, 95 / maxY)
|
||||
const cx0 = W / 2
|
||||
const cy0 = H / 2
|
||||
const az = ((azimuth ?? 270) * Math.PI) / 180
|
||||
const dir = (len: number, turn = 0) => [cx0 + Math.sin(az + turn) * len, cy0 - Math.cos(az + turn) * len] as const
|
||||
const tip = dir(190)
|
||||
const label = dir(120)
|
||||
|
||||
return (
|
||||
<div className="mx-3 mt-3 overflow-hidden rounded-[26px] bg-[#eef2e8] shadow-[inset_0_0_0_2px_#e1e7da]">
|
||||
<svg viewBox={`0 0 ${W} ${H}`} role="img" aria-label={`${region.name} 주변 노을 명소 지도`} className="block h-auto w-full">
|
||||
<rect width={W} height={H} fill="#eef2e8" />
|
||||
{BLOCKS.map(([x, y, w, h]) => (
|
||||
<rect key={`${x}-${y}`} x={x} y={y} width={w} height={h} rx="10" fill="#e1e7da" />
|
||||
))}
|
||||
<path d={`M${W / 2 - 10} 0 L${W / 2 + 4} ${H}`} stroke="#fff" strokeWidth="9" />
|
||||
<path d={`M0 ${H / 2 - 30} H${W}`} stroke="#fff" strokeWidth="10" />
|
||||
{azimuth != null && (
|
||||
<>
|
||||
<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}°
|
||||
</text>
|
||||
</>
|
||||
)}
|
||||
<circle cx={cx0} cy={cy0} r="13" fill="#4f97e3" opacity=".25" />
|
||||
<circle cx={cx0} cy={cy0} r="6" fill="#4f97e3" stroke="#fff" strokeWidth="2" />
|
||||
<text x={cx0 + 14} y={cy0 + 18} fontFamily="Pretendard Variable,sans-serif" fontWeight="800" fontSize="11" fill="#2f6fb7">
|
||||
지금 여기
|
||||
</text>
|
||||
{pts.map((p) => (
|
||||
<g key={p.no}>
|
||||
<circle cx={cx0 + p.x * scale} cy={cy0 - p.y * scale} r="13" fill="#ff7a45" stroke="#fff" strokeWidth="3" />
|
||||
<text x={cx0 + p.x * scale} y={cy0 - p.y * scale + 5} textAnchor="middle" fontFamily="Bagel Fat One,sans-serif" fontSize="14" fill="#fff">
|
||||
{p.no}
|
||||
</text>
|
||||
</g>
|
||||
))}
|
||||
</svg>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Li({ no, title, sub, right, meter, mine = false }: { no: number; title: string; sub?: string | null; right: string; meter?: number; 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>
|
||||
<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>
|
||||
)}
|
||||
</span>
|
||||
<em className="font-jua text-base not-italic">{right}</em>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
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 days = sky.data?.days ?? []
|
||||
const items = (ranking.data?.items ?? []).slice(0, 8)
|
||||
|
||||
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>
|
||||
) : (
|
||||
<StateBox loading={sky.isPending} error={sky.error} onRetry={() => sky.refetch()} empty="오늘 노을 정보가 없어요." />
|
||||
)}
|
||||
{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={sky.data?.sunset_azimuth != null ? `해 지는 쪽 ${sky.data.sunset_azimuth}° · 서쪽이 트인 곳` : '서쪽이 트인 곳'} />
|
||||
{spots.length ? (
|
||||
<>
|
||||
<SpotMap region={region} spots={spots} azimuth={sky.data?.sunset_azimuth} />
|
||||
<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.description} right={`${p.distance_km}km`} />
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
) : (
|
||||
<StateBox loading={sky.isPending} error={sky.error} empty="이 지역은 아직 등록된 노을 명소가 없어요." />
|
||||
)}
|
||||
<Sec title="전국 노을 순위" sub={items[0] ? `오늘 기준 · 1위 ${items[0].name} ${items[0].score}점` : '오늘 기준'} />
|
||||
{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} />
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<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>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user