# AI Agent Prompt: 生产级报纸组件库开发 ## 任务目标 开发一个浏览器端生产级报纸布局组件库,参考 InDesign 与经典严肃风(NYT / The Times)排版传统,组件少而精、职责明确、无冗余、无歧义,支持全局 24 列栅格、跨栏、视觉权重和主题系统,提供文档网站(内嵌 demo,无需 storybook)。 视觉基调:经典严肃风(衬线为主、暖灰系、warm off-white 背景、双线分隔、首字下沉、栏间细线、真实多栏文字流)。 --- ## 1. 项目 setup 与架构 - **Monorepo 管理**(pnpm workspace + Turborepo) - Packages: 1. `components` → Layout / Section / Article / Layer / Masthead / Rule / Headline / Subhead / Kicker / BodyText / Quote / Byline / Dateline / Caption / Image / Figure / Video / PullQuote 2. `theme` → 字体导入、CSS variables、视觉权重映射、Tailwind tokens、排版工具类 3. `docs` → 文档网站(Next.js + Tailwind + MDX) 4. `utils` → 栅格校验(`validateSpan` / `clampSpan`)、`cx` 类名合并 - **目录结构**: ``` /packages /components /src /layout (Layout / Section / Article / Layer / Masthead / Rule) /text (Headline / Subhead / Kicker / BodyText / Quote / Byline / Dateline / Caption) /media (Image / Figure / Video / PullQuote) /theme /src fonts.css (Google Fonts: Cormorant Garamond / Source Serif 4 / Inter / UnifrakturMaguntia) variables.css (CSS variables: 字体 / 暖灰系颜色 / 间距 / 分隔线 / 强调色) typography.css (drop-cap / small-caps / paragraph-flow / OSF / column-rule 等工具类) visual-weights.ts tailwind.config.js /docs /utils ``` - **技术栈**: - React 18+, TypeScript 5+ - TailwindCSS 3+ + 文档站基础 stack - Vitest + React Testing Library - 构建:Vite + Rollup(components/theme/utils);Next.js 14+(docs) --- ## 2. 全局栅格系统 - `` 顶层容器: - `columns`(默认 24)、`maxWidth`、`padding`、`theme`('light' | 'dark') - 通过 React Context 把 columns 下传给 `
` - `
` 内部使用 `display: grid; grid-template-columns: repeat(N, 1fr); gap: var(--nui-gutter)` - Section 内对象通过 `grid-column: span N` 跨栏,统一布局机制 - 响应式:通过 CSS media query / container query 调整(不再使用 JS 路径) --- ## 3. 核心布局组件 1. `
`: - `columns`(必填)、`gap`、`breakable`、`divider`('none' | 'top' | 'bottom' | 'both') - 内部对象 span ≤ Section.columns,超过自动 clamp 并 console.warn 2. `
`: - `span`、`breakable` - 跨栏统一通过 `grid-column: span N` 3. ``: - `position`('absolute' | 'fixed' | 'sticky')、`top/left/right/bottom`、`zIndex` 4. `` 报头组件: - `title`、`kicker`、`edition`、`date`、`price` - `variant`:'classic'(双线居中 + Cormorant Garamond)、'blackletter'(UnifrakturMaguntia 哥特体)、'modern'(左对齐 + accent 色) 5. `` 分隔线组件: - `variant`:'hairline' | 'double' | 'thick' - `orientation`:'horizontal' | 'vertical' - `span`(横向时占多少列,默认 `1 / -1`) --- ## 4. 内容组件 - 文本类:`` / `` / `` / `` / `` / `` / `` / `` - 媒体类:`` / `
` / `