Files
newsui/packages/docs/app/(docs)/grid-system/page.tsx
T

226 lines
7.0 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-components';
2026-05-20 01:30:49 +08:00
import { Demo } from '@/components/Demo';
import { PropsTable } from '@/components/PropsTable';
export default function GridSystemPage() {
return (
<Layout columns={24} maxWidth="900px" padding="2rem">
<Section columns={24}>
<Article span={24}>
<Headline weight="Medium" as="h1">
</Headline>
<Subhead weight="Medium">
24 Layout Section grid-template-columns
Article grid-column span CSS Grid
</Subhead>
<Headline weight="Low" as="h2">
24
</Headline>
<BodyText>
<p>
24 24
2 / 3 / 4 / 6 / 8 / 12 1/32/31/43/4
</p>
</BodyText>
<div
style={{
display: 'grid',
gridTemplateColumns: 'repeat(24, 1fr)',
gap: '4px',
margin: '1.5rem 0 2rem',
}}
>
{Array.from({ length: 24 }, (_, i) => (
<div
key={i}
style={{
background: 'var(--nui-bg-surface)',
border: '1px solid var(--nui-rule-hairline)',
textAlign: 'center',
padding: '0.5rem 0',
fontFamily: 'var(--font-family-meta)',
fontSize: '11px',
color: 'var(--nui-text-muted)',
letterSpacing: '0.04em',
}}
>
{i + 1}
</div>
))}
</div>
<Headline weight="Low" as="h2">
Layout API
</Headline>
<BodyText>
<p>
<code>Layout</code> LayoutContextSection
useLayout clamp
</p>
</BodyText>
<PropsTable
data={[
{
name: 'columns',
type: 'number',
default: '24',
description: '栅格总列数。决定子 Section 的最大 columns。',
},
{
name: 'maxWidth',
type: 'string',
default: "'1280px'",
description: '页面最大宽度。',
},
{
name: 'padding',
type: 'string',
default: "'var(--nui-space-6)'",
description: '页面内边距。',
},
{
name: 'theme',
type: "'light' | 'dark'",
description:
'强制主题;省略时跟随 documentElement.dataset.theme。',
},
{
name: 'children',
type: 'ReactNode',
required: true,
description: '子内容(通常是若干 Section)。',
},
]}
/>
<Headline weight="Low" as="h2">
Section API
</Headline>
<BodyText>
<p>
<code>Section</code>
<code>display: grid; grid-template-columns: repeat(N, 1fr)</code>
Article grid-column span
</p>
</BodyText>
<PropsTable
data={[
{
name: 'columns',
type: 'number',
required: true,
description: 'Section 内部栅格列数(≤ Layout.columns)。',
},
{
name: 'gap',
type: 'string',
default: "'var(--nui-gutter)'",
description: '栏间间距。',
},
{
name: 'breakable',
type: 'boolean',
default: 'true',
description: '允许打印时跨页断开。',
},
{
name: 'divider',
type: "'none' | 'top' | 'bottom' | 'both'",
default: "'none'",
description: '上下方向的 hairline 分隔线。',
},
]}
/>
<Headline weight="Low" as="h2">
Article API
</Headline>
<BodyText>
<p>
<code>Article</code> Section grid-column span N
span Section
</p>
</BodyText>
<PropsTable
data={[
{
name: 'span',
type: 'number',
description: '跨多少列(0 &lt; span ≤ Section.columns)。',
},
{
name: 'breakable',
type: 'boolean',
default: 'true',
description: '允许打印时跨页断开。',
},
{
name: 'children',
type: 'ReactNode',
required: true,
description: '文章内容。',
},
]}
/>
<Headline weight="Low" as="h2">
</Headline>
<Demo
title="8 + 16 跨栏"
description="左侧短讯 8 列 + 右侧主稿 16 列。"
code={`<Layout columns={24}>
<Section columns={24}>
<Article span={8}>
<Headline weight="Low">短讯</Headline>
<BodyText>...</BodyText>
</Article>
<Article span={16}>
<Headline weight="Medium">主稿</Headline>
<BodyText>...</BodyText>
</Article>
</Section>
</Layout>`}
>
<Layout columns={24} padding="0">
<Section columns={24}>
<Article span={8}>
<Headline weight="Low" as="h3">
</Headline>
<BodyText weight="Low">
<p> 8 </p>
</BodyText>
</Article>
<Article span={16}>
<Headline weight="Medium" as="h3">
稿
</Headline>
<BodyText>
<p>
16 稿
</p>
</BodyText>
</Article>
</Section>
</Layout>
</Demo>
</Article>
</Section>
</Layout>
);
}