diff --git a/frontend/src/b/foliageMap.tsx b/frontend/src/b/foliageMap.tsx index 87bf8bf..050c902 100644 --- a/frontend/src/b/foliageMap.tsx +++ b/frontend/src/b/foliageMap.tsx @@ -14,23 +14,25 @@ const MAP = { lon0: 124.5, lat1: 38.75, k: 0.809017, s: 153.5327, ox: 40, oy: 62 const FIRST_DAYS = 14 const PEAK_DAYS = 3 const PEAK_AFTER = 7 -// 점 반지름(테두리 포함, px)과 점 사이 최소 틈 -const DOT_R: Record = { before: 5.5, first: 6.5, peak: 8, gone: 5.5 } +// 점 반지름(테두리 포함, px)과 점 사이 최소 틈, 지도를 눌렀을 때 가장 가까운 명소를 고르는 거리 +const DOT_R: Record = { before: 2.5, first: 3, peak: 7.5, gone: 2.5 } const GAP = 1.5 +const TAP_R = 22 const STAGE: Record = { before: '단풍 전', first: '첫 단풍', peak: '절정', gone: '' } const KIND: Record = { maple: '단풍', ginkgo: '은행' } +// 절정만 테두리·그림자로 띄우고, 나머지는 테두리 없는 작은 점으로 지도 결에 묻는다 const DOT: Record = { - before: 'size-2 bg-[#b9bcc6]', - first: 'size-2.5 bg-[#f39a3d]', - peak: 'size-[13px] bg-[#e0442e]', - gone: 'size-2 bg-[#b9bcc6]', + before: 'size-[5px] bg-[#8f8a80]/55', + first: 'size-[6px] bg-[#d9772e]/80', + peak: 'size-[13px] border-2 border-white bg-[#e0442e] shadow-[0_1px_3px_rgb(40_48_74/0.35)]', + gone: 'size-[5px] bg-[#8f8a80]/55', } const LEGEND = [ - { label: '단풍 전', color: 'bg-[#b9bcc6]' }, - { label: '첫 단풍', color: 'bg-[#f39a3d]' }, - { label: '절정 단풍', color: 'bg-[#e0442e]' }, - { label: '절정 은행', color: 'bg-[#f2c230]' }, + { label: '단풍 전', dot: DOT.before }, + { label: '첫 단풍', dot: DOT.first }, + { label: '절정 단풍', dot: DOT.peak }, + { label: '절정 은행', dot: cx(DOT.peak, 'bg-[#f2c230]') }, ] const xy = (m: Spot) => [(MAP.ox + (m.lon - MAP.lon0) * MAP.k * MAP.s) / MAP.size, (MAP.oy + (MAP.lat1 - m.lat) * MAP.s) / MAP.size] @@ -145,13 +147,28 @@ export function FoliageCard() { if (days(peaks[0], today) < -FIRST_DAYS || days(peaks[peaks.length - 1], today) > PEAK_AFTER) return null const peakNow = spots.filter((m) => m.stage === 'peak').map((m) => m.name) const sel = spots.find((m) => m.name === picked) + // 작은 점도 손가락으로 고를 수 있게 누른 자리에서 가장 가까운 명소를 연다 + const tapNearest = (e: React.MouseEvent) => { + const r = e.currentTarget.getBoundingClientRect() + const x = e.clientX - r.left + const y = e.clientY - r.top + let best: string | null = null + let bestD = TAP_R + for (const m of spots) { + const [nx, ny] = xy(m) + const p = at[m.name] ?? { x: nx * r.width, y: ny * r.width } + const d = Math.hypot(p.x - x, p.y - y) + if (d < bestD) [best, bestD] = [m.name, d] + } + setPicked(best === picked ? null : best) + } const order = [...spots].sort((a, b) => Number(a.stage === 'peak') - Number(b.stage === 'peak')) return ( 5 ? ' 외' : ''}` : undefined}>

단풍 지도 · {md(today)}

{headline(spots)}

-
+
단풍 지도 {order.map((m) => { const [x, y] = xy(m) @@ -160,13 +177,16 @@ export function FoliageCard() {