여러 줄 주석이 설명보다 경위(예전·실측·지적)를 적고 있어 읽는 사람이 결론을 찾기 어려웠다. - ts·tsx·js·mjs·css·py 478개: 여러 줄 주석은 첫 문장 한 줄로, 과거형·날짜 문장은 삭제 - 주석 위치는 TypeScript 파서·파이썬 tokenize/ast 로 찾는다 — 문자열 안의 # · /* 는 건드리지 않는다 - eslint·ts·noqa·type: ignore 같은 지시 주석은 그대로 둔다 파이썬 275개 정리 전후 AST 동일, TS 298개 주석 뺀 토큰 동일(빈 JSX 주석 10곳만 차이). site·frontend·admin tsc, site vitest 105 passed Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
87 lines
2.6 KiB
TypeScript
87 lines
2.6 KiB
TypeScript
import type {ReactNode} from 'react';
|
|
import {useLayout, type SectionHeadProps} from '@site/lib/layout';
|
|
|
|
export type SectionTone = 'base' | 'alt' | 'dark';
|
|
|
|
const TONE_STYLE: Record<SectionTone, {backgroundColor: string; color?: string}> = {
|
|
base: {backgroundColor: 'var(--tpl-surface, #ffffff)'},
|
|
alt: {backgroundColor: 'var(--tpl-surface-alt, #f5f5f4)'},
|
|
// 어두운 면 위 글자는 흰색을 박지 않고 템플릿의 밝은 면 색을 쓴다.
|
|
dark: {backgroundColor: 'var(--tpl-inverse, #1c1917)', color: 'var(--tpl-bg, #ffffff)'},
|
|
};
|
|
|
|
export function Section({
|
|
id,
|
|
title,
|
|
lead,
|
|
tone = 'base',
|
|
aside,
|
|
footnote,
|
|
children,
|
|
wide,
|
|
bare,
|
|
}: {
|
|
id: string;
|
|
title: string;
|
|
/** 제목 아래 한 줄. */
|
|
lead?: string;
|
|
tone?: SectionTone;
|
|
/** 제목 줄 오른쪽(넓은 화면에서만 옆에 선다). */
|
|
aside?: ReactNode;
|
|
/** 맨 아래 작은 글씨 — 기준일·출처. */
|
|
footnote?: ReactNode;
|
|
children: ReactNode;
|
|
/** 화면 끝까지 쓰는 섹션은 shell 을 벗는다. */
|
|
wide?: boolean;
|
|
/** 제목 줄을 섹션이 그리지 않는다 — 본문 안(예: 사진 옆 칸)에 두는 편집형 레이아웃용. */
|
|
bare?: boolean;
|
|
}) {
|
|
const Head = useLayout().SectionHead ?? DefaultHead;
|
|
|
|
return (
|
|
<section
|
|
id={id}
|
|
aria-labelledby={`${id}-heading`}
|
|
className="border-line paper w-full border-b"
|
|
style={{...TONE_STYLE[tone], paddingBlock: 'var(--section-space)'}}
|
|
>
|
|
<div className={wide ? 'w-full' : 'shell'}>
|
|
{!bare && (
|
|
<div className={wide ? 'shell' : undefined}>
|
|
<Head id={id} title={title} lead={lead} aside={aside} />
|
|
</div>
|
|
)}
|
|
|
|
{children}
|
|
|
|
{footnote && (
|
|
<p className={`text-muted mt-5 text-[length:var(--fs-xs)] ${wide ? 'shell' : ''}`}>
|
|
{footnote}
|
|
</p>
|
|
)}
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
function DefaultHead({id, title, lead, aside}: SectionHeadProps) {
|
|
return (
|
|
<header className="mb-6 sm:mb-8">
|
|
<div className="flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between sm:gap-6">
|
|
<div className="min-w-0">
|
|
<h2 id={`${id}-heading`} className="h2 flex items-center gap-2.5">
|
|
<i aria-hidden className="h-[1em] w-[3px] shrink-0 bg-current opacity-25" />
|
|
<span className="min-w-0">{title}</span>
|
|
</h2>
|
|
{lead && (
|
|
<p className="text-muted measure mt-2 pl-[calc(3px+0.625rem)] text-[length:var(--fs-sm)]">
|
|
{lead}
|
|
</p>
|
|
)}
|
|
</div>
|
|
{aside && <div className="shrink-0">{aside}</div>}
|
|
</div>
|
|
</header>
|
|
);
|
|
}
|