/** * 섹션 껍데기 — 배리에이션이 절대 다시 만들지 않는 부분. * * 앵커 id(모바일 탭이 스크롤하는 목표), 선택 링, "선택됨" 배지, 배경 톤이 여기 모여 있다. * 배리에이션은 안쪽 내용만 책임진다 — 껍데기가 제각각이면 레이아웃을 바꿀 때마다 * 선택 표시가 사라지거나 앵커가 끊긴다. */ import type {ReactNode} from 'react'; import type {SectionItem} from '@o2o/shared'; import {cn} from '@/lib/utils'; import type {SectionTone} from '../types'; /** * 섹션 배경 톤 → 실제 색. * * 화면 면적의 대부분이 이 네 색이라, 여기가 하드코딩이면 팔레트를 바꿔도 인상이 안 바뀐다. * 그래서 템플릿 토큰(`--tpl-*`)을 읽고, 폴백으로 기존 색을 그대로 둔다 — * ★ 토큰을 안 내려보내는 화면(발행 사이트·썸네일 등)에서는 지금과 픽셀 단위로 동일하다. */ const TONE_BG: Record = { paper: 'var(--tpl-surface, #faf7f2)', // ★ 진짜 흰색으로 남긴다 — surface/surfaceAlt 와 세 단계가 있어야 섹션이 서로 구분된다. white: 'var(--tpl-bg, #ffffff)', tint: 'var(--tpl-surface-alt, #f4f1ec)', dark: 'var(--tpl-inverse, #1c1917)', }; interface SectionFrameProps { section: SectionItem; isSelected: boolean; onSelect: () => void; /** 배경 톤. 위아래 섹션과 다른 톤을 주면 경계선 없이도 구분된다. */ tone?: SectionTone; /** 히어로처럼 자기 여백을 직접 잡는 배리에이션은 false. */ padded?: boolean; className?: string; children: ReactNode; } export function SectionFrame({ section, isSelected, onSelect, tone = 'white', padded = true, className, children, }: SectionFrameProps) { const isDark = tone === 'dark'; return (
{isSelected && ( 선택됨: {section.name} {section.isLocked && ' (필수)'} )} {children}
); } /** 섹션 본문의 표준 폭. 배리에이션마다 폭이 다르면 스크롤할 때 글줄이 출렁인다. */ export function SectionBody({ children, width = 'default', className, }: { children: ReactNode; width?: 'default' | 'wide' | 'narrow'; className?: string; }) { return (
{children}
); }