Design components
The component collection of a design: headers in component files become pages, a data file for lenses, a Custom Elements Manifest and Storybook stories; checks that the pages are fresh, uses exist, a level uses only levels below, and component CSS has tokens only.
关于该包
这段内容尚未翻译,下面是英文原文。
The components of a design, by level (primitive, composite, block, page), as a collection of pages that is made from the code. The record of a component is the YAML header in the first comment of its file (HTML or TS/TSX; the component header); the action sync turns every header into a page of the collection Components and into three files that other tools read.
What it installs
- The collection Components with its views (by level, all components) and the page the component header.
- The action
place(runs by itself after install and update): adds the kindComponentto the placement map/base/ontology/placement.mdof the packagelayers, so that the layers check passes. - The action
sync(runs by itself after install and update): reads every header under/design/*/components/**and the folders listed insources:of the collection page, and writes/design/components/<id>.md, one page per id, the HTML and the React implementation joined; the text under the page's header is kept;lib/design/components.data.js(window.SB_COMPONENTS), which the lenses read;/design/custom-elements.json, a Custom Elements Manifest;/design/stories/<id>.stories.js, Storybook CSF 3 stories, one story per state.
- Norms and their checks:
- DSC-R01
fresh: the pages and the generated files are whatsyncwrites now. - DSC-R02
uses-exist: every id inusesis a component. - DSC-R03
no-level-up: a component uses only its own level or below; no circles. - DSC-R04
tokens-only: component CSS has no raw colour outside the fallback of avar(). - DSC-R05
health, modewarn: the health of a library in bands (full, missing, fallbacks, extra); it informs and never fails.
- DSC-R01
- The convention A component library (page type
Convention, see Conventions): what a library gives (names from shadcn, paths, the header, states), expects from a style (only contract names), may choose freely, the recipe for making an alternative, and its health. - Lens layout: the contract for interchangeable layouts. The lens shell lists the component slots and lens author API.
- The header parser
lib/header.ts(parseHeader,validateControls), which other packages import to test their own headers:import { parseHeader } from '../../design-components/lib/header.ts'.
Where the boundary is
- The components themselves (markup, CSS, React code) are in the libraries (
shtukbase-ui-html,shtukbase-ui-react); this package only describes and checks them. - The catalog lens that shows the components is in
design-lenses; it readslib/design/components.data.js. - The header of
/design/design.mdselects the style, libraries and layout. Thesyncaction lists their CSS and the selected layout script in the design data. - Virtual records ("items from code", no page files) wait for the engine; the header format does not change when they come.
规范 5
| ID | 规范 | 级别 | 模式 | Enforcer |
|---|---|---|---|---|
| DSC-R01 | The pages in /design/components, the data file, the manifest and the stories are what sync writes from the component headers now. |
MUST | 拦截 | 检查 |
| DSC-R02 | Each id in the uses of a component header is a component with a header or a page. |
MUST | 拦截 | 检查 |
| DSC-R03 | A component uses only components of its own level or below (primitive, composite, block, page), and the uses do not go in a circle. |
MUST | 拦截 | 检查 |
| DSC-R04 | The CSS of a component has no raw colour (hex, rgb, hsl, oklch) outside the fallback of a var(); colours come from the token contract. |
MUST | 拦截 | 检查 |
| DSC-R05 | The health of a component library is reported in bands (full, missing, fallbacks, extra): headers, tokens only and coverage of the shadcn list; a library that is not full is told, never stopped. |
SHOULD | 提醒 | 检查 |
“拦截”:enforcer 会阻止违规;“观察”:只记录违规。MUST 级别表示必须遵守;SHOULD 表示默认应当遵守。
动作 7
| 名称 | 作用 | 文件 | 时机 |
|---|---|---|---|
| place | Add the Component kind to the placement map | actions/place.ts | 安装后 更新后 |
| sync | Resolve components into pages, catalog data, shared CSS, a manifest and stories | actions/sync.ts | 安装后 更新后 |
| fresh | Component pages and generated files are fresh 规范 DSC-R01 | checks/fresh.ts | 检查 |
| uses-exist | Every used component exists 规范 DSC-R02 | checks/uses-exist.ts | 检查 |
| no-level-up | A component does not use a component of a higher level 规范 DSC-R03 | checks/no-level-up.ts | 检查 |
| tokens-only | Component CSS has tokens only 规范 DSC-R04 | checks/tokens-only.ts | 检查 |
| health | Component library health, including override contract warnings (--lib) 规范 DSC-R05 | checks/health.ts | 检查 |
shtuk check 运行检查;shtuk run design-components <名称> 运行任意动作。“安装后”动作只有在包来自可信来源时才会自动运行。
页面 10
这些页面会放到项目中的以下路径。
- /design/
- The component header 页面
- Components 集合
- /design/conventions/
- A component library Convention
- Lens layout Convention
- The lens shell 页面
- /norms/rules/design-components/
- Component pages and generated files are fresh DSC-R01
- Every used component exists DSC-R02
- A component does not use a component of a higher level DSC-R03
- Component CSS has tokens only DSC-R04
- A component library reports its health DSC-R05
包文件 20
它们会放到 .shtukbase/packages/design-components/,动作从那里运行。