Merge branch 'feature/stay-parity'

This commit is contained in:
HyeongBaeYang committed 2026-09-10 16:15:29 +09:00
commit 25f7e5c0c8
25 files changed
+987 -70

No files matched your search

+8 -1
View File
@@ -59,7 +59,14 @@ export function HomePage() {
rooms: UnitsSection,
menu: UnitsSection,
programs: UnitsSection,
booking: BookingSection,
// ★ 숙박은 예약 섹션이 다른 컴포넌트다(요금·인원·창구 + 날짜/시간 목업).
// 같은 섹션 id 가 업종에 따라 다른 것을 그리는 자리는 여기가 유일하다 —
// 이유는 StayBookingSection 머리주석.
// ★ 이 줄이 64ce467 에서 조용히 사라졌다. 그러자 숙박 사이트의 예약 섹션이 전화번호
// 한 줄짜리 BookingSection 으로 돌아갔고, 화면에서 요금이 사라져 **발행이 통째로
// 막혔다** — JSON-LD 의 makesOffer.price 를 화면이 뒷받침하지 못해 절대규칙 3 대조에
// 걸린다(실측 2026-09-10: 발행본 2개 중 2개 실패).
booking: isLodging ? StayBookingSection : BookingSection,
space: SpaceSection,
inquiry: InquirySection,
exhibition: ExhibitionSection,
+129 -49
View File
@@ -1,5 +1,5 @@
import {useEffect, useMemo, useState} from 'react';
import {CalendarDays, Check, Clock, Minus, Phone, Plus, RotateCcw} from 'lucide-react';
import {CalendarDays, Check, ChevronLeft, ChevronRight, Clock, Minus, Phone, Plus, RotateCcw} from 'lucide-react';
import {factText, sanitizeUnits, selectPublishable, type SitePayload} from '@o2o/shared';
import {useSite} from '@site/lib/site-context';
import {unitBaseRate} from '@site/seo/jsonld';
@@ -26,31 +26,52 @@ import {unitBaseRate} from '@site/seo/jsonld';
* 목업이 아니라 거짓말이 된다. 고를 수 없는 날은 **지난 날짜**뿐이고, 그건 사실이다.
*/
/** 달력에 낼 날짜 수. 두 주면 흐름을 보기에 충분하고, 화면도 한 줄에 들어온다. */
const DAY_COUNT = 14;
const WEEKDAY_LABEL = ['일', '월', '화', '수', '목', '금', '토'] as const;
/**
* 고를 수 있는 앞선 달 수. 오늘이 든 달부터 이만큼 앞으로 넘길 수 있다.
*
* ★ 상한을 두는 이유: 우리는 빈 방을 모른다. 반년 뒤를 고르게 두면 손님은 그 날짜가
* 열려 있다고 읽는다 — 모르는 것을 넓게 열어 두는 쪽이 더 나쁜 거짓이다.
*/
const MONTH_SPAN = 2;
interface DayCell {
iso: string;
month: number;
day: number;
weekday: number;
/** 토·일은 주말 요금이 붙는 날이다. 요금 계산의 근거가 화면에도 보여야 한다. */
isWeekend: boolean;
/** 지난 날짜. **고를 수 없는 유일한 사유**다 — '마감' 같은 표시는 만들지 않는다(머리주석). */
past: boolean;
}
function buildDays(from: Date): DayCell[] {
return Array.from({length: DAY_COUNT}, (_, index) => {
const date = new Date(from.getFullYear(), from.getMonth(), from.getDate() + index);
const weekday = date.getDay();
return {
iso: `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`,
month: date.getMonth() + 1,
day: date.getDate(),
weekday,
isWeekend: weekday === 0 || weekday === 6,
};
});
function isoOf(date: Date): string {
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
}
/**
* 한 달치 칸. 1일이 무슨 요일인지에 따라 앞에 빈 칸을 채워 **요일 열을 맞춘다** —
* 달력은 열이 맞아야 달력이고, 어긋나면 그냥 숫자 목록이다.
*/
function buildMonth(year: number, month: number, today: Date): (DayCell | null)[] {
const first = new Date(year, month, 1);
const lastDay = new Date(year, month + 1, 0).getDate();
const todayIso = isoOf(today);
const cells: (DayCell | null)[] = Array.from({length: first.getDay()}, () => null);
for (let day = 1; day <= lastDay; day += 1) {
const date = new Date(year, month, day);
const iso = isoOf(date);
cells.push({
iso,
day,
weekday: date.getDay(),
isWeekend: date.getDay() === 0 || date.getDay() === 6,
past: iso < todayIso,
});
}
return cells;
}
/**
@@ -106,9 +127,22 @@ export function StayBookingDemo() {
);
const slots = useMemo(() => buildArrivalSlots(checkIn), [checkIn]);
/** ★ 서버 렌더에서는 false — 날짜를 HTML 에 굽지 않기 위한 게이트(머리주석). */
const [days, setDays] = useState<DayCell[] | null>(null);
useEffect(() => setDays(buildDays(new Date())), []);
/**
* ★ 서버 렌더에서는 null — 날짜를 HTML 에 굽지 않기 위한 게이트(머리주석).
* '오늘' 을 브라우저에서 정하므로 이 값이 곧 달력의 기준이다.
*/
const [today, setToday] = useState<Date | null>(null);
const [monthOffset, setMonthOffset] = useState(0);
useEffect(() => setToday(new Date()), []);
const cursor = useMemo(
() => (today ? new Date(today.getFullYear(), today.getMonth() + monthOffset, 1) : null),
[today, monthOffset],
);
const cells = useMemo(
() => (today && cursor ? buildMonth(cursor.getFullYear(), cursor.getMonth(), today) : []),
[today, cursor],
);
const [dateIso, setDateIso] = useState<string | null>(null);
const [slot, setSlot] = useState<string | null>(null);
@@ -116,7 +150,7 @@ export function StayBookingDemo() {
const [guests, setGuests] = useState(2);
const [submitted, setSubmitted] = useState(false);
const selectedDay = days?.find((day) => day.iso === dateIso) ?? null;
const selectedDay = cells.find((cell): cell is DayCell => cell !== null && cell.iso === dateIso) ?? null;
const selectedUnit = units.find((unit) => unit.unitId === unitId) ?? null;
const maxGuests = selectedUnit?.maxCapacity ?? 8;
@@ -146,7 +180,7 @@ export function StayBookingDemo() {
</div>
{/* 서버 렌더 · 자바스크립트 꺼짐: 달력 대신 사실만 내보낸다(머리주석). */}
{days === null ? (
{today === null || cursor === null ? (
<p className="px-4 py-6 text-xs leading-relaxed opacity-60 sm:px-5">
날짜 선택은 브라우저에서 열립니다. 실제 예약 가능 여부와 결제는 아래 예약 창구에서
확인해 주세요.
@@ -156,7 +190,7 @@ export function StayBookingDemo() {
payload={payload}
onReset={() => setSubmitted(false)}
summary={[
selectedDay ? `${selectedDay.month}월 ${selectedDay.day}일(${WEEKDAY_LABEL[selectedDay.weekday]})` : null,
selectedDay ? `${cursor.getMonth() + 1}월 ${selectedDay.day}일(${WEEKDAY_LABEL[selectedDay.weekday]})` : null,
slot ? `도착 ${slot}` : null,
selectedUnit?.name ?? null,
`${guests}명`,
@@ -166,34 +200,80 @@ export function StayBookingDemo() {
/>
) : (
<div className="space-y-5 p-4 sm:p-5">
{/* ── 날짜 ─────────────────────────────────────── */}
{/* ── 날짜 (달력) ──────────────────────────────── */}
<div>
<p className="mb-2 text-[11px] font-semibold opacity-55">날짜</p>
<ul className="-mx-1 flex gap-1.5 overflow-x-auto px-1 pb-1">
{days.map((day) => {
const active = day.iso === dateIso;
return (
<li key={day.iso}>
<button
type="button"
onClick={() => setDateIso(day.iso)}
aria-pressed={active}
className="flex w-13 shrink-0 flex-col items-center gap-0.5 rounded-xl border px-2 py-2 text-xs transition-colors"
style={{
borderColor: active ? 'var(--color-brand)' : 'rgba(0,0,0,0.10)',
backgroundColor: active ? 'var(--color-brand)' : 'var(--color-surface-alt)',
color: active ? '#fff' : undefined,
}}
>
<span className="text-[10px] opacity-70">{WEEKDAY_LABEL[day.weekday]}</span>
<span className="font-bold">{day.day}</span>
</button>
</li>
);
})}
</ul>
<div className="mb-2 flex items-center justify-between">
<p className="text-[11px] font-semibold opacity-55">날짜</p>
<div className="flex items-center gap-1">
<button
type="button"
onClick={() => setMonthOffset((n) => Math.max(0, n - 1))}
disabled={monthOffset === 0}
aria-label="이전 달"
className="flex size-7 items-center justify-center rounded-lg border border-black/10 transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-30"
>
<ChevronLeft className="size-3.5" />
</button>
<span className="w-24 text-center text-xs font-bold">
{cursor.getFullYear()}년 {cursor.getMonth() + 1}월
</span>
<button
type="button"
onClick={() => setMonthOffset((n) => Math.min(MONTH_SPAN, n + 1))}
disabled={monthOffset >= MONTH_SPAN}
aria-label="다음 달"
className="flex size-7 items-center justify-center rounded-lg border border-black/10 transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-30"
>
<ChevronRight className="size-3.5" />
</button>
</div>
</div>
{/* 요일 머리. 토·일은 색으로 구분한다 — 주말 요금이 붙는 날이라 정보다. */}
<div className="grid grid-cols-7 gap-1 border-b border-black/8 pb-1.5">
{WEEKDAY_LABEL.map((label, index) => (
<span
key={label}
className="text-center text-[10px] font-semibold"
style={{opacity: index === 0 || index === 6 ? 0.75 : 0.45}}
>
{label}
</span>
))}
</div>
<div className="mt-1.5 grid grid-cols-7 gap-1">
{cells.map((cell, index) =>
cell === null ? (
// 1일 앞의 빈 칸. 요일 열을 맞추는 자리라 버튼이 아니다.
<span key={`pad-${index}`} aria-hidden />
) : (
<button
key={cell.iso}
type="button"
disabled={cell.past}
onClick={() => setDateIso(cell.iso)}
aria-pressed={cell.iso === dateIso}
aria-label={`${cursor.getMonth() + 1}월 ${cell.day}일`}
className="flex h-9 items-center justify-center rounded-lg border text-xs transition-colors disabled:cursor-not-allowed"
style={{
borderColor: cell.iso === dateIso ? 'var(--color-brand)' : 'transparent',
backgroundColor:
cell.iso === dateIso ? 'var(--color-brand)' : 'var(--color-surface-alt)',
color: cell.iso === dateIso ? '#fff' : undefined,
// ★ 지난 날짜만 흐리다. '마감'·'잔여' 는 만들지 않는다 — 우리는 그 값을 모른다.
opacity: cell.past ? 0.25 : 1,
fontWeight: cell.iso === dateIso ? 700 : 400,
}}
>
{cell.day}
</button>
),
)}
</div>
{selectedDay?.isWeekend && (
<p className="mt-1.5 text-[11px] opacity-55">주말 요금이 적용되는 날짜입니다.</p>
<p className="mt-2 text-[11px] opacity-55">주말 요금이 적용되는 날짜입니다.</p>
)}
</div>
@@ -287,7 +367,7 @@ export function StayBookingDemo() {
<div className="flex items-baseline justify-between gap-3">
<span className="text-xs opacity-60">
{selectedDay
? `${selectedDay.month}월 ${selectedDay.day}일 · ${selectedUnit?.name ?? ''} · ${guests}명`
? `${cursor.getMonth() + 1}월 ${selectedDay.day}일 · ${selectedUnit?.name ?? ''} · ${guests}명`
: '날짜를 골라 주세요'}
</span>
{price != null && (
@@ -67,7 +67,7 @@ export function ChronicleSection() {
<h3 className="serif text-base font-bold">{item.title}</h3>
{item.summary && <p className="text-[13px] leading-relaxed opacity-80">{item.summary}</p>}
{item.place && <p className="text-[11px] opacity-60">지금 이 자리 · {item.place}</p>}
<SourceLine source={item.source} verified={item.verified} />
<SourceLine source={item.source} verified={item.verified} imageCredit={item.imageCredit} />
</div>
</div>
</article>
@@ -38,6 +38,7 @@ export function PeopleSection() {
<Rail label="인물 목록" arrows="overlay">
{parsed.items.map((person, index) => (
<article key={`${person.name}-${index}`} className="w-[210px] shrink-0 snap-center">
{/* 사진 출처는 카드 아래 SourceLine 옆에 붙는다(아래) — 라이선스 조건이다. */}
{person.imageUrl ? (
<img
src={person.imageUrl}
@@ -69,7 +70,7 @@ export function PeopleSection() {
</p>
{person.oneLine && <p className="mt-2 text-[13px] leading-relaxed opacity-85">{person.oneLine}</p>}
<div className="mt-2">
<SourceLine source={person.source} verified={person.verified} />
<SourceLine source={person.source} verified={person.verified} imageCredit={person.imageCredit} />
</div>
</article>
))}
@@ -34,10 +34,16 @@ export function PostcardSection() {
alt={`${card.place || card.postmark || '엽서'} 사진`}
loading="lazy"
decoding="async"
className="mb-3.5 block aspect-3/2 w-full border object-cover"
className="block aspect-3/2 w-full border object-cover"
style={{borderColor: ITEM_BORDER}}
/>
)}
{/* 사진 출처. CC BY·공공누리 제1유형이 **요구하는** 표시라 생략할 수 없다. */}
{card.imageUrl && (
<p className="mt-1 mb-3.5 text-[10px] leading-tight opacity-45">
사진 · {card.imageCredit || '출처 표기 없음'}
</p>
)}
<div className="grid grid-cols-[minmax(0,1fr)_auto] gap-3">
{/* 가운데 괘선 — 엽서 뒷면을 반으로 가르는 그 선 */}
<div className="min-w-0 border-r pr-3" style={{borderColor: ITEM_BORDER}}>
+16 -2
View File
@@ -191,10 +191,23 @@ export function Rail({
* 검수는 에디터(빌더 캔버스)에서 계속 보인다 — 고칠 사람은 거기서 본다.
* ★ 출처는 남긴다. 인용될 때 근거를 대는 건 이 사이트의 존재 이유다.
*/
export function SourceLine({source, verified}: {source?: DataSource; verified?: DataVerified}) {
export function SourceLine({
source,
verified,
imageCredit,
}: {
source?: DataSource;
verified?: DataVerified;
/**
* 사진의 출처 표시. **글의 출처와 다른 것**이다 — 사진은 위키미디어(CC BY·BY-SA)나
* 공공누리 제1유형에서 오고, 둘 다 출처 표시가 **라이선스 조건**이다. 생략하면 침해다.
* 그래서 글 출처가 없어도 사진 출처만으로 이 줄이 선다.
*/
imageCredit?: string;
}) {
// verified 는 계약에 남겨 둔다(에디터·게이트가 읽는다). 화면에만 안 낸다.
void verified;
if (!source?.name) return null;
if (!source?.name && !imageCredit) return null;
return (
<p className="flex flex-wrap items-center gap-x-2 gap-y-1 text-[10px] opacity-70">
{source?.name && (
@@ -214,6 +227,7 @@ export function SourceLine({source, verified}: {source?: DataSource; verified?:
)}
</span>
)}
{imageCredit && <span>사진 · {imageCredit}</span>}
</p>
);
}