7.5 KiB
7.5 KiB
M15 Typography 交接报告
实施日期:2026-10-22。状态:实施者自测完成,待集成人复核。未提交、未推送、未宣布验收通过。
1. 起点与范围
| 项 | 值 |
|---|---|
| 起始 HEAD | bcadbea(feat: add Checkbox and Radio field families) |
| 工作区起点 | 干净;无未提交修改 |
| 上游基线 | HeroUI 3.2.6 / ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960(../heroui 只读) |
| 范围 | Typography、TypographyHeading、TypographyParagraph、TypographyCode、TypographyProse 及文档 |
本轮实现 M15,按顺序继续 M16 EmptyState、M17 Breadcrumbs;三批共享入口只做必要增量。
2. 上游核对
- 实际导出:
Typography是带Root、Heading、Paragraph、Code、Prose的对象;同时命名导出TypographyRoot、Heading、Paragraph、Code、Prose。 - 实现:
TypographyRoot基于 React Aria ComponentsText,type默认body,映射到p;h1–h6映射到同名标题,code映射到code。默认align="start"、color="default",truncate与weight未指定。 - 子部件:
Heading的level默认1;Paragraph的size默认base,映射body/body-sm/body-xs;Code固定type="code";Prose固定div。 - tv:
typographyVariants提供type(10 项)、align(start/center/end/justify)、color(default/muted)、truncate、weight(normal/medium/semibold/bold),另有proseslot。 - CSS:
packages/styles/components/typography.css的标题、正文、代码、prose 后代元素和修饰类全部按基线数值移植。 - 文档/示例:固定基线有 1 个中文 Typography 页和 6 个示例:
default、typography-scale、primitives、prose、render-props、custom-styles。
3. Vue 实现与 API 对照
Vue 使用独立命名组件,替代 React 的对象子部件:
| 上游 | Vue |
|---|---|
Typography / .Root |
Typography |
Typography.Heading |
TypographyHeading |
Typography.Paragraph |
TypographyParagraph |
Typography.Code |
TypographyCode |
Typography.Prose |
TypographyProse |
render 元素替换 |
as 字符串 |
className / children |
class / 默认插槽 |
| React 属性与事件 | Vue $attrs、原生属性和事件;inheritAttrs: false 显式透传 |
公共属性保持基线名称与默认值:type='body'、align='start'、color='default'、truncate=false,weight 未指定;Heading level=1,Paragraph size='base'。TypographyProse 固定 div,不提供 as,与上游一致。
DOM/类名:根元素 data-slot="typography"、data-type;tv 类为 hv-typography--{type}、--align-*、--color-*、--weight-*、--truncate。TypographyProse 根类为 hv-typography-prose,data-slot="prose"。
4. 变更文件
新增:
packages/styles/components/typography.csspackages/vue/src/components/typography/Typography.vuepackages/vue/src/components/typography/TypographyHeading.vuepackages/vue/src/components/typography/TypographyParagraph.vuepackages/vue/src/components/typography/TypographyCode.vuepackages/vue/src/components/typography/TypographyProse.vueapps/docs/components/typography.mdapps/docs/demos/typography-default.vueapps/docs/demos/typography-typography-scale.vueapps/docs/demos/typography-primitives.vueapps/docs/demos/typography-prose.vueapps/docs/demos/typography-render-props.vueapps/docs/demos/typography-custom-styles.vue
共享增量:
packages/styles/src/index.ts:typographyVariants/TypographyVariantspackages/styles/index.css:Typography CSS 入口packages/vue/src/index.ts、packages/vue/src/types.ts:组件与 Props 导出apps/docs/.vitepress/theme/Layout.vue、apps/docs/components.md:导航与总览tests/typography-empty-breadcrumbs.test.ts:三批共用的行为测试文件(本批含 Typography 用例)tests/ssr.test.ts:三批共用的组合 SSR 用例
5. 验证结果
| 入口 | 文件数 | 通过数 | 含 SSR |
|---|---|---|---|
pnpm test |
17 | 284 | 是(ssr.test.ts 6) |
pnpm test:unit |
16 | 278 | 否 |
pnpm test:ssr |
1 | 6 | 是 |
pnpm typecheck |
— | 通过 | — |
pnpm build:docs |
— | 通过 | — |
pnpm format |
— | 通过 | — |
build:docs 仅有 VitePress chunk >500 kB 提示。新增测试文件 tests/typography-empty-breadcrumbs.test.ts 共 24 项,已加入 test:unit;其中覆盖 Typography 的默认元素映射、五个具名部件、全部变体、as、动态 attrs/class 和 SSR 组合。
浏览器(127.0.0.1:5173,桌面 800×655 与 390×900 同源 iframe,浅色/深色):
- Typography 页 6 个预览、6 张表(类型映射 + 5 个 API 表);桌面表宽 724px,窄屏 350px,
table-layout:fixed、scrollWidth == clientWidth,无水平溢出。 - 浅色计算样式:h1 36/40、h2 30/36、body 16/28、body-sm 14/24、body-xs 12/20、code 14/20;深色颜色切换到主题深色变量。
- 窄屏组件 h1 保持 36px;此前文档全局
h1媒体规则会把预览 h1 压到 28px,已把规则收回.docs-main > h1。 - 预览内
code保持 14px,不被文档正文的 12px 内联代码样式覆盖。
6. 差异与限制
- React 对象子部件访问方式改为独立具名导出;名称加
Typography前缀以避免公共命名冲突,这是 Vue 适配差异。 render函数可由任意 React 元素/组件返回;Vue 仅支持as字符串标签。需要组件级多态时应由调用方使用插槽或包装组件。TypographyProse固定div,与上游一致;没有额外的as。- 未做自动逐像素对比;截图接口返回 “Screenshot needs a visible tab”,本条只有 DOM/计算样式证据。
- 未验证读屏、RTL、触屏、Nuxt 水合和独立安装 dist。
- 未提交、未推送,不能据本报告宣称集成验收通过。
7. 最短复核步骤
git diff -- packages/styles/components/typography.css packages/styles/src/index.ts packages/vue/src/components/typography apps/docs/components/typography.md apps/docs/demos/typography-*.vue- 运行
npx --yes pnpm@11.25.0 typecheck && npx --yes pnpm@11.25.0 test:unit && npx --yes pnpm@11.25.0 test:ssr && npx --yes pnpm@11.25.0 format。 - 打开
http://127.0.0.1:5173/components/typography,核对 6 个示例、6 张表、浅/深色和 390px 宽度;重点检查 h1 36px 与预览 code 14px。 - 复核
render-props示例已明确改写为as,并确认文档没有把 React 对象访问方式写成 Vue API。