[feat] solution: 지역 이야기 생성 · 발행본 섹션 손질 · 마이그레이션 주석 축약
- 지역 이야기(가요·인물·연표·엽서·퀴즈) 생성 경로: story_service · grounding/story · section_prompts. 지금까지 만들 자리가 없어 시안에만 손으로 넣은 3만 자였다 - 발행본 섹션: ItinerarySection · Carousel 레일 자동재생(use-rail-autoplay) · Festival · LocalGuide · Weather · Gallery · Header/Footer - 목업 payload 를 payloads-mockup/ 으로 분리 — 발행 대상과 섞이지 않게 - DB 새 구조 후속: site_payload · local_content_crud 조인 정리 · 테스트 - 마이그레이션 주석 축약: 9개 파일 합계 주석 비율 48% → 25%. 실측과 밟은 함정만 남기고 논증은 커밋 메시지로 옮겼다 검증: site·frontend 빌드 통과 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
3910feddfb
commit
328d9e18ee
58 files changed
+5625
-412
No files matched your search
@@ -19,7 +19,7 @@ import type {FestivalEntry} from '@o2o/shared';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {naverSearchUrl} from '@site/lib/format';
|
||||
import {useLiveSeasons} from '@site/lib/use-live-seasons';
|
||||
import {Section} from '@site/lib/ui';
|
||||
import {Carousel, CarouselSlide, Section} from '@site/lib/ui';
|
||||
|
||||
// shared 의 SEASON_ORDER 는 내보내지 않는다. 순서는 달력이 정한 것이라 갈릴 일이 없다.
|
||||
const SEASONS = ['봄', '여름', '가을', '겨울'];
|
||||
@@ -97,7 +97,7 @@ export function FestivalSection() {
|
||||
<h3 className="border-line mb-4 border-b pb-2 text-[length:var(--fs-sm)] font-bold">
|
||||
{season}
|
||||
</h3>
|
||||
<FestivalGrid items={items} />
|
||||
<FestivalRail items={items} label={`${season} 축제`} remount={active} />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
@@ -107,7 +107,7 @@ export function FestivalSection() {
|
||||
<h3 className="border-line mb-4 border-b pb-2 text-[length:var(--fs-sm)] font-bold">
|
||||
계절 없이 열리는 행사
|
||||
</h3>
|
||||
<FestivalGrid items={evergreen} />
|
||||
<FestivalRail items={evergreen} label="계절 없이 열리는 행사" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -116,25 +116,39 @@ export function FestivalSection() {
|
||||
}
|
||||
|
||||
/**
|
||||
* ★ 좁은 화면에서는 **가로줄**, 넓어지면 세로 카드 (2026-09-04, 사장님: "모바일에서 너무 길다")
|
||||
* 실측 390px 에서 이 섹션 하나가 1,274px — 화면 1.7개였다. 큰 사진을 세로로 쌓은 탓이다.
|
||||
* 축제 카드에서 손님이 찾는 건 **언제·어디서** 셋 줄이지 사진이 아니다. 사진은 썸네일로 줄이고
|
||||
* 글을 옆에 붙이면 한 장이 400px 에서 120px 이 된다.
|
||||
* ★ 폭으로 컴포넌트를 갈아 끼우지 않고 CSS 로만 가른다 — 서버 렌더는 화면 폭을 모른다.
|
||||
* ★ 격자에서 **레일**로 바꿨다 (2026-09-09, 사장님: "계절별 축제 카로셀로")
|
||||
* 한 계절에 열 개가 넘으면 격자는 네 줄이 되고, 그 아래 섹션이 화면 밖으로 밀린다.
|
||||
* 레일은 계절이 몇 개든 세로 길이가 한 장으로 고정된다. 자동 넘김은 Carousel 기본값이다.
|
||||
* ★ 접힌 계절 안에 있는 레일은 폭이 0 이다 — embla 가 그 상태로 스냅을 재면 어긋난다.
|
||||
* `remount` 로 활성 탭이 바뀔 때 다시 태운다(LocalGuideSection 의 `key={shown.length}` 와 같은 이유).
|
||||
* ★ 카드 모양을 **주변 안내와 같게** 맞췄다 (2026-09-09, 사장님: "축제만 왜 ui가 달라 주변맛집이랑?")
|
||||
* 격자 시절에는 좁은 화면에서 가로줄(썸네일 왼쪽·글 오른쪽)로 눕혔다 — 세로로 열두 장이
|
||||
* 쌓이니 섹션 하나가 화면 1.7개였기 때문이다(2026-09-04). 레일이 되면서 그 이유가 없어졌다.
|
||||
* 세로 길이는 이미 카드 한 장으로 고정되는데 모양만 옆 섹션과 달라, 같은 페이지에서
|
||||
* 같은 성격의 카드(사진·이름·설명·검색 링크)가 두 벌로 보였다.
|
||||
* 지금은 사진 위 배지 · aspect-4/3 · 슬라이드 폭까지 `LocalGuideSection` 과 같다.
|
||||
*/
|
||||
function FestivalGrid({items}: {items: FestivalEntry[]}) {
|
||||
function FestivalRail({
|
||||
items,
|
||||
label,
|
||||
remount,
|
||||
}: {
|
||||
items: FestivalEntry[];
|
||||
label: string;
|
||||
remount?: string | null;
|
||||
}) {
|
||||
return (
|
||||
<ul className="grid grid-cols-1 gap-2.5 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3 lg:gap-4">
|
||||
<Carousel key={remount ?? 'all'} label={label}>
|
||||
{items.map((festival) => (
|
||||
<li key={festival.name}>
|
||||
<CarouselSlide key={festival.name} basis="basis-[76%] sm:basis-1/3 lg:basis-1/4">
|
||||
<a
|
||||
href={naverSearchUrl(festival.searchQuery)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer nofollow"
|
||||
className="panel group flex h-full overflow-hidden transition-opacity hover:opacity-85 sm:flex-col"
|
||||
className="panel group flex h-full flex-col overflow-hidden transition-opacity hover:opacity-85"
|
||||
>
|
||||
{/* 사진이 없으면 빈 회색 상자 대신 이름 활자 — 주변 안내 카드와 같은 규칙이다. */}
|
||||
<span className="relative block aspect-square w-28 shrink-0 overflow-hidden sm:aspect-4/3 sm:w-auto">
|
||||
<span className="relative block aspect-4/3 overflow-hidden">
|
||||
{festival.imageUrl ? (
|
||||
<img
|
||||
src={festival.imageUrl}
|
||||
@@ -164,7 +178,7 @@ function FestivalGrid({items}: {items: FestivalEntry[]}) {
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span className="flex min-w-0 flex-1 flex-col gap-1 p-3 sm:p-3.5">
|
||||
<span className="flex min-w-0 flex-1 flex-col gap-1 p-3.5">
|
||||
<span className="text-[length:var(--fs-sm)] font-bold">{festival.name}</span>
|
||||
{/*
|
||||
★ <time> 을 걷었다 (2026-09-04, AEO 진단 '미래 날짜 표기')
|
||||
@@ -187,18 +201,18 @@ function FestivalGrid({items}: {items: FestivalEntry[]}) {
|
||||
</span>
|
||||
)}
|
||||
{festival.description && (
|
||||
<span className="text-muted line-clamp-2 pt-0.5 text-[length:var(--fs-xs)] leading-relaxed sm:line-clamp-3">
|
||||
<span className="text-muted line-clamp-3 pt-0.5 text-[length:var(--fs-xs)] leading-relaxed">
|
||||
{festival.description}
|
||||
</span>
|
||||
)}
|
||||
<span className="text-muted mt-auto hidden items-center gap-0.5 pt-1.5 text-[length:var(--fs-xs)] opacity-70 transition-opacity group-hover:opacity-100 sm:flex">
|
||||
<span className="text-muted mt-auto flex items-center gap-0.5 pt-1.5 text-[length:var(--fs-xs)] opacity-70 transition-opacity group-hover:opacity-100">
|
||||
<span>검색으로 열기</span>
|
||||
<ArrowUpRight className="size-3.5" />
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</CarouselSlide>
|
||||
))}
|
||||
</ul>
|
||||
</Carousel>
|
||||
);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import {ChevronLeft, ChevronRight, X} from 'lucide-react';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {galleryImages} from '@site/lib/derive';
|
||||
import {Section} from '@site/lib/ui';
|
||||
import {AUTOPLAY_MS, scrollRailNext, useRailAutoplay} from '@site/lib/ui/use-rail-autoplay';
|
||||
|
||||
/**
|
||||
* 사진 갤러리.
|
||||
@@ -39,6 +40,17 @@ export function GallerySection() {
|
||||
return () => window.removeEventListener('resize', syncTrack);
|
||||
}, [syncTrack]);
|
||||
|
||||
/*
|
||||
* 자동 넘김 — 카드 레일과 같은 정책이다(`useRailAutoplay`).
|
||||
* 넓은 화면에서는 격자라 넘길 데가 없고, 그때 `scrollRailNext` 가 false 를 돌려 스스로 멈춘다.
|
||||
* 사진은 한 장이 화면을 다 채우므로 한 번에 한 장씩 넘긴다(비율 1).
|
||||
*/
|
||||
useRailAutoplay({
|
||||
box: track,
|
||||
interval: AUTOPLAY_MS,
|
||||
advance: () => scrollRailNext(track.current, 1),
|
||||
});
|
||||
|
||||
const nudge = useCallback((dir: -1 | 1) => {
|
||||
const box = track.current;
|
||||
if (!box) return;
|
||||
@@ -96,7 +108,9 @@ export function GallerySection() {
|
||||
<ul
|
||||
ref={track}
|
||||
onScroll={syncTrack}
|
||||
className="flex snap-x snap-mandatory gap-2 overflow-x-auto [scrollbar-width:none] lg:grid lg:grid-cols-4 lg:gap-3 lg:snap-none lg:overflow-visible [&::-webkit-scrollbar]:hidden"
|
||||
/* 사진 모자이크는 12px 한 값이다 — 모바일 8px·데스크톱 12px 로 갈라 두면
|
||||
같은 사진 목록이 폭에 따라 다른 물건처럼 보인다(카드 레일은 16px, Carousel 주석). */
|
||||
className="flex snap-x snap-mandatory gap-3 overflow-x-auto [scrollbar-width:none] lg:grid lg:grid-cols-4 lg:gap-3 lg:snap-none lg:overflow-visible [&::-webkit-scrollbar]:hidden"
|
||||
>
|
||||
{images.map((image, index) => (
|
||||
<li key={image.mediaId} className="w-full shrink-0 snap-center lg:w-auto">
|
||||
|
||||
@@ -167,7 +167,7 @@ function PlaceList({
|
||||
★ 그래도 **문서에서는 지우지 않는다.** 레일 뒤에 접힌 목록으로 남긴다 —
|
||||
검색·AI 는 거리 탭과 무관하게 스물넷을 다 읽어야 한다.
|
||||
*/}
|
||||
<Carousel key={shown.length} label={title} gap={0.75}>
|
||||
<Carousel key={shown.length} label={title}>
|
||||
{shown.map((place) => (
|
||||
<CarouselSlide key={place.name} basis="basis-[76%] sm:basis-1/3 lg:basis-1/4">
|
||||
<a
|
||||
|
||||
@@ -2,7 +2,7 @@ import {ExternalLink, Mail, MapPin, Phone} from 'lucide-react';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {isoDate} from '@site/lib/format';
|
||||
// 채널 이름표는 예약·문의 섹션과 같은 표를 쓴다 — 같은 채널이 자리마다 다른 이름으로 뜨면 안 된다.
|
||||
import {channelLabel} from '@site/lib/derive';
|
||||
import {channelLabel, publicLinks} from '@site/lib/derive';
|
||||
|
||||
/**
|
||||
* 푸터.
|
||||
@@ -15,7 +15,8 @@ export function SiteFooter() {
|
||||
const payload = useSite();
|
||||
const {place, site} = payload;
|
||||
// 확정된 채널만 — 확정 전 URL 은 동명 업소일 수 있다.
|
||||
const links = payload.links.filter((link) => link.confirmed);
|
||||
// ★ sameAs 와 같은 목록이어야 한다 — 화면에 없는 주소가 구조화 데이터에 있으면 발행이 막힌다.
|
||||
const links = publicLinks(payload);
|
||||
const address = place.roadAddress ?? place.address;
|
||||
|
||||
return (
|
||||
|
||||
@@ -27,7 +27,7 @@ export function SiteHeader() {
|
||||
|
||||
return (
|
||||
<header
|
||||
className="border-line sticky top-0 z-40 w-full border-b backdrop-blur-md"
|
||||
className="border-line safe-t sticky top-0 z-40 w-full border-b backdrop-blur-md"
|
||||
style={{backgroundColor: 'color-mix(in srgb, var(--tpl-surface, #fff) 88%, transparent)'}}
|
||||
>
|
||||
<div className="shell flex h-16 items-center justify-between gap-3">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {useLiveWeather} from '@site/lib/use-live-weather';
|
||||
import {weatherMood} from '@site/lib/derive';
|
||||
import {weatherBand, weatherMood} from '@site/lib/derive';
|
||||
import {Card, Section} from '@site/lib/ui';
|
||||
import './weather.css';
|
||||
|
||||
@@ -35,8 +35,17 @@ export function WeatherSection() {
|
||||
if (!weather) return null;
|
||||
|
||||
const mood = weatherMood(weather.condition);
|
||||
const band = weatherBand(weather.temperature);
|
||||
// 조건별 문장이 우선. 없으면 예전 한 칸(note)으로 떨어진다 — 옛 payload 도 깨지지 않는다.
|
||||
const line = payload.local.weather?.notes?.[mood] ?? weather.note;
|
||||
/*
|
||||
* ★ 기온 줄 (2026-09-09, 사장님: "기온에 따라서 문구 다르게, 펜션지역의 관광에 맞춰서")
|
||||
* 하늘 줄은 집 안 이야기(마당·CAFÉ)라 "그래서 오늘 어디를 가지"에는 답하지 않았다.
|
||||
* 34도의 맑음과 3도의 맑음이 같은 문장을 받는 것도 이 때문이었다.
|
||||
* ★ 없으면 줄 자체를 그리지 않는다 — 기온대는 항상 계산되지만 문장은 사장님이 적은
|
||||
* 것뿐이라, 빈 칸을 우리가 채우면 지어낸 관광 안내가 된다.
|
||||
*/
|
||||
const bandLine = payload.local.weather?.tempNotes?.[band];
|
||||
const observed = observedText(weather.observedAt);
|
||||
|
||||
return (
|
||||
@@ -73,6 +82,22 @@ export function WeatherSection() {
|
||||
{line}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/*
|
||||
기온 줄은 하늘 줄 아래에 둔다 — 손님이 먼저 보는 건 "비 오나"이고
|
||||
"그럼 어디 가지"는 그다음이다. 활자를 한 급 낮춰 둘의 순서를 눈에도 보이게 한다.
|
||||
*/}
|
||||
{bandLine && (
|
||||
<p className="measure flex items-start gap-2.5 text-[length:var(--fs-sm)] leading-relaxed opacity-75">
|
||||
<span
|
||||
className="border-line mt-0.5 shrink-0 rounded-full border px-2 py-0.5 text-[length:var(--fs-xs)] font-bold"
|
||||
aria-hidden
|
||||
>
|
||||
{band}
|
||||
</span>
|
||||
<span>{bandLine}</span>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
</Section>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* — FestivalSection 과 같은 규칙이다.
|
||||
* ★ 기본값은 **첫 번째 기간**이다. `useState` 초깃값이라 SSR 과 어긋나지 않는다.
|
||||
*/
|
||||
import {useState} from 'react';
|
||||
import {useCallback, useMemo, useRef, useState} from 'react';
|
||||
import {planDay, type ItineraryItem, type PlannerStop} from '@o2o/shared';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
@@ -61,6 +61,13 @@ function DayCard({
|
||||
const day = planDay({name: item.name, startTime, stops});
|
||||
|
||||
return (
|
||||
/*
|
||||
* ★ 코스 경계에 여백을 더 주지 않는다 (2026-09-09, 사장님: "간격 다 똑같이")
|
||||
* 한때 코스가 바뀌는 카드에 `ml-6 border-l-2` 를 걸어 48px 로 벌렸다. 레일에 코스 셋이
|
||||
* 섞여 있어 경계가 안 보인다고 봤기 때문인데, **코스 줄**(DurationRail)이 레일 위에
|
||||
* 생기면서 그 일을 글자가 대신한다 — 지금 보고 있는 코스에 밑줄이 간다.
|
||||
* 경계 여백이 남으면 같은 레일 안에서 카드 간격이 두 종류가 되고, 그게 더 눈에 걸린다.
|
||||
*/
|
||||
<article
|
||||
className="w4-paper w-[320px] shrink-0 snap-center border"
|
||||
style={{backgroundColor: ITEM_CARD, borderColor: ITEM_BORDER}}
|
||||
@@ -86,9 +93,14 @@ function DayCard({
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5 px-4 pt-3.5">
|
||||
<h4 className="serif text-lg font-bold">{item.name}</h4>
|
||||
{/* ★ audience 는 카드가 아니라 레일 위 제목 옆에 있다 — 날마다 카드가 서므로
|
||||
여기 두면 같은 문구가 이틀·사흘 반복된다. */}
|
||||
{/*
|
||||
★ h3 다 — 레일이 탭마다 하나로 합쳐지면서(2026-09-09) 카드 밖 코스 제목이 없어졌다.
|
||||
카드 안 제목이 그 코스의 유일한 표제가 되므로 단계를 올린다. 여러 날짜리는 같은
|
||||
제목이 날마다 반복되는데, 카드 하나만 인용돼도 무슨 코스인지 읽혀야 해서 그대로 둔다.
|
||||
*/}
|
||||
<h3 className="serif text-lg font-bold">{item.name}</h3>
|
||||
{/* ★ why·audience 는 첫 장만 — 다 채우면 같은 문구가 이틀·사흘 반복된다. */}
|
||||
{first && item.audience && <p className="text-[12px] opacity-60">{item.audience}</p>}
|
||||
{first && item.why && <p className="text-[13px] leading-relaxed opacity-80">{item.why}</p>}
|
||||
</div>
|
||||
|
||||
@@ -99,7 +111,15 @@ function DayCard({
|
||||
<li key={`${planned.stop.name}-${index}`} className="grid grid-cols-[46px_minmax(0,1fr)] gap-2.5">
|
||||
{/* 시각 열 — 왼쪽에 붙어 정렬돼야 '시간표'로 읽힌다. */}
|
||||
<span className="serif pt-2 text-[12px] tabular-nums opacity-75">{planned.time}</span>
|
||||
<div className="border-l pb-2 pl-3" style={{borderColor: ITEM_BORDER}}>
|
||||
{/*
|
||||
★ 정거장 사이를 벌린다 (2026-09-09, 간격 감사)
|
||||
pb-2 였을 때 정거장 사이가 13px 인데 정거장 **안**의 줄간격이 10px 이라,
|
||||
둘이 거의 같아 시간표가 한 덩이 글로 뭉갰다 — 어디까지가 한 정거장인지
|
||||
눈으로 안 갈렸다. 안(10px)보다 뚜렷하게 넓어야 목록으로 읽힌다.
|
||||
★ 사이를 선으로 끊지 않는다. 왼쪽 `border-l` 이 이미 하루를 잇는 세로 레일이라
|
||||
가로 선을 더하면 레일이 토막나고, 시간표가 아니라 표가 된다.
|
||||
*/}
|
||||
<div className="border-l pb-5 pl-3" style={{borderColor: ITEM_BORDER}}>
|
||||
{planned.move > 0 && <p className="pt-1 text-[10px] opacity-50">↓ {planned.move}분 이동</p>}
|
||||
<div className="flex items-start gap-2.5 pt-1">
|
||||
{/* 사진은 있을 때만. 없으면 빈 회색 상자 대신 활자만 선다(이 팩의 규칙). */}
|
||||
@@ -198,38 +218,103 @@ export function ItinerarySection() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/*
|
||||
★ 탭 하나 = 레일 하나 (2026-09-09, 사장님: "추천일정 1열로 만들어서 auto play")
|
||||
예전에는 안(코스)마다 제목 + 레일을 두고 세로로 쌓았다. 한 탭에 안이 셋이면
|
||||
카드 높이가 그대로 세 번 쌓여 이 섹션 하나가 화면 세 개를 먹었다 —
|
||||
손님은 두 번째 안을 보려고 첫 안의 시간표를 다 지나야 했다.
|
||||
★ 접힌 탭은 폭이 0 이라 embla 가 스냅을 잘못 잡는다 → key 로 활성 탭이 바뀔 때 다시 태운다.
|
||||
*/}
|
||||
{tabs.map((tab) => (
|
||||
<div key={tab} hidden={tab !== active} className="space-y-10">
|
||||
{items
|
||||
.filter((item) => (item.duration?.trim() || NO_DURATION) === tab)
|
||||
.map((item, index) => (
|
||||
<div key={`${item.name}-${index}`} className="space-y-3">
|
||||
<div className="space-y-1">
|
||||
{/* 코스 이름에 이미 "1박 2일" 이 들어 있으면 앞에 또 붙이지 않는다. */}
|
||||
<h3 className="serif text-lg font-bold">
|
||||
{item.duration && !item.name.includes(item.duration)
|
||||
? `${item.duration} · ${item.name}`
|
||||
: item.name}
|
||||
</h3>
|
||||
{/* ★ 탭 안에서는 기간이 다 같다 — 안끼리 갈리는 것은 '누구에게 맞나'다. */}
|
||||
{item.audience && <p className="text-[13px] opacity-60">{item.audience}</p>}
|
||||
</div>
|
||||
<Rail label={`${item.name} 일정`}>
|
||||
{daysOf(item).map((day, dayIndex) => (
|
||||
<DayCard
|
||||
key={`${item.name}-${dayIndex}`}
|
||||
item={item}
|
||||
badge={day.label ?? item.duration ?? `${dayIndex + 1}일차`}
|
||||
startTime={day.startTime}
|
||||
stops={day.stops}
|
||||
first={dayIndex === 0}
|
||||
/>
|
||||
))}
|
||||
</Rail>
|
||||
</div>
|
||||
))}
|
||||
<div key={tab} hidden={tab !== active}>
|
||||
<DurationRail
|
||||
key={active}
|
||||
tab={tab}
|
||||
items={items.filter((item) => (item.duration?.trim() || NO_DURATION) === tab)}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</ItemSection>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 기간 탭 하나의 레일 — **코스 줄 + 날짜 카드 한 줄**.
|
||||
*
|
||||
* ★ 왜 코스 줄이 필요한가 (2026-09-09, 사장님: "일렬로 되었으니까 타이틀이 안보이잖아")
|
||||
* 코스마다 레일을 따로 두던 때는 제목이 레일 위에 있어서, 세로로 훑기만 하면
|
||||
* "이 기간에 무슨 코스가 있나"를 알 수 있었다. 한 줄로 합치자 그 목록이 사라졌다 —
|
||||
* 카드 안에 제목이 있어도 **지금 보이는 한 장의 제목**이라 전체 목록이 아니고,
|
||||
* 자동 넘김까지 돌아 처음 본 카드가 둘째 날인 경우도 생긴다(실측).
|
||||
* ★ 그래서 코스 이름을 레일 위에 한 줄로 늘어놓고, 지금 보고 있는 코스를 표시한다.
|
||||
* 누르면 그 코스의 첫날로 레일이 넘어간다 — 목록이자 이동 수단이다.
|
||||
* ★ 기간 탭(강조)과 층을 가른다: 저쪽은 알약 버튼이고 이쪽은 글자다.
|
||||
* 같은 모양으로 두 줄을 세우면 어느 쪽이 상위인지 안 읽힌다.
|
||||
* ★ 코스가 하나면 줄을 그리지 않는다 — 선택지 없는 목록은 장식이다.
|
||||
* ★ `audience`("차 없이 오는 손님")는 카드에만 둔다. 줄에도 적으면 같은 문구가 위아래로
|
||||
* 두 번 나오고, 코스가 하나일 때는 줄이 아예 없어서 그 문구만 사라진다.
|
||||
*/
|
||||
function DurationRail({tab, items}: {tab: string; items: ItineraryItem[]}) {
|
||||
/** 코스별 시작 위치와 길이. 레일 인덱스 ↔ 코스를 잇는 유일한 표다. */
|
||||
const courses = useMemo(() => {
|
||||
let cursor = 0;
|
||||
return items.map((item) => {
|
||||
const start = cursor;
|
||||
cursor += daysOf(item).length;
|
||||
return {item, start};
|
||||
});
|
||||
}, [items]);
|
||||
|
||||
const [slide, setSlide] = useState(0);
|
||||
const api = useRef<{scrollTo: (index: number) => void} | null>(null);
|
||||
const onReady = useCallback((next: {scrollTo: (index: number) => void}) => {
|
||||
api.current = next;
|
||||
}, []);
|
||||
|
||||
// 지금 보이는 장이 속한 코스 — 시작 위치가 그 장보다 앞인 것 중 마지막.
|
||||
const currentStart = courses.reduce(
|
||||
(found, course) => (course.start <= slide ? course.start : found),
|
||||
0,
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{courses.length > 1 && (
|
||||
<ul className="border-line mb-5 flex flex-wrap items-center gap-x-4 gap-y-2 border-b pb-3">
|
||||
{courses.map(({item, start}) => {
|
||||
const on = start === currentStart;
|
||||
return (
|
||||
<li key={`${item.name}-${start}`}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => api.current?.scrollTo(start)}
|
||||
aria-current={on}
|
||||
className={`text-left text-[length:var(--fs-sm)] underline-offset-4 transition-opacity hover:opacity-100 ${
|
||||
on ? 'font-bold underline' : 'opacity-55 hover:underline'
|
||||
}`}
|
||||
>
|
||||
{item.name}
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
<Rail label={`${tab} 일정`} onSelect={setSlide} onReady={onReady}>
|
||||
{courses.flatMap(({item, start}, index) =>
|
||||
daysOf(item).map((day, dayIndex) => (
|
||||
<DayCard
|
||||
key={`${item.name}-${start}-${dayIndex}`}
|
||||
item={item}
|
||||
badge={day.label ?? item.duration ?? `${dayIndex + 1}일차`}
|
||||
startTime={day.startTime}
|
||||
stops={day.stops}
|
||||
first={dayIndex === 0}
|
||||
/>
|
||||
)),
|
||||
)}
|
||||
</Rail>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
youtubePoster,
|
||||
type VideoItem,
|
||||
} from '@o2o/shared';
|
||||
import {AUTOPLAY_MS, scrollRailNext, useRailAutoplay} from '@site/lib/ui/use-rail-autoplay';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
import {ITEM_BORDER, ITEM_CARD, ItemSection, SourceLine} from './common';
|
||||
@@ -69,6 +70,17 @@ export function VideoSection() {
|
||||
box.scrollBy({left: dir * box.clientWidth * 0.85, behavior: still ? 'auto' : 'smooth'});
|
||||
}, []);
|
||||
|
||||
/*
|
||||
* 자동 넘김 — 카드 레일과 **같은 정책**이다(`useRailAutoplay`).
|
||||
* 이 섹션은 embla 를 안 써서 자동 넘김이 없었다(2026-09-09, 사장님: "ado2 카로셀은 auto가 아닌데?").
|
||||
* 넓은 화면에서는 격자라 넘길 데가 없고, 그때는 `scrollRailNext` 가 곧 false 를 돌려 스스로 멈춘다.
|
||||
*/
|
||||
useRailAutoplay({
|
||||
box: scroller,
|
||||
interval: AUTOPLAY_MS,
|
||||
advance: () => scrollRailNext(scroller.current),
|
||||
});
|
||||
|
||||
if (parsed.items.length === 0) return null;
|
||||
|
||||
// 한 편뿐이면 밀 곳이 없다 — 슬라이더로 만들지 않는다.
|
||||
@@ -87,11 +99,17 @@ export function VideoSection() {
|
||||
<ul
|
||||
ref={scroller}
|
||||
onScroll={syncEdges}
|
||||
className={`gap-5 ${
|
||||
/*
|
||||
* ★ 데스크톱에서 카드가 **딱 붙어 있었다** (2026-09-09, 사장님: "간격없이 붙는거 다 수정해")
|
||||
* 클래스가 `gap-5` 와 `gap-3` 두 벌이었고 거기에 `lg:gap-0` 이 얹혀 있었다 —
|
||||
* 실측(1280px): 3열 격자의 카드 간격이 0px 이라 영상 셋이 한 덩이로 보였다.
|
||||
* 간격은 카드 레일 한 값(16px)으로 맞췄다 — Carousel 의 `gap` 주석 참조.
|
||||
*/
|
||||
className={
|
||||
many
|
||||
? 'flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 lg:gap-0 [scrollbar-width:none] lg:grid lg:grid-cols-3 lg:snap-none lg:overflow-visible lg:pb-0 [&::-webkit-scrollbar]:hidden'
|
||||
: 'grid grid-cols-1'
|
||||
}`}
|
||||
? 'flex snap-x snap-mandatory gap-4 overflow-x-auto pb-2 [scrollbar-width:none] lg:grid lg:grid-cols-3 lg:gap-4 lg:snap-none lg:overflow-visible lg:pb-0 [&::-webkit-scrollbar]:hidden'
|
||||
: 'grid grid-cols-1 gap-4'
|
||||
}
|
||||
>
|
||||
{parsed.items.map((item, index) => {
|
||||
const id = youtubeId(item.url);
|
||||
|
||||
@@ -161,6 +161,8 @@ export function Rail({
|
||||
children,
|
||||
label,
|
||||
arrows = 'header',
|
||||
onSelect,
|
||||
onReady,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
label: string;
|
||||
@@ -169,9 +171,12 @@ export function Rail({
|
||||
* 퍼포레이션과 프레임 사이에 버튼 띠가 생겨 필름이 아니라 위젯이 된다.
|
||||
*/
|
||||
arrows?: 'header' | 'overlay';
|
||||
/** 지금 몇 번째 장인지 알아야 하는 레일에만 준다(추천 일정의 코스 줄). Carousel 주석 참조. */
|
||||
onSelect?: (index: number) => void;
|
||||
onReady?: (api: {scrollTo: (index: number) => void}) => void;
|
||||
}) {
|
||||
return (
|
||||
<Carousel label={label} gap={1} arrows={arrows}>
|
||||
<Carousel label={label} gap={1} arrows={arrows} onSelect={onSelect} onReady={onReady}>
|
||||
{children}
|
||||
</Carousel>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user