feat: 10/21 회의 반영 — 공유 링크·로그인 없이 댓글·구글 로그인만, 히어로·오늘의 각 좋아요·댓글, 히어로 오늘/내일 스위치, 단풍 지도 65곳·3단계

- 공유: 이미지와 함께 고정 URL을 넘기고 링크도 클립보드에 복사
- 로그인 창은 구글만, 댓글은 로그인 없이 '동네 익명'(링크·전화번호 막기, IP당 하루 20개, 같은 IP만 지우기)
- 히어로·오늘의 각 카드에 좋아요·댓글 (PostType HERO·TODAY_GAK)
- 히어로 오늘/내일 스위치: 내일 구간별 날씨 점수·기온·최저최고·습도·1위 각, /v1/weather/today?day=tomorrow
- 단풍 지도: 단풍 그림 지도, 단풍 전·첫 단풍·절정, 단풍잎·은행잎, 명소 65곳(산림청 예측 + 가까운 지점 날짜)
- 하단 탭 바 불투명 (홈 바 자리로 글이 비치지 않게)
- 사람 글 동네 우선 정렬·내 글 목록, 내 각 '있는 각에서 불러오기'
- 댓글 표 user_id NULL 허용·ip_hash·region_name (운영 DB ALTER 필요)
This commit is contained in:
minaChoi committed 2026-10-21 17:10:29 +09:00
1 parent 14f24d1ab0
commit 93e041bb91
46 files changed
+1820 -337

No files matched your search

+48 -54
View File
@@ -3,54 +3,42 @@ import data from '../../seo/foliage_2026.json'
import { cx } from '../lib/utils'
import { kst } from './lib'
import { PostFrame } from './Post'
import { Ic } from './ui'
type Mountain = { name: string; region: string; lat: number; lon: number; peak: string }
type Stage = 'peak' | 'soon' | 'before' | 'after'
type Kind = 'maple' | 'ginkgo'
type Spot = { name: string; kind: Kind; region: string; lat: number; lon: number; peak: string; basis: string }
type Stage = 'before' | 'first' | 'peak'
// 지도 그림(public/foliage/korea-map.webp, 정사각형)의 위경도 → 그림 위 위치. generated-images/foliage-map/south_outline.json 과 같은 값
const MAP = { lon0: 124.5, lat1: 38.75, k: 0.809017, s: 153.5327, ox: 40, oy: 62.92, size: 1024 }
const PEAK_DAYS = 3 // 절정일 앞뒤 이만큼은 '지금 절정'
const SOON_DAYS = 7
// 발표에 시작일이 없어 절정 FIRST_DAYS 일 전부터 첫 단풍, PEAK_DAYS 일 전부터 절정으로 본다
const FIRST_DAYS = 14
const PEAK_DAYS = 3
const SEASON = { from: '09-20', to: '11-25' }
const SEOUL = { lat: 37.566, lon: 126.978 }
const STAGE: Record<Stage, { label: string; dot: string }> = {
peak: { label: '지금 절정', dot: 'bg-[#ff5a36]' },
soon: { label: '곧 절정', dot: 'bg-[#ffb02e]' },
before: { label: '아직', dot: 'bg-[#7cc47a]' },
after: { label: '절정 지남', dot: 'bg-[#b9a69a]' },
const STAGE: Record<Stage, { label: string; icon: string }> = {
before: { label: '단풍 전', icon: 'size-3 opacity-60 grayscale' },
first: { label: '첫 단풍', icon: 'size-3.5' },
peak: { label: '절정', icon: 'size-[18px]' },
}
const KIND: Record<Kind, { label: string; icon: string }> = {
maple: { label: '단풍', icon: 'maple' },
ginkgo: { label: '은행', icon: 'ginkgo' },
}
const pos = (m: Mountain) => ({
const pos = (m: Spot) => ({
left: `${((MAP.ox + (m.lon - MAP.lon0) * MAP.k * MAP.s) / MAP.size) * 100}%`,
top: `${((MAP.oy + (MAP.lat1 - m.lat) * MAP.s) / MAP.size) * 100}%`,
})
// 점이 붙은 곳은 이름을 점 왼쪽·위·아래로 돌려 겹치지 않게. 없으면 오른쪽
type Side = 'left' | 'right' | 'top' | 'bottom'
const SIDE: Record<string, Side> = {
광덕산: 'left',
설악산: 'top',
금원산: 'top',
두륜산: 'left',
'한라산(1100도로)': 'left',
}
const LABEL_AT: Record<Side, string> = {
right: 'left-full top-1/2 -translate-y-1/2',
left: 'right-full top-1/2 -translate-y-1/2',
top: 'bottom-full left-1/2 -translate-x-1/2',
bottom: 'top-full left-1/2 -translate-x-1/2',
}
const short = (name: string) => name.replace(/\(.*\)$/, '')
const DAY = 86_400_000
const days = (from: string, to: string) => Math.round((Date.parse(to) - Date.parse(from)) / DAY)
function stage(m: Mountain, today: string): Stage {
function stage(m: Spot, today: string): Stage {
const d = days(today, m.peak)
if (Math.abs(d) <= PEAK_DAYS) return 'peak'
if (d < 0) return 'after'
return d <= SOON_DAYS ? 'soon' : 'before'
if (d <= PEAK_DAYS) return 'peak'
return d <= FIRST_DAYS ? 'first' : 'before'
}
const md = (iso: string) => `${Number(iso.slice(5, 7))}/${Number(iso.slice(8, 10))}`
@@ -63,51 +51,57 @@ export function FoliageCard() {
const [picked, setPicked] = useState<string | null>(null)
const mmdd = today.slice(5)
if (mmdd < SEASON.from || mmdd > SEASON.to) return null
const mountains = (data.mountains as unknown as Mountain[]).map((m) => ({ ...m, stage: stage(m, today) }))
const peakNow = mountains.filter((m) => m.stage === 'peak').map((m) => m.name)
// 발표 지도에 서울 안 산은 없어 서울 시청에서 가장 가까운 산으로
const seoul = mountains.reduce((a, b) => (Math.hypot(b.lat - SEOUL.lat, b.lon - SEOUL.lon) < Math.hypot(a.lat - SEOUL.lat, a.lon - SEOUL.lon) ? b : a))
const sel = mountains.find((m) => m.name === picked)
const spots = (data.spots as Spot[]).map((m) => ({ ...m, stage: stage(m, today) }))
const peakNow = spots.filter((m) => m.stage === 'peak').map((m) => m.name)
// 발표 지도에 서울 안 산은 없어 서울 시청에서 가장 가까운 단풍 예측 산으로
const forecast = spots.filter((m) => m.kind === 'maple' && m.basis.startsWith('산림청'))
const seoul = forecast.reduce((a, b) => (Math.hypot(b.lat - SEOUL.lat, b.lon - SEOUL.lon) < Math.hypot(a.lat - SEOUL.lat, a.lon - SEOUL.lon) ? b : a))
const sel = spots.find((m) => m.name === picked)
return (
<PostFrame title="단풍 지도" account="단풍 지도" avatar="maple" caption={peakNow.length ? `지금 절정: ${peakNow.join(' · ')}` : undefined}>
<div className="relative bg-[#e6f2ff] px-4 pt-4 pb-3">
<PostFrame title="단풍 지도" account="단풍 지도" avatar="maple" caption={peakNow.length ? `지금 절정 ${peakNow.length}곳: ${peakNow.slice(0, 5).join(' · ')}${peakNow.length > 5 ? ' 외' : ''}` : undefined}>
<div className="relative bg-[#fff6ea] px-4 pt-4 pb-3">
<p className="m-0 text-[13px] font-extrabold opacity-75">단풍 지도 · {md(today)}</p>
<p className="m-0 mt-1 font-jua text-[24px] leading-tight">서울 근교 {seoul.name} 절정 예상 {md(seoul.peak)}</p>
<div className="relative mx-auto mt-1 aspect-square w-full">
<img src="/foliage/korea-map.webp" alt="한반도 지도" className="absolute inset-0 size-full" />
{mountains.map((m) => (
<img src="/foliage/korea-map.webp" alt="단풍 지도" className="absolute inset-0 size-full" />
{spots.map((m) => (
<button
key={m.name}
type="button"
onClick={() => setPicked(m.name === picked ? null : m.name)}
aria-label={`${m.name} ${STAGE[m.stage].label}, 절정 예상 ${md(m.peak)}`}
className="absolute -translate-x-1/2 -translate-y-1/2 cursor-pointer p-1"
aria-label={`${m.name} ${KIND[m.kind].label} ${STAGE[m.stage].label}, 절정 예상 ${md(m.peak)}`}
className={cx('absolute grid -translate-x-1/2 -translate-y-1/2 cursor-pointer place-items-center p-0.5', m.name === picked && 'z-[2] scale-150')}
style={pos(m)}
>
<i className={cx('block size-3 rounded-full border-2 border-white shadow-[0_1px_4px_rgb(40_48_74/0.35)]', STAGE[m.stage].dot, m.name === picked && 'size-4.5')} />
<span className={cx('absolute py-1 text-[10.5px] leading-none font-extrabold whitespace-nowrap text-(--ink2) [text-shadow:0_0_3px_#fff,0_0_3px_#fff]', LABEL_AT[SIDE[m.name] ?? 'right'])}>
{short(m.name)}
</span>
<Ic name={KIND[m.kind].icon} className={cx('drop-shadow-[0_0_1.5px_#fff] drop-shadow-[0_1px_1px_rgb(40_48_74/0.4)]', STAGE[m.stage].icon)} />
</button>
))}
{sel && (
<p className="absolute right-0 bottom-0 m-0 rounded-[14px] bg-white/90 px-3 py-2 text-[13px] font-bold shadow-[0_4px_12px_rgb(40_48_74/0.15)]">
<p className="absolute right-0 bottom-0 z-[3] m-0 max-w-[75%] rounded-[14px] bg-white/95 px-3 py-2 text-[13px] font-bold shadow-[0_4px_12px_rgb(40_48_74/0.15)]">
<b className="font-jua text-[16px] font-normal">{sel.name}</b> {sel.region}
<br />
{STAGE[sel.stage].label} · 절정 예상 {md(sel.peak)}
{KIND[sel.kind].label} {STAGE[sel.stage].label} · 절정 예상 {md(sel.peak)}
{!sel.basis.startsWith('산림청') && <small className="block text-[11px] font-semibold text-(--ink3)">가까운 예측 지점 날짜예요</small>}
</p>
)}
</div>
<div className="mt-2 flex flex-wrap justify-center gap-x-3 gap-y-1 text-[12.5px] font-bold">
{(Object.keys(STAGE) as Stage[]).map((s) => (
<span key={s} className="flex items-center gap-1">
<i className={cx('size-2.5 rounded-full', STAGE[s].dot)} />
{STAGE[s].label}
<div className="mt-2 flex flex-wrap items-center justify-center gap-x-3 gap-y-1 text-[12.5px] font-bold">
{(Object.keys(KIND) as Kind[]).map((k) => (
<span key={k} className="flex items-center gap-1">
<Ic name={KIND[k].icon} className="size-4" />
{KIND[k].label}
</span>
))}
<span className="opacity-30" aria-hidden="true">|</span>
{(Object.keys(STAGE) as Stage[]).map((st) => (
<span key={st} className="flex items-center gap-1">
<Ic name="maple" className={cx('size-4', STAGE[st].icon)} />
{STAGE[st].label}
</span>
))}
</div>
<p className="m-0 mt-1.5 text-center text-[11px] font-semibold text-(--ink3)">
출처: 산림청 2026 단풍절정 예측 · 단풍나무 잎 절반이 물든 때 기준
출처: 산림청 2026 단풍절정 예측 · 잎 절반이 물든 때를 절정으로, 그 2주 전부터 첫 단풍으로 봐요
</p>
</div>
</PostFrame>