`backend` 옆에 `front` 가 있을 이유가 없었다. negosium 의 negodata/front 를 그대로 베꼈고 그게 왜 front 인지는 따져보지 않았다 — 근거 없이 들여온 이름이라 바로잡는다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019uYhHQdssRubirPirrdJJC
107 lines
3.2 KiB
TypeScript
107 lines
3.2 KiB
TypeScript
/**
|
|
* 섹션 껍데기 — 배리에이션이 절대 다시 만들지 않는 부분.
|
|
*
|
|
* 앵커 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<SectionTone, string> = {
|
|
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 (
|
|
<section
|
|
id={`canvas-section-${section.id}`}
|
|
onClick={onSelect}
|
|
className={cn(
|
|
'relative cursor-pointer transition-all',
|
|
padded && 'px-4 py-12 sm:px-6 sm:py-16 md:px-8',
|
|
isSelected
|
|
? 'ring-2 ring-stone-900 ring-offset-2'
|
|
: 'hover:outline-1 hover:outline-dashed hover:outline-stone-300',
|
|
className,
|
|
)}
|
|
style={{backgroundColor: TONE_BG[tone]}}
|
|
>
|
|
{isSelected && (
|
|
<span
|
|
className={cn(
|
|
'z-30 rounded bg-stone-900 px-2 py-0.5 text-[10px] font-semibold text-white',
|
|
padded ? 'mb-4 inline-block' : 'absolute left-3 top-3 shadow-xs',
|
|
isDark && 'bg-white text-stone-900',
|
|
)}
|
|
>
|
|
선택됨: {section.name}
|
|
{section.isLocked && ' (필수)'}
|
|
</span>
|
|
)}
|
|
|
|
{children}
|
|
</section>
|
|
);
|
|
}
|
|
|
|
/** 섹션 본문의 표준 폭. 배리에이션마다 폭이 다르면 스크롤할 때 글줄이 출렁인다. */
|
|
export function SectionBody({
|
|
children,
|
|
width = 'default',
|
|
className,
|
|
}: {
|
|
children: ReactNode;
|
|
width?: 'default' | 'wide' | 'narrow';
|
|
className?: string;
|
|
}) {
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'mx-auto space-y-6',
|
|
width === 'wide' && 'max-w-[1120px]',
|
|
width === 'default' && 'max-w-[880px]',
|
|
width === 'narrow' && 'max-w-[640px]',
|
|
className,
|
|
)}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|