Files
newsui/packages/docs/app/(docs)/theme/page.tsx
T

217 lines
6.4 KiB
TypeScript
Raw Normal View History

2026-05-20 01:30:49 +08:00
'use client';
import {
Layout,
Section,
Article,
Headline,
Subhead,
BodyText,
} from 'newspaperui';
2026-05-20 01:30:49 +08:00
import { ThemeToggle } from '@/components/ThemeToggle';
interface Swatch {
token: string;
hex: string;
label?: string;
}
const textSwatches: Swatch[] = [
{ token: '--nui-text-primary', hex: '#1A1A1A', label: '标题、主文本' },
{ token: '--nui-text-body', hex: '#22201C', label: '正文' },
{ token: '--nui-text-secondary', hex: '#4A4742', label: 'Subhead、次级' },
{ token: '--nui-text-muted', hex: '#6E6A63', label: 'Caption、注释' },
{ token: '--nui-text-quote', hex: '#2E2A24', label: 'Quote 主体' },
];
const surfaceSwatches: Swatch[] = [
{ token: '--nui-bg-page', hex: '#F7F4ED', label: 'Warm off-white 页面底' },
{ token: '--nui-bg-surface', hex: '#FBF9F4', label: '次级面板背景' },
{ token: '--nui-rule-hairline', hex: '#C9C2B2', label: '细线分隔' },
{ token: '--nui-rule-decorative', hex: '#1A1A1A', label: '强调线' },
{ token: '--nui-highlight', hex: '#F2E9C8', label: '旧报纸黄' },
];
const accentSwatches: Swatch[] = [
{ token: '--nui-accent-primary', hex: '#7A1F1F', label: 'Brick red, Kicker / Masthead 强调' },
{ token: '--nui-accent-ink-blue', hex: '#1B2A4A', label: 'The Times 蓝' },
{ token: '--nui-highlight', hex: '#F2E9C8', label: '高亮底色' },
];
interface FontFamily {
token: string;
sample: string;
description: string;
}
const families: FontFamily[] = [
{
token: '--font-family-masthead',
sample: 'The Daily Chronicle',
description: 'Cormorant Garamond — 报头',
},
{
token: '--font-family-blackletter',
sample: 'The Daily Chronicle',
description: 'UnifrakturMaguntia — Blackletter preset',
},
{
token: '--font-family-display',
sample: 'A Quiet Revolution',
description: 'Source Serif 4 — Display 大字头条',
},
{
token: '--font-family-headline',
sample: 'Whitehall confirms review',
description: 'Source Serif 4 — Headline / Subhead',
},
{
token: '--font-family-body',
sample: 'In Manchester, regional officials greeted the announcement.',
description: 'Source Serif 4 — 正文',
},
{
token: '--font-family-meta',
sample: 'BY ALICE SMITH · LONDON',
description: 'Inter — small-caps 元信息',
},
];
function SwatchGrid({ swatches }: { swatches: Swatch[] }) {
return (
<div
style={{
display: 'grid',
gridTemplateColumns: 'repeat(auto-fill, minmax(200px, 1fr))',
gap: '0.75rem',
margin: '1rem 0 1.5rem',
}}
>
{swatches.map((s) => (
<div
key={s.token}
style={{ border: '1px solid var(--nui-rule-hairline)', overflow: 'hidden' }}
>
<div style={{ background: s.hex, height: '64px' }} />
<div
style={{
padding: '0.5rem 0.75rem',
fontFamily: 'var(--font-family-meta)',
fontSize: '11px',
background: 'var(--nui-bg-surface)',
}}
>
<code style={{ display: 'block', fontSize: '11px' }}>{s.token}</code>
<div
style={{
color: 'var(--nui-text-muted)',
marginTop: '0.15rem',
letterSpacing: '0.04em',
}}
>
{s.hex}
{s.label ? ` · ${s.label}` : ''}
</div>
</div>
</div>
))}
</div>
);
}
export default function ThemePage() {
return (
<Layout columns={24} maxWidth="900px" padding="2rem">
<Section columns={24}>
<Article span={24}>
<Headline weight="Medium" as="h1">
</Headline>
<Subhead weight="Medium">
+ warm off-white使#000使#FFF
</Subhead>
<Headline weight="Low" as="h2">
</Headline>
<BodyText weight="Low">
<p>
#14110D
</p>
</BodyText>
<div style={{ margin: '1rem 0 2rem' }}>
<ThemeToggle />
</div>
<Headline weight="Low" as="h2">
token
</Headline>
<SwatchGrid swatches={textSwatches} />
<Headline weight="Low" as="h2">
线 token
</Headline>
<SwatchGrid swatches={surfaceSwatches} />
<Headline weight="Low" as="h2">
token
</Headline>
<SwatchGrid swatches={accentSwatches} />
<Headline weight="Low" as="h2">
</Headline>
<BodyText weight="Low">
<p>
Cormorant Garamond Source Serif 4
穿Inter small-caps Blackletter preset
UnifrakturMaguntia
</p>
</BodyText>
<div
style={{
display: 'flex',
flexDirection: 'column',
gap: '1rem',
margin: '1rem 0 2rem',
}}
>
{families.map((f) => (
<div
key={f.token}
style={{
borderTop: '1px solid var(--nui-rule-hairline)',
paddingTop: '0.75rem',
}}
>
<div
className="nui-small-caps"
style={{
fontFamily: 'var(--font-family-meta)',
fontSize: '11px',
color: 'var(--nui-text-muted)',
letterSpacing: '0.08em',
marginBottom: '0.25rem',
}}
>
{f.token} &middot; {f.description}
</div>
<div
style={{
fontFamily: `var(${f.token})`,
fontSize: '32px',
color: 'var(--nui-text-primary)',
lineHeight: 1.1,
}}
>
{f.sample}
</div>
</div>
))}
</div>
</Article>
</Section>
</Layout>
);
}