agentcss 0.11.3 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/01-tokens/README.md +2 -2
- package/01-tokens/focus-ring.css +1 -1
- package/01-tokens/tokens.css +1 -1
- package/03-patterns/nav/README.md +1 -1
- package/03-patterns/pagination/pagination.css +2 -2
- package/03-patterns/reveal/README.md +3 -3
- package/04-recipes/analysis-report/demo.html +2 -2
- package/04-recipes/longform/README.md +1 -1
- package/04-recipes/longform/longform.html +6 -10
- package/04-recipes/report/demo.html +1 -1
- package/04-recipes/table/demo.html +1 -1
- package/04-recipes/table/table.css +1 -1
- package/04-recipes/tierA-tokens.css +1 -1
- package/09-assets/README.md +1 -1
- package/09-assets/bar/README.md +1 -3
- package/09-assets/bar/bar.css +2 -2
- package/09-assets/bar/bar.js +6 -6
- package/09-assets/bar/demo.html +2 -2
- package/09-assets/echarts-adapter/echarts-adapter.js +8 -8
- package/09-assets/model-viewer/model-viewer.css +2 -2
- package/09-assets/scientific-plot/scientific-plot.js +1 -1
- package/CHANGELOG.md +107 -48
- package/CONTRIBUTING.md +1 -1
- package/README.md +158 -369
- package/README.zh-CN.md +508 -0
- package/SUPPORT.md +2 -2
- package/ai/START-HERE.md +1 -1
- package/ai/components.json +2 -2
- package/ai/components.meta.json +1 -1
- package/ai/tokens.json +1 -1
- package/dist/09-assets/bar/bar.js +1 -1
- package/dist/09-assets/echarts-adapter/echarts-adapter.js +1 -1
- package/dist/09-assets/scientific-plot/scientific-plot.js +1 -1
- package/dist/COSTS.md +9 -9
- package/docs/INVARIANT.md +1 -1
- package/index.html +78 -62
- package/package.json +3 -3
- package/ERRORS.md +0 -1658
- package/docs/BACKLOG.md +0 -127
- package/docs/BENCHMARK.md +0 -252
- package/docs/GUIDANCE.md +0 -154
- package/docs/RELEASING.md +0 -311
- package/docs/RFC-THEME-SCOPE.md +0 -141
- package/docs/ROADMAP.md +0 -182
package/README.md
CHANGED
|
@@ -1,139 +1,78 @@
|
|
|
1
|
-
#
|
|
1
|
+
# agentcss
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Mobile-web components in plain CSS, with optional behaviour scripts. **Zero third-party runtime dependencies** — installing it adds nothing to your `node_modules` that ships to the browser.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
> 仓库名沿用 `frontend-lib`。两者不是一回事:包名是安装标识,仓库名是主页地址。
|
|
5
|
+
[中文说明](README.zh-CN.md)
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install agentcss
|
|
9
|
+
```
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
The npm package is `agentcss`; the repository is `frontend-lib`. They are different things: the package name is what you install, the repository name is where the source lives.
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
## Docs and live demos
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
- **Every demo page, one index** — https://owain323.github.io/frontend-lib/
|
|
16
|
+
- **Component documentation with search** — https://owain323.github.io/frontend-lib/guide/
|
|
17
|
+
|
|
18
|
+
Both are generated from `ai/components.json` and the per-component `README.md`
|
|
19
|
+
files, so a page cannot quietly go missing from the index when a component is
|
|
20
|
+
added. The docs pages resolve every link to a file that actually exists.
|
|
21
|
+
|
|
22
|
+
---
|
|
19
23
|
|
|
20
|
-
##
|
|
24
|
+
## What it solves
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
(`date-range` 是轻量的起止日期选择,不是完整的日历 / 日期选择器;
|
|
24
|
-
完整的 date-picker 请用专门的库)
|
|
25
|
-
- ❌ **不是构建工具** —— 不需要打包器,复制文件就能用
|
|
26
|
-
- ❌ **不是零依赖的 JS 框架** —— 交互组件是**可选**的,纯样式场景不用加载任何 JS
|
|
26
|
+
Three things that get rewritten in every mobile web project:
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
1. **Dark mode** normally costs a second set of colour values. Here one token set adapts, and a container can carry its own theme.
|
|
29
|
+
2. **Overlay behaviour** — close on Escape, return focus to the trigger, close on outside click — is written once as a shared core instead of copied per project.
|
|
30
|
+
3. **Accessibility** (focus rings, screen-reader labels, contrast) is easy to miss. Every component here is held to a written contract.
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
It is also **readable by machines**: `ai/components.json` carries a machine-parseable contract per component — class names, how state is expressed, which behaviours must not be skipped, how mature it is. A person can copy the CSS; a tool can read the contract instead of guessing.
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
- 本库不覆盖你的场景时,**直接用别的做法** —— 不要为了迁就本库而把任务做坏。
|
|
34
|
-
- 改一个**已有网站**时,先看它原有的框架、组件和样式体系,能沿用就沿用;
|
|
35
|
-
本库只在你确实缺一块时补上去。
|
|
36
|
-
- 输出形态不是网页(PPT / 文档 / 邮件)时,本库的网页布局规则**不适用**。
|
|
34
|
+
## What it is not
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
- **Not a UI kit.** No calendar, no file upload, no all-in-one widget set. `date-range` is a light start/end picker, not a full date picker.
|
|
37
|
+
- **Not a build tool.** No bundler required. Copy files and it works.
|
|
38
|
+
- **Not a JS framework.** Interaction scripts are optional; a styles-only page loads no JavaScript at all.
|
|
40
39
|
|
|
41
|
-
##
|
|
40
|
+
## Use it selectively
|
|
41
|
+
|
|
42
|
+
This is an optional toolbox, not a spec every page must obey.
|
|
43
|
+
|
|
44
|
+
- Pick components by reading the actual implementation, the demo, and the stated use case — not by the component name or maturity field.
|
|
45
|
+
- When a component does not cover your case, use something else. Do not damage the task to fit the library.
|
|
46
|
+
- Adding it to an existing site: keep that site's existing framework and styles where they work, and fill only the gap you actually have.
|
|
47
|
+
- When the output is not a web page (slides, documents, email), the layout rules here do not apply.
|
|
48
|
+
|
|
49
|
+
`ai/START-HERE.md` is the short entry point for tools (~90 lines); `START-HERE.md` at the repository root is the three-step checklist for people.
|
|
50
|
+
|
|
51
|
+
---
|
|
42
52
|
|
|
43
|
-
|
|
53
|
+
## Install
|
|
44
54
|
|
|
45
55
|
```bash
|
|
46
56
|
npm install agentcss
|
|
47
57
|
```
|
|
48
58
|
|
|
49
|
-
|
|
59
|
+
The directory it installs as is `agentcss`, and `dist-tags.latest` points at the current version.
|
|
50
60
|
|
|
51
|
-
|
|
61
|
+
Two more paths that resolve to the same content:
|
|
52
62
|
|
|
53
63
|
```bash
|
|
54
|
-
#
|
|
64
|
+
# Pin an exact version and get a tarball byte-identical to the published one
|
|
55
65
|
npm install https://github.com/owain323/frontend-lib/releases/download/v0.11.3/agentcss-0.11.3.tgz
|
|
56
66
|
|
|
57
|
-
#
|
|
67
|
+
# Track master (unreleased commits)
|
|
58
68
|
npm install github:owain323/frontend-lib
|
|
59
69
|
```
|
|
60
70
|
|
|
61
|
-
> 历史说明:0.9.0 曾发布成功、两分钟后被误删(`ERRORS.md` E55);此后一段时间
|
|
62
|
-
> registry 上没有可安装版本,靠 GitHub Release 附件分发(`docs/RELEASING.md`
|
|
63
|
-
> 「发布受阻时」)。自 0.11.2 起这条通路已恢复。
|
|
64
|
-
|
|
65
|
-
**② 源码复制**(不想装依赖):把 `01-tokens/` 和需要的组件目录复制进你的项目。
|
|
66
|
-
⚠️ 复制 `dist/` 里的版本,**别复制源码版** —— 源码版有一半以上是给人和 AI 读的注释
|
|
67
|
-
(理由见下面「体积」一节)。
|
|
68
|
-
|
|
69
|
-
> 为什么这里不提前写 `npm install agentcss`:
|
|
70
|
-
> 写了而 registry 上还没有,照做的人会拿到 404,然后以为是自己的环境问题 ——
|
|
71
|
-
> 这与本库曾经踩过的「README 教人装、装到的是别人 2017 年的包」是同一类坑。
|
|
72
|
-
> 发布成功之后这一行才会换上。
|
|
73
|
-
|
|
74
|
-
## 组件一览
|
|
75
|
-
|
|
76
|
-
共 **35** 个(stable 31 / beta 4)。每个组件目录下有 `README.md`(为什么这么做)和 `demo.html`(能直接抄的结构)。
|
|
77
|
-
|
|
78
|
-
### primitives · 基础件(13)
|
|
79
|
-
|
|
80
|
-
| 组件 | 根类名 | 用途 |
|
|
81
|
-
|---|---|---|
|
|
82
|
-
| `badge` | `badge` | 状态标签:计数、分类、结果标记 |
|
|
83
|
-
| `button` | `btn` | 动作触发:主/次/危险/纯文字四档 |
|
|
84
|
-
| `card` | `card` | 内容容器:媒体+正文+操作区三段 |
|
|
85
|
-
| `choice` | `choice` | 单选/多选/原生 select 外观的统一控件 |
|
|
86
|
-
| `combobox` | `combo` | 可搜索 + 可多选标签的输入控件 |
|
|
87
|
-
| `date-range` | `drange` | 日期区间选择,含预设快捷范围 |
|
|
88
|
-
| `input` | `field` | 文本输入及其标签/帮助/错误三件套 |
|
|
89
|
-
| `popover` | `popover` | 锚定到触发元素的浮层 |
|
|
90
|
-
| `progress` | `progress` | 进度条与进度环 |
|
|
91
|
-
| `select` | `select` | 自定义下拉选择(非原生) |
|
|
92
|
-
| `separator` | `separator` | 分隔线,可带中间文字 |
|
|
93
|
-
| `skeleton` | `skeleton` | 加载占位骨架 |
|
|
94
|
-
| `switch` | `switch` | 开关切换 |
|
|
95
|
-
|
|
96
|
-
### patterns · 组合模式(14)
|
|
97
|
-
|
|
98
|
-
| 组件 | 根类名 | 用途 |
|
|
99
|
-
|---|---|---|
|
|
100
|
-
| `accordion` | `accordion` | 可折叠分组 |
|
|
101
|
-
| `content` | `prose` | 长文排版容器(标题/段落/列表/引用/代码) |
|
|
102
|
-
| `drawer` | `drawer` | 侧边抽屉,含遮罩 |
|
|
103
|
-
| `dropdown` | `dd` | 下拉菜单 |
|
|
104
|
-
| `form-validation` | `form` | 表单校验反馈与错误汇总 |
|
|
105
|
-
| `list` | `list` | 键值列表/条目列表 |
|
|
106
|
-
| `nav` | `nav` | 顶部导航与目录 |
|
|
107
|
-
| `overlay` | `toast` | 吐司提示与模态遮罩 |
|
|
108
|
-
| `pagination` | `pagination` | 分页控件 |
|
|
109
|
-
| `reveal` | `reveal` | 入场动效:一个 `data-reveal` 属性管六个方向,**零 JS 也能看** |
|
|
110
|
-
| `states` | `state` | 空/加载/错误/成功四种整块状态 |
|
|
111
|
-
| `tabs` | `tabs` | 选项卡切换 |
|
|
112
|
-
| `tooltip` | `tooltip` | 悬停/聚焦提示 |
|
|
113
|
-
| `tree` | `tree` | 可展开树形结构 |
|
|
114
|
-
|
|
115
|
-
### recipes · 整页配方(4)
|
|
116
|
-
|
|
117
|
-
| 组件 | 根类名 | 用途 |
|
|
118
|
-
|---|---|---|
|
|
119
|
-
| `analysis-report` | `report` | 组合型研究报告页面:正文与辅助栏并排,窄屏自然退回单栏 |
|
|
120
|
-
| `detail-page` | `detail-page` | 实体详情页骨架:字段齐全 / 部分缺失 / 一条数据都没有,三态共用同一套 DOM |
|
|
121
|
-
| `report` | `rep` | 报告版式系统 v1:共享基础 + 三套版式(杂志/科研技术/金融研究),只换一个 … |
|
|
122
|
-
| `table` | `table` | 数据表格:排序/加载/空/错误四态;三种用途预设(财务/学术/统计) |
|
|
123
|
-
|
|
124
|
-
### assets · 可视化(4)
|
|
125
|
-
|
|
126
|
-
| 组件 | 根类名 | 用途 |
|
|
127
|
-
|---|---|---|
|
|
128
|
-
| `bar` | `bar` | 柱状图(charter 13 图表规范):堆叠/分组两种语义、超量程裁剪、图例 |
|
|
129
|
-
| `model-viewer` | `mv` | 3D 模型查看器:令牌驱动样式,不含渲染库本体 |
|
|
130
|
-
| `scientific-plot` | `splot` | 二维科学绘图:折线/区间带/对数轴,纯令牌驱动、零依赖 |
|
|
131
|
-
| `sparkline` | `sparkline` | 迷你趋势图:无坐标轴、纯形状,适合表格内嵌的一行走势 |
|
|
132
71
|
---
|
|
133
72
|
|
|
134
|
-
##
|
|
73
|
+
## Usage
|
|
135
74
|
|
|
136
|
-
**1 ·
|
|
75
|
+
**1 · Bring in the styles** (with your bundler)
|
|
137
76
|
|
|
138
77
|
```js
|
|
139
78
|
import 'agentcss/tokens.css';
|
|
@@ -141,53 +80,48 @@ import 'agentcss/typography.css';
|
|
|
141
80
|
import 'agentcss/primitives/button/button.css';
|
|
142
81
|
```
|
|
143
82
|
|
|
144
|
-
**2 ·
|
|
83
|
+
**2 · For interactive components, load the behaviour script**
|
|
145
84
|
|
|
146
|
-
|
|
85
|
+
Behaviour scripts are IIFEs that attach to `window` (e.g. `window.Overlay`).
|
|
147
86
|
|
|
148
|
-
|
|
87
|
+
With a bundler:
|
|
149
88
|
|
|
150
89
|
```js
|
|
151
90
|
import 'agentcss/patterns/overlay/overlay.js';
|
|
152
91
|
```
|
|
153
92
|
|
|
154
|
-
|
|
93
|
+
With a `<script>` tag — note the path is the real directory inside the package:
|
|
155
94
|
|
|
156
95
|
```html
|
|
157
|
-
<!-- npm
|
|
96
|
+
<!-- npm does not create a patterns/ directory; use 03-patterns/ -->
|
|
158
97
|
<script src="node_modules/agentcss/03-patterns/overlay/overlay.js"></script>
|
|
159
98
|
```
|
|
160
99
|
|
|
161
|
-
|
|
162
|
-
`04-recipes` `09-assets`。上例等价于 `import 'agentcss/patterns/overlay/overlay.js'`。
|
|
100
|
+
The directory layout inside the package matches the repository: `01-tokens` `02-primitives` `03-patterns` `04-recipes` `09-assets`. The line above is equivalent to `import 'agentcss/patterns/overlay/overlay.js'`.
|
|
163
101
|
|
|
164
|
-
**3 ·
|
|
102
|
+
**3 · Copy the files** (if you would rather not add a dependency)
|
|
165
103
|
|
|
166
|
-
|
|
167
|
-
拷过去不会有大段注释挡着。想读取舍理由再回源码目录看。
|
|
104
|
+
Copy the matching files out of `dist/`. That tree has comments stripped but formatting kept, so a copied file does not arrive buried under prose. Read the source directory when you want the reasoning.
|
|
168
105
|
|
|
169
106
|
```
|
|
170
|
-
dist/01-tokens/tokens.css
|
|
171
|
-
01-tokens/tokens.css
|
|
107
|
+
dist/01-tokens/tokens.css <- copy this
|
|
108
|
+
01-tokens/tokens.css <- source (with comments), for reading
|
|
172
109
|
```
|
|
173
110
|
|
|
174
|
-
-
|
|
175
|
-
|
|
176
|
-
- **JS 也拷 `dist/`**:那一份去了注释但没压缩(理由见「体积」一节)。
|
|
111
|
+
- Do not copy the source directory unless you intend to read it: the majority of the bytes in the CSS source tree are comments.
|
|
112
|
+
- Copy JS from `dist/` too — that copy has comments stripped and is deliberately unminified.
|
|
177
113
|
|
|
178
|
-
|
|
114
|
+
### Smallest working page (plain HTML, no bundler)
|
|
179
115
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
把下面整段存成 `index.html`,放在 `node_modules/` 同级目录,双击打开就是对的:
|
|
116
|
+
Save this as `index.html` next to your `node_modules/` directory and open it directly:
|
|
183
117
|
|
|
184
118
|
```html
|
|
185
119
|
<!doctype html>
|
|
186
|
-
<html lang="
|
|
120
|
+
<html lang="en">
|
|
187
121
|
<head>
|
|
188
122
|
<meta charset="utf-8">
|
|
189
123
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
190
|
-
<title
|
|
124
|
+
<title>Example</title>
|
|
191
125
|
<link rel="stylesheet" href="node_modules/agentcss/dist/01-tokens/tokens.css">
|
|
192
126
|
<link rel="stylesheet" href="node_modules/agentcss/dist/01-tokens/typography.css">
|
|
193
127
|
<link rel="stylesheet" href="node_modules/agentcss/dist/01-tokens/page.css">
|
|
@@ -199,300 +133,155 @@ dist/01-tokens/tokens.css ← 拷这个
|
|
|
199
133
|
<body class="page">
|
|
200
134
|
<main class="wrap">
|
|
201
135
|
|
|
202
|
-
<h1
|
|
203
|
-
<p class="lede"
|
|
136
|
+
<h1>My orders</h1>
|
|
137
|
+
<p class="lede">Last 30 days · 1 order</p>
|
|
204
138
|
|
|
205
139
|
<div class="card card--interactive">
|
|
206
140
|
<div class="card__body">
|
|
207
|
-
<h3
|
|
208
|
-
<p class="small"
|
|
209
|
-
<span class="badge badge--success"
|
|
141
|
+
<h3>Quarterly report</h3>
|
|
142
|
+
<p class="small">Order 20261017001</p>
|
|
143
|
+
<span class="badge badge--success">Filed</span>
|
|
210
144
|
</div>
|
|
211
145
|
</div>
|
|
212
146
|
|
|
213
147
|
<div class="field">
|
|
214
|
-
<label class="field__label" for="q"
|
|
215
|
-
<input class="field__input" id="q" type="search" placeholder="
|
|
216
|
-
<span class="field__hint"
|
|
148
|
+
<label class="field__label" for="q">Order number</label>
|
|
149
|
+
<input class="field__input" id="q" type="search" placeholder="Enter an order number" inputmode="numeric">
|
|
150
|
+
<span class="field__hint">Last four digits are enough</span>
|
|
217
151
|
</div>
|
|
218
152
|
|
|
219
|
-
<button class="btn btn--md btn--primary"
|
|
153
|
+
<button class="btn btn--md btn--primary">Export</button>
|
|
220
154
|
|
|
221
155
|
</main>
|
|
222
156
|
</body>
|
|
223
157
|
</html>
|
|
224
158
|
```
|
|
225
159
|
|
|
226
|
-
|
|
160
|
+
Three mistakes the template above already avoids:
|
|
227
161
|
|
|
228
|
-
|
|
|
162
|
+
| If you write it this way | What happens |
|
|
229
163
|
|---|---|
|
|
230
|
-
| `<input class="input">` | **`.input`
|
|
231
|
-
|
|
|
232
|
-
|
|
|
164
|
+
| `<input class="input">` | **`.input` does not exist.** No error, no warning — the field renders 21px tall |
|
|
165
|
+
| Content placed directly in `.card` | `.card` has `padding: 0`; text sits flush against the edge |
|
|
166
|
+
| Leaving out `page.css` | `.wrap` and `.lede` do nothing and the page width is unconstrained |
|
|
233
167
|
|
|
234
|
-
|
|
235
|
-
把上面 7 个 `href` 的前缀换掉。`node_modules` 不会随部署上线。
|
|
168
|
+
**Going to production:** copy all of `node_modules/agentcss/dist/` into a static directory (say `vendor/agentcss/`) and rewrite the seven `href` prefixes above. `node_modules` does not get deployed.
|
|
236
169
|
|
|
237
170
|
---
|
|
238
171
|
|
|
239
|
-
##
|
|
240
|
-
|
|
241
|
-
源码目录(`01-tokens/` `02-primitives/` …)里的 CSS **带着全部注释** —— 实测全库 CSS
|
|
242
|
-
有 **66% 是注释**(354.7 KB 原始里 235.2 KB),`page.css` 单个就有 87%。
|
|
172
|
+
## Components
|
|
243
173
|
|
|
244
|
-
|
|
245
|
-
**注释让你看代码时处处撞墙,构建工具还会把 66% 的字节原样传下去。**
|
|
174
|
+
**35** components (31 stable / 4 beta). Each directory holds a `README.md` (why it is built this way) and a `demo.html` (markup you can copy).
|
|
246
175
|
|
|
247
|
-
|
|
248
|
-
源码版放在 `agentcss/src/*`:
|
|
176
|
+
### primitives (13)
|
|
249
177
|
|
|
250
|
-
|
|
|
178
|
+
| Component | Root class | Purpose |
|
|
251
179
|
|---|---|---|
|
|
252
|
-
| `
|
|
253
|
-
| `
|
|
254
|
-
| `
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
|
180
|
+
| `badge` | `badge` | Status label: counts, categories, outcome markers |
|
|
181
|
+
| `button` | `btn` | Action trigger: primary / secondary / danger / text-only |
|
|
182
|
+
| `card` | `card` | Content container: media, body, actions |
|
|
183
|
+
| `choice` | `choice` | One control for radio, checkbox and native-select appearance |
|
|
184
|
+
| `combobox` | `combo` | Searchable input that can hold multiple tags |
|
|
185
|
+
| `date-range` | `drange` | Start/end date range with preset shortcuts |
|
|
186
|
+
| `input` | `field` | Text field plus its label, hint and error |
|
|
187
|
+
| `popover` | `popover` | Floating panel anchored to its trigger |
|
|
188
|
+
| `progress` | `progress` | Progress bar and ring |
|
|
189
|
+
| `select` | `select` | Custom dropdown (not the native element) |
|
|
190
|
+
| `separator` | `separator` | Divider, optionally with centred text |
|
|
191
|
+
| `skeleton` | `skeleton` | Loading placeholder |
|
|
192
|
+
| `switch` | `switch` | Toggle switch |
|
|
193
|
+
|
|
194
|
+
### patterns (14)
|
|
195
|
+
|
|
196
|
+
| Component | Root class | Purpose |
|
|
261
197
|
|---|---|---|
|
|
262
|
-
| `
|
|
263
|
-
| `
|
|
264
|
-
| `
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
- **一致性有门禁守着**:`dist-parity` 把每个产物与源码喂给浏览器的 CSSOM,
|
|
281
|
-
必须解析出**同一份规则集**;`dist-fresh` 防"源码改了但 dist 没重建"。
|
|
282
|
-
|
|
283
|
-
**采纳一个组件到底要付多少**:见 `dist/COSTS.md`(由脚本生成,每个数字都能复算)。
|
|
284
|
-
`tokens` 的 min 版 **2.1 KB gzip**,比任何一个组件自己都贵 —— 那就是"只用一个组件"的真实起步价。
|
|
285
|
-
|
|
286
|
-
**4 · 要成套的页面(可选)** —— 页面骨架
|
|
287
|
-
|
|
288
|
-
`01-tokens/page.css` 是**页面级**的骨架:页面框、内容列宽、标题阶梯、
|
|
289
|
-
行内代码、说明块。**它是选配的**,只有写了 `class="page"` 的页面才生效:
|
|
290
|
-
|
|
291
|
-
```html
|
|
292
|
-
<link rel="stylesheet" href="01-tokens/tokens.css">
|
|
293
|
-
<link rel="stylesheet" href="01-tokens/typography.css">
|
|
294
|
-
<link rel="stylesheet" href="01-tokens/page.css">
|
|
295
|
-
<!-- 骨架要放在组件 CSS 之前:组件靠"后来者同特异性胜出"覆盖骨架,不用 !important -->
|
|
296
|
-
<link rel="stylesheet" href="02-primitives/button/button.css">
|
|
297
|
-
...
|
|
298
|
-
<body class="page">
|
|
299
|
-
<main class="wrap"> <!-- 内容列,宽度 = var(--measure-page) -->
|
|
300
|
-
<h1>标题</h1>
|
|
301
|
-
<p class="lede">导语</p>
|
|
302
|
-
<h2 class="rule-top">带分隔线的小节</h2>
|
|
303
|
-
</main>
|
|
304
|
-
</body>
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
为什么是 `class="page"` 而不是直接给 `body` / `h1` 写规则:
|
|
308
|
-
裸标签选择器的作用域是**整个文档**,会改掉宿主页面自己的同名元素。
|
|
309
|
-
挂一个类名是**显式选配** —— 不写就不生效,库对宿主页面零副作用。
|
|
310
|
-
|
|
311
|
-
要改全局观感,改这几处就够了,**不要在页面里再写一遍**:
|
|
312
|
-
|
|
313
|
-
| 想改什么 | 改哪里 |
|
|
314
|
-
|---|---|
|
|
315
|
-
| 内容列宽 | `--measure-page`(所有 `.wrap` 一起变) |
|
|
316
|
-
| 标题字号 / 字距 | `--fs-2xl` / `--tracking-title` |
|
|
317
|
-
| 页面内边距 | `--sp-6`(页面框)、`--sp-4`(左右下限) |
|
|
318
|
-
| 行内代码底色 | `--surface-sunken` |
|
|
319
|
-
| 说明块 | `--surface-sunken`(`.note--warn` 用 `--warning-bg`) |
|
|
320
|
-
|
|
321
|
-
页面里重写这些选择器**不会报错,但也不会生效**(会被 `.page` 前缀的定义
|
|
322
|
-
以更高特异性静默盖掉,成为死声明)⇒ `05-audit/shell-gate.py` 会拦住它。
|
|
323
|
-
|
|
324
|
-
## 目录
|
|
325
|
-
|
|
326
|
-
| 路径 | 内容 |
|
|
327
|
-
|---|---|
|
|
328
|
-
| `01-tokens/` | 设计令牌(颜色 / 间距 / 字号 / 圆角)、排版基线、页面骨架(`page.css`,选配)、`behavior/` 微行为核 |
|
|
329
|
-
| `02-primitives/` | 基础组件:button / input / select / combobox / date-range 等 |
|
|
330
|
-
| `03-patterns/` | 复合模式:nav / tabs / overlay / list / tree / table 等 |
|
|
331
|
-
| `04-recipes/` | 页面级示例:`longform`(长文排版)· `analysis-report`(组合型研究报告)· `table`(专业数据表格)· `data-showcase`(数据展示能力对照) |
|
|
332
|
-
| `09-assets/` | 图表资产:`sparkline`(迷你趋势线)· `scientific-plot`(二维科学绘图:坐标轴/误差棒/置信区间带/对数轴)· `echarts-adapter`(把令牌喂给 ECharts,按需,本库不含 ECharts) |
|
|
333
|
-
| `ai/` | **机器可读契约**:`components.json` / `tokens.json` / schema / 校验器 / 命令行 |
|
|
334
|
-
| `adapters/` | 场景适配层(如演示文稿),**不进核心** |
|
|
335
|
-
| `benchmark/` | 兼容性基准(10 类编辑意图,当前无模型实测记录) |
|
|
336
|
-
| `docs/` | `INVARIANT.md`(不变式)· `GUIDANCE.md`(建议)· `BENCHMARK.md`(对标) |
|
|
337
|
-
| `types/` | TypeScript 类型定义(描述 `window` 上的全局对象) |
|
|
338
|
-
|
|
339
|
-
## 示例与验证状态
|
|
340
|
-
|
|
341
|
-
### 怎么跑示例
|
|
342
|
-
|
|
343
|
-
```bash
|
|
344
|
-
npm ci
|
|
345
|
-
python -m http.server 8000 # 在仓库根起静态服务
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
| 示例 | 地址 | 展示什么 |
|
|
198
|
+
| `accordion` | `accordion` | Collapsible groups |
|
|
199
|
+
| `content` | `prose` | Long-form container: headings, paragraphs, lists, quotes, code |
|
|
200
|
+
| `drawer` | `drawer` | Side drawer with scrim |
|
|
201
|
+
| `dropdown` | `dd` | Dropdown menu |
|
|
202
|
+
| `form-validation` | `form` | Field-level feedback and an error summary |
|
|
203
|
+
| `list` | `list` | Key/value and item lists |
|
|
204
|
+
| `nav` | `nav` | Top navigation and in-page contents |
|
|
205
|
+
| `overlay` | `toast` | Toasts and modal scrims |
|
|
206
|
+
| `pagination` | `pagination` | Pagination control |
|
|
207
|
+
| `reveal` | `reveal` | Entrance motion: one `data-reveal` attribute, six directions, **works with zero JS** |
|
|
208
|
+
| `states` | `state` | Empty / loading / error / success blocks |
|
|
209
|
+
| `tabs` | `tabs` | Tab switching |
|
|
210
|
+
| `tooltip` | `tooltip` | Hover and focus hints |
|
|
211
|
+
| `tree` | `tree` | Expandable tree |
|
|
212
|
+
|
|
213
|
+
### recipes (4)
|
|
214
|
+
|
|
215
|
+
| Component | Root class | Purpose |
|
|
349
216
|
|---|---|---|
|
|
350
|
-
|
|
|
351
|
-
|
|
|
352
|
-
|
|
|
353
|
-
|
|
|
354
|
-
| 科学绘图 | `/09-assets/scientific-plot/demo.html` | 坐标轴、误差棒、置信区间带、对数轴 |
|
|
355
|
-
|
|
356
|
-
### 怎么自己验证(不想只信我们的话)
|
|
357
|
-
|
|
358
|
-
```bash
|
|
359
|
-
python -m http.server 8000 & # 🔴 必须先起静态服务:一部分门禁要真浏览器渲染
|
|
360
|
-
bash 05-audit/check-all.sh # 全量门禁约 130 项,本机约 8 分钟
|
|
361
|
-
```
|
|
217
|
+
| `analysis-report` | `report` | Research report page: body and side rail side by side, collapsing to one column |
|
|
218
|
+
| `detail-page` | `detail-page` | Entity detail skeleton: complete / partly missing / no records, three states sharing one DOM structure |
|
|
219
|
+
| `report` | `rep` | Report layout system v1: shared base plus three layouts (magazine, scientific, financial research) |
|
|
220
|
+
| `table` | `table` | Data table: sort / loading / empty / error states, three presets (financial, academic, statistical) |
|
|
362
221
|
|
|
363
|
-
|
|
222
|
+
### assets (4)
|
|
364
223
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
- 只跑一项:`python 05-audit/deprecation-gate.py`、`node 05-audit/table-check.js`、
|
|
372
|
-
`node 05-audit/scientific-plot-check.js`。
|
|
373
|
-
- 想看每道门禁**自己有没有牙**:`bash 05-audit/behavior-reverse.sh`
|
|
374
|
-
(对门禁做突变,验证它会红、且只红该红的那一条)。
|
|
375
|
-
- 想知道**我们踩过哪些坑**:`ERRORS.md`。只记真的红过的门禁和真的做错过的事,
|
|
376
|
-
每条写清症状 → 根因 → 纠正规则,规则都能照着执行。
|
|
377
|
-
|
|
378
|
-
### 经过实际验证的
|
|
379
|
-
|
|
380
|
-
- 桌面 Chrome / Edge / Firefox,跑过全量门禁(含真浏览器渲染与无障碍扫描)。
|
|
381
|
-
- 视觉基线在 `10-review/shots/_baseline/`,由 `shot-baseline` 门禁逐张比对。
|
|
382
|
-
- 每个组件的键盘路径 / ARIA / 对比度都有契约守着(`05-audit/` 下百余道检查)。
|
|
383
|
-
- 数据语义有机械断言:例如科学绘图的「缺失值不被当作零」、
|
|
384
|
-
表格的「不按数值大小猜百分比」,都有**反例对照**证明判据有效。
|
|
385
|
-
|
|
386
|
-
### 明确不承诺的
|
|
387
|
-
|
|
388
|
-
- **未在 iOS / Android 真机 WebView 上验证**(见下一节)。
|
|
389
|
-
- 不做虚拟滚动:大表格的行数上限交给调用方判断。
|
|
390
|
-
- 不提供 React / Vue 组件,只提供 CSS 类与可选的行为脚本。
|
|
391
|
-
- `scientific-plot` 不做插值、回归或任何统计计算,也不宣称显著性。
|
|
392
|
-
- 示例页里的数据**全部是演示数据**,不是真实实验结果或业务数据。
|
|
393
|
-
|
|
394
|
-
## 浏览器支持
|
|
224
|
+
| Component | Root class | Purpose |
|
|
225
|
+
|---|---|---|
|
|
226
|
+
| `bar` | `bar` | Bar chart: stacked and grouped semantics, out-of-range clipping, legend |
|
|
227
|
+
| `model-viewer` | `mv` | 3D model viewer, token-driven — ships without the rendering library itself |
|
|
228
|
+
| `scientific-plot` | `splot` | 2D scientific plotting: lines, bands, log axes, token-driven, zero dependencies |
|
|
229
|
+
| `sparkline` | `sparkline` | Inline trend shape, no axes — for a one-line trend inside a table cell |
|
|
395
230
|
|
|
396
|
-
|
|
397
|
-
|---|---|
|
|
398
|
-
| Chrome / Edge(桌面) | 已验证 |
|
|
399
|
-
| Firefox(桌面) | 已验证 |
|
|
400
|
-
| iOS Safari / WKWebView | **未在真机验证** |
|
|
401
|
-
| Android WebView | **未在真机验证** |
|
|
231
|
+
---
|
|
402
232
|
|
|
403
|
-
|
|
404
|
-
不代表已在真机 WebView 上跑过完整测试。生产前请在自己的目标环境验证。
|
|
233
|
+
## Bundle cost
|
|
405
234
|
|
|
406
|
-
|
|
235
|
+
Adopting a component costs three things: `tokens` (always required), the component CSS, and optionally component JS.
|
|
407
236
|
|
|
408
|
-
|
|
237
|
+
The token set is **2.6 KB gzip** as a minified build, and it is larger than any single component — so it *is* the real starting price for "just one button". The full per-component table is generated into [`dist/COSTS.md`](dist/COSTS.md) rather than repeated here, because a hand-written table drifts.
|
|
409
238
|
|
|
410
|
-
|
|
411
|
-
:root {
|
|
412
|
-
--accent: #0a7c5a; /* 品牌主色 */
|
|
413
|
-
--r-md: 10px; /* 圆角 */
|
|
414
|
-
--sp-3: 12px; /* 间距 */
|
|
415
|
-
}
|
|
416
|
-
```
|
|
239
|
+
Two builds ship:
|
|
417
240
|
|
|
418
|
-
|
|
241
|
+
| | Comments | Minified | Use it for |
|
|
242
|
+
|---|---|---|---|
|
|
243
|
+
| `dist/` | stripped, formatting kept | no | copying, debugging |
|
|
244
|
+
| `dist/**/*.min.css` | stripped | yes | production |
|
|
419
245
|
|
|
420
|
-
|
|
246
|
+
The source tree keeps every comment — that is documentation, not payload.
|
|
421
247
|
|
|
422
|
-
|
|
423
|
-
|---|---|
|
|
424
|
-
| 跟随系统 | 什么都不做(默认) |
|
|
425
|
-
| 强制暗 | `<html data-theme="dark">` |
|
|
426
|
-
| 强制亮 | `<html data-theme="light">` |
|
|
248
|
+
---
|
|
427
249
|
|
|
428
|
-
|
|
250
|
+
## Browser support
|
|
429
251
|
|
|
430
|
-
|
|
431
|
-
它**只翻属性,不含任何色值**(色值的真值只有一份:`tokens.css`)。
|
|
432
|
-
支持三态:跟随系统 / 亮 / 暗,`window.Theme.set('dark' | 'light' | 'auto')`。
|
|
252
|
+
[`SUPPORT.md`](SUPPORT.md) lists every engine with the evidence behind its status. Two conventions matter there:
|
|
433
253
|
|
|
434
|
-
|
|
435
|
-
|
|
254
|
+
- **Verified** means an automated check runs **in that engine** and the job reports its own user agent as proof.
|
|
255
|
+
- **Not claimed** means exactly that. A row that has not been tested is not written as supported.
|
|
436
256
|
|
|
437
|
-
##
|
|
257
|
+
## Theming
|
|
438
258
|
|
|
439
|
-
|
|
259
|
+
Themes are switched by a `data-theme` attribute on any container, not only on the root — a dark card can sit inside a light page.
|
|
440
260
|
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
node ai/cli.js tokens --mode=dark # 列出暗色令牌
|
|
444
|
-
node ai/cli.js check doc.json # 校验一份**契约文档**(读 JSON)
|
|
445
|
-
node ai/cli.js diff a.json b.json # 两份契约文档按语义 id 比对
|
|
261
|
+
```html
|
|
262
|
+
<div data-theme="dark">…</div>
|
|
446
263
|
```
|
|
447
264
|
|
|
448
|
-
|
|
449
|
-
> 想校验一个真实页面,请先用契约格式描述它,或直接跑 `npm run gate`
|
|
450
|
-
> (那里有真浏览器,能验的是渲染结果而不是源文件文本)。
|
|
451
|
-
|
|
452
|
-
- `ai/components.json` / `ai/tokens.json` 由源码**生成**(`--check` 已接门禁)
|
|
453
|
-
⇒ 改了源码忘记重新生成就红。真值只有一份,不靠"记得同步"。
|
|
454
|
-
- 组件**成熟度是算出来的**,不是人写的(没人会主动把自己的组件标成 beta)。
|
|
455
|
-
- 档位 `creative / standard / strict` 决定校验严格程度。
|
|
456
|
-
门禁会证明它有鉴别力:同一份文档在 `strict` 下的报错数必须**多于** `creative`。
|
|
457
|
-
- 文档里带未知 `extensions` 时旧版校验器只忽略、不判非法(前向兼容)。
|
|
458
|
-
|
|
459
|
-
## 规范分三层
|
|
265
|
+
Colour comes from tokens only. Component CSS never writes `@media (prefers-color-scheme: dark)`, because that expression can only answer "what does the operating system prefer", not "what theme is this region in".
|
|
460
266
|
|
|
461
|
-
|
|
267
|
+
## Machine-readable contract
|
|
462
268
|
|
|
463
|
-
|
|
464
|
-
|---|---|---|
|
|
465
|
-
| **不变式** | `docs/INVARIANT.md` | 客观事实,永不变。有门禁守边界 |
|
|
466
|
-
| **契约** | `ai/*.json` + `API.md` | 约定,随版本变 |
|
|
467
|
-
| **建议** | `docs/GUIDANCE.md` | 工作建议,可整份推翻 |
|
|
468
|
-
|
|
469
|
-
约束要放宽时动的是**建议层**,不变式一个字都不用动。
|
|
470
|
-
对标了谁、故意不学谁,见 `docs/BENCHMARK.md`。
|
|
269
|
+
`ai/components.json` describes each component for tools: usable class names, how state is expressed, required behaviours, maturity. `agentcss ai` (the `bin` entry) validates and queries it.
|
|
471
270
|
|
|
472
|
-
##
|
|
271
|
+
## Accessibility
|
|
473
272
|
|
|
474
|
-
|
|
475
|
-
- 焦点环遵循系统设置,高对比度模式下浏览器会加强
|
|
476
|
-
- 尊重 `prefers-reduced-motion`
|
|
273
|
+
Every component carries a contract covering focus order, keyboard operation, ARIA state and contrast; the checks run in real browsers rather than only reading source text. Components that fail their own contract are marked `beta` rather than described as stable.
|
|
477
274
|
|
|
478
|
-
##
|
|
275
|
+
## Development
|
|
479
276
|
|
|
480
277
|
```bash
|
|
481
|
-
npm ci
|
|
482
|
-
npm
|
|
483
|
-
npm run
|
|
484
|
-
npm
|
|
485
|
-
npm run
|
|
486
|
-
npm run ai -- check path/to/doc.json # 机器可读契约的命令行(读 JSON 文档)
|
|
487
|
-
npm run benchmark # 兼容性基准
|
|
278
|
+
npm ci
|
|
279
|
+
npm run gate # full gate run
|
|
280
|
+
npm run gate:fast # fast layer
|
|
281
|
+
npm test # unit and behaviour-core tests
|
|
282
|
+
npm run dist # rebuild dist/
|
|
488
283
|
```
|
|
489
284
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
类型声明在 `types/index.d.ts`。改动它之前先看
|
|
493
|
-
[docs/ROADMAP.md](docs/ROADMAP.md) 里的「契约类事项」——
|
|
494
|
-
那几项没做完之前,本库还不适合作为长期依赖引入。
|
|
495
|
-
|
|
496
|
-
## 许可
|
|
285
|
+
## License
|
|
497
286
|
|
|
498
|
-
MIT
|
|
287
|
+
MIT.
|