CLAUDE.md · diff
git:20260608.71d4bc3 to git:20260701.30eb0d6
1 added, 0 removed. Audit A to A.
What this update changes in the checks
No check changed: every fixed check gives the same answer before and after this update.
A tripped check is a label, not a verdict: read the matched text and the lines below. This week's updates that newly trip a check.
# tao-ui 项目指南
## 新组件开发清单
每个新组件必须包含:
1. **组件文件** `src/components/<name>/<name>.tsx` + `<name>.css`
2. **Semantic DOM** — 定义 `<Name>SemanticPart` 类型,props 加 `classNames` / `styles`
3. **导出** — 在 `src/index.tsx` 导出组件、Props 类型、SemanticPart 类型
4. **测试** `tests/<name>/<name>.test.tsx`
5. **Story** `stories/<name>.stories.tsx`,按 antd 分类放 title
6. **Build 验证** — `rslib build` 通过(含 d.ts)
### Semantic DOM 规范
每个组件暴露 `classNames` 和 `styles` prop,按语义部件定制内部 DOM:
```tsx
import { cx, type SemanticClassNames, type SemanticStyles } from '../../utils/semantic';
export type ExampleSemanticPart = 'root' | 'header' | 'body';
export interface ExampleProps {
classNames?: SemanticClassNames<ExampleSemanticPart>;
styles?: SemanticStyles<ExampleSemanticPart>;
className?: string; // 合并到 root
}
// JSX 中应用:
<div className={cx(classNames?.root, className)} style={styles?.root}>
<div className={cx(classNames?.header)} style={styles?.header}>...</div>
</div>
```
规则:
- `className` prop 通过 `cx(classNames?.root, className)` 与 `classNames.root` 合并
- 只暴露用户真正会定制的部件,不要把每个 DOM 节点都暴露
- SemanticPart 类型必须导出,方便消费方使用
- Table 等复杂组件用点号命名:`'header.cell' | 'body.row'`
### Storybook 分类(参考 antd)
| 分类 | 示例组件 |
|------|---------|
| `通用 General/` | Button |
| `布局 Layout/` | Stack, FormLayout |
| `导航 Navigation/` | Tabs, Pagination |
| `数据录入 Data Entry/` | Input, Select, Checkbox, Radio, Switch, DatePicker, Form |
| `数据展示 Data Display/` | Table |
| `反馈 Feedback/` | Drawer |
| `配置 Config/` | TaoProvider |
### 样式规范
- CSS 变量前缀 `--tao-*`,data 属性 `data-tao-*`
- theme.css 和 control.css 在 `src/index.tsx` 顶层统一导入,组件 CSS 不需要 `@import theme`
+ - **不要动 package.json 的 `sideEffects`**——白名单里显式列了 `./dist/index.js` 和 `./src/index.tsx`,让 tree-shaker 保留入口的 CSS 副作用(否则 Storybook/rspack/esbuild 严格模式会悄悄丢掉 theme.css,组件全变透明;已复现过一次)。tree-shaking 按 export 粒度工作,未用到的组件仍会被剪掉,不影响体积。
- 用 data 属性驱动样式,不用 className
- 颜色用 OKLCH + `color-mix()`
- 动画只允许 `opacity`, `transform`, `background-color`, `border-color`, `color`
### TaoProvider 继承
组件通过 `useTaoConfig()` 继承 `size` / `disabled` / `variant`,本地 prop 优先。