agentcss 0.11.2 → 0.11.4
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 +92 -34
- package/CONTRIBUTING.md +1 -1
- package/README.md +160 -365
- 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 +77 -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 -275
- package/docs/RFC-THEME-SCOPE.md +0 -141
- package/docs/ROADMAP.md +0 -182
package/README.md
CHANGED
|
@@ -1,133 +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
|
-
3. **无障碍**(焦点环、读屏标签、对比度)容易漏 → 这里每个组件都有契约守着
|
|
15
|
+
- **Every demo page, one index** — https://owain323.github.io/frontend-lib/
|
|
16
|
+
- **Component documentation with search** — https://owain323.github.io/frontend-lib/guide/
|
|
19
17
|
|
|
20
|
-
|
|
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
21
|
|
|
22
|
-
|
|
23
|
-
(`date-range` 是轻量的起止日期选择,不是完整的日历 / 日期选择器;
|
|
24
|
-
完整的 date-picker 请用专门的库)
|
|
25
|
-
- ❌ **不是构建工具** —— 不需要打包器,复制文件就能用
|
|
26
|
-
- ❌ **不是零依赖的 JS 框架** —— 交互组件是**可选**的,纯样式场景不用加载任何 JS
|
|
22
|
+
---
|
|
27
23
|
|
|
28
|
-
##
|
|
24
|
+
## What it solves
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
Three things that get rewritten in every mobile web project:
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
本库只在你确实缺一块时补上去。
|
|
36
|
-
- 输出形态不是网页(PPT / 文档 / 邮件)时,本库的网页布局规则**不适用**。
|
|
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.
|
|
37
31
|
|
|
38
|
-
`ai/
|
|
39
|
-
人类复用者的三步清单(组件表由脚本生成,不会漂移)。
|
|
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.
|
|
40
33
|
|
|
41
|
-
##
|
|
34
|
+
## What it is not
|
|
42
35
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
所以现在有两条**真实可用**的路:
|
|
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.
|
|
47
39
|
|
|
48
|
-
|
|
49
|
-
# ① 装**和我们验证过的那一份逐字节一致**的包(GitHub Release 附件,v0.11.2)
|
|
50
|
-
npm install https://github.com/owain323/frontend-lib/releases/download/v0.11.2/agentcss-0.11.2.tgz
|
|
40
|
+
## Use it selectively
|
|
51
41
|
|
|
52
|
-
|
|
53
|
-
npm install github:owain323/frontend-lib
|
|
54
|
-
```
|
|
42
|
+
This is an optional toolbox, not a spec every page must obey.
|
|
55
43
|
|
|
56
|
-
|
|
57
|
-
|
|
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.
|
|
58
48
|
|
|
59
|
-
|
|
60
|
-
⚠️ 复制 `dist/` 里的版本,**别复制源码版** —— 源码版有一半以上是给人和 AI 读的注释
|
|
61
|
-
(理由见下面「体积」一节)。
|
|
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.
|
|
62
50
|
|
|
63
|
-
|
|
64
|
-
> 写了而 registry 上还没有,照做的人会拿到 404,然后以为是自己的环境问题 ——
|
|
65
|
-
> 这与本库曾经踩过的「README 教人装、装到的是别人 2017 年的包」是同一类坑。
|
|
66
|
-
> 发布成功之后这一行才会换上。
|
|
51
|
+
---
|
|
67
52
|
|
|
68
|
-
##
|
|
53
|
+
## Install
|
|
69
54
|
|
|
70
|
-
|
|
55
|
+
```bash
|
|
56
|
+
npm install agentcss
|
|
57
|
+
```
|
|
71
58
|
|
|
72
|
-
|
|
59
|
+
The directory it installs as is `agentcss`, and `dist-tags.latest` points at the current version.
|
|
73
60
|
|
|
74
|
-
|
|
75
|
-
|---|---|---|
|
|
76
|
-
| `badge` | `badge` | 状态标签:计数、分类、结果标记 |
|
|
77
|
-
| `button` | `btn` | 动作触发:主/次/危险/纯文字四档 |
|
|
78
|
-
| `card` | `card` | 内容容器:媒体+正文+操作区三段 |
|
|
79
|
-
| `choice` | `choice` | 单选/多选/原生 select 外观的统一控件 |
|
|
80
|
-
| `combobox` | `combo` | 可搜索 + 可多选标签的输入控件 |
|
|
81
|
-
| `date-range` | `drange` | 日期区间选择,含预设快捷范围 |
|
|
82
|
-
| `input` | `field` | 文本输入及其标签/帮助/错误三件套 |
|
|
83
|
-
| `popover` | `popover` | 锚定到触发元素的浮层 |
|
|
84
|
-
| `progress` | `progress` | 进度条与进度环 |
|
|
85
|
-
| `select` | `select` | 自定义下拉选择(非原生) |
|
|
86
|
-
| `separator` | `separator` | 分隔线,可带中间文字 |
|
|
87
|
-
| `skeleton` | `skeleton` | 加载占位骨架 |
|
|
88
|
-
| `switch` | `switch` | 开关切换 |
|
|
89
|
-
|
|
90
|
-
### patterns · 组合模式(14)
|
|
91
|
-
|
|
92
|
-
| 组件 | 根类名 | 用途 |
|
|
93
|
-
|---|---|---|
|
|
94
|
-
| `accordion` | `accordion` | 可折叠分组 |
|
|
95
|
-
| `content` | `prose` | 长文排版容器(标题/段落/列表/引用/代码) |
|
|
96
|
-
| `drawer` | `drawer` | 侧边抽屉,含遮罩 |
|
|
97
|
-
| `dropdown` | `dd` | 下拉菜单 |
|
|
98
|
-
| `form-validation` | `form` | 表单校验反馈与错误汇总 |
|
|
99
|
-
| `list` | `list` | 键值列表/条目列表 |
|
|
100
|
-
| `nav` | `nav` | 顶部导航与目录 |
|
|
101
|
-
| `overlay` | `toast` | 吐司提示与模态遮罩 |
|
|
102
|
-
| `pagination` | `pagination` | 分页控件 |
|
|
103
|
-
| `reveal` | `reveal` | 入场动效:一个 `data-reveal` 属性管六个方向,**零 JS 也能看** |
|
|
104
|
-
| `states` | `state` | 空/加载/错误/成功四种整块状态 |
|
|
105
|
-
| `tabs` | `tabs` | 选项卡切换 |
|
|
106
|
-
| `tooltip` | `tooltip` | 悬停/聚焦提示 |
|
|
107
|
-
| `tree` | `tree` | 可展开树形结构 |
|
|
108
|
-
|
|
109
|
-
### recipes · 整页配方(4)
|
|
110
|
-
|
|
111
|
-
| 组件 | 根类名 | 用途 |
|
|
112
|
-
|---|---|---|
|
|
113
|
-
| `analysis-report` | `report` | 组合型研究报告页面:正文与辅助栏并排,窄屏自然退回单栏 |
|
|
114
|
-
| `detail-page` | `detail-page` | 实体详情页骨架:字段齐全 / 部分缺失 / 一条数据都没有,三态共用同一套 DOM |
|
|
115
|
-
| `report` | `rep` | 报告版式系统 v1:共享基础 + 三套版式(杂志/科研技术/金融研究),只换一个 … |
|
|
116
|
-
| `table` | `table` | 数据表格:排序/加载/空/错误四态;三种用途预设(财务/学术/统计) |
|
|
61
|
+
Two more paths that resolve to the same content:
|
|
117
62
|
|
|
118
|
-
|
|
63
|
+
```bash
|
|
64
|
+
# Pin an exact version and get a tarball byte-identical to the published one
|
|
65
|
+
npm install https://github.com/owain323/frontend-lib/releases/download/v0.11.3/agentcss-0.11.3.tgz
|
|
66
|
+
|
|
67
|
+
# Track master (unreleased commits)
|
|
68
|
+
npm install github:owain323/frontend-lib
|
|
69
|
+
```
|
|
119
70
|
|
|
120
|
-
| 组件 | 根类名 | 用途 |
|
|
121
|
-
|---|---|---|
|
|
122
|
-
| `bar` | `bar` | 柱状图(charter 13 图表规范):堆叠/分组两种语义、超量程裁剪、图例 |
|
|
123
|
-
| `model-viewer` | `mv` | 3D 模型查看器:令牌驱动样式,不含渲染库本体 |
|
|
124
|
-
| `scientific-plot` | `splot` | 二维科学绘图:折线/区间带/对数轴,纯令牌驱动、零依赖 |
|
|
125
|
-
| `sparkline` | `sparkline` | 迷你趋势图:无坐标轴、纯形状,适合表格内嵌的一行走势 |
|
|
126
71
|
---
|
|
127
72
|
|
|
128
|
-
##
|
|
73
|
+
## Usage
|
|
129
74
|
|
|
130
|
-
**1 ·
|
|
75
|
+
**1 · Bring in the styles** (with your bundler)
|
|
131
76
|
|
|
132
77
|
```js
|
|
133
78
|
import 'agentcss/tokens.css';
|
|
@@ -135,53 +80,48 @@ import 'agentcss/typography.css';
|
|
|
135
80
|
import 'agentcss/primitives/button/button.css';
|
|
136
81
|
```
|
|
137
82
|
|
|
138
|
-
**2 ·
|
|
83
|
+
**2 · For interactive components, load the behaviour script**
|
|
139
84
|
|
|
140
|
-
|
|
85
|
+
Behaviour scripts are IIFEs that attach to `window` (e.g. `window.Overlay`).
|
|
141
86
|
|
|
142
|
-
|
|
87
|
+
With a bundler:
|
|
143
88
|
|
|
144
89
|
```js
|
|
145
90
|
import 'agentcss/patterns/overlay/overlay.js';
|
|
146
91
|
```
|
|
147
92
|
|
|
148
|
-
|
|
93
|
+
With a `<script>` tag — note the path is the real directory inside the package:
|
|
149
94
|
|
|
150
95
|
```html
|
|
151
|
-
<!-- npm
|
|
96
|
+
<!-- npm does not create a patterns/ directory; use 03-patterns/ -->
|
|
152
97
|
<script src="node_modules/agentcss/03-patterns/overlay/overlay.js"></script>
|
|
153
98
|
```
|
|
154
99
|
|
|
155
|
-
|
|
156
|
-
`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'`.
|
|
157
101
|
|
|
158
|
-
**3 ·
|
|
102
|
+
**3 · Copy the files** (if you would rather not add a dependency)
|
|
159
103
|
|
|
160
|
-
|
|
161
|
-
拷过去不会有大段注释挡着。想读取舍理由再回源码目录看。
|
|
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.
|
|
162
105
|
|
|
163
106
|
```
|
|
164
|
-
dist/01-tokens/tokens.css
|
|
165
|
-
01-tokens/tokens.css
|
|
107
|
+
dist/01-tokens/tokens.css <- copy this
|
|
108
|
+
01-tokens/tokens.css <- source (with comments), for reading
|
|
166
109
|
```
|
|
167
110
|
|
|
168
|
-
-
|
|
169
|
-
|
|
170
|
-
- **JS 也拷 `dist/`**:那一份去了注释但没压缩(理由见「体积」一节)。
|
|
171
|
-
|
|
172
|
-
---
|
|
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.
|
|
173
113
|
|
|
174
|
-
###
|
|
114
|
+
### Smallest working page (plain HTML, no bundler)
|
|
175
115
|
|
|
176
|
-
|
|
116
|
+
Save this as `index.html` next to your `node_modules/` directory and open it directly:
|
|
177
117
|
|
|
178
118
|
```html
|
|
179
119
|
<!doctype html>
|
|
180
|
-
<html lang="
|
|
120
|
+
<html lang="en">
|
|
181
121
|
<head>
|
|
182
122
|
<meta charset="utf-8">
|
|
183
123
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
184
|
-
<title
|
|
124
|
+
<title>Example</title>
|
|
185
125
|
<link rel="stylesheet" href="node_modules/agentcss/dist/01-tokens/tokens.css">
|
|
186
126
|
<link rel="stylesheet" href="node_modules/agentcss/dist/01-tokens/typography.css">
|
|
187
127
|
<link rel="stylesheet" href="node_modules/agentcss/dist/01-tokens/page.css">
|
|
@@ -193,300 +133,155 @@ dist/01-tokens/tokens.css ← 拷这个
|
|
|
193
133
|
<body class="page">
|
|
194
134
|
<main class="wrap">
|
|
195
135
|
|
|
196
|
-
<h1
|
|
197
|
-
<p class="lede"
|
|
136
|
+
<h1>My orders</h1>
|
|
137
|
+
<p class="lede">Last 30 days · 1 order</p>
|
|
198
138
|
|
|
199
139
|
<div class="card card--interactive">
|
|
200
140
|
<div class="card__body">
|
|
201
|
-
<h3
|
|
202
|
-
<p class="small"
|
|
203
|
-
<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>
|
|
204
144
|
</div>
|
|
205
145
|
</div>
|
|
206
146
|
|
|
207
147
|
<div class="field">
|
|
208
|
-
<label class="field__label" for="q"
|
|
209
|
-
<input class="field__input" id="q" type="search" placeholder="
|
|
210
|
-
<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>
|
|
211
151
|
</div>
|
|
212
152
|
|
|
213
|
-
<button class="btn btn--md btn--primary"
|
|
153
|
+
<button class="btn btn--md btn--primary">Export</button>
|
|
214
154
|
|
|
215
155
|
</main>
|
|
216
156
|
</body>
|
|
217
157
|
</html>
|
|
218
158
|
```
|
|
219
159
|
|
|
220
|
-
|
|
160
|
+
Three mistakes the template above already avoids:
|
|
221
161
|
|
|
222
|
-
|
|
|
162
|
+
| If you write it this way | What happens |
|
|
223
163
|
|---|---|
|
|
224
|
-
| `<input class="input">` | **`.input`
|
|
225
|
-
|
|
|
226
|
-
|
|
|
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 |
|
|
227
167
|
|
|
228
|
-
|
|
229
|
-
把上面 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.
|
|
230
169
|
|
|
231
170
|
---
|
|
232
171
|
|
|
233
|
-
##
|
|
172
|
+
## Components
|
|
234
173
|
|
|
235
|
-
|
|
236
|
-
有 **66% 是注释**(354.7 KB 原始里 235.2 KB),`page.css` 单个就有 87%。
|
|
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).
|
|
237
175
|
|
|
238
|
-
|
|
239
|
-
**注释让你看代码时处处撞墙,构建工具还会把 66% 的字节原样传下去。**
|
|
176
|
+
### primitives (13)
|
|
240
177
|
|
|
241
|
-
|
|
242
|
-
源码版放在 `agentcss/src/*`:
|
|
243
|
-
|
|
244
|
-
| 你写的 | 实际拿到 | tokens 那一项的体积 |
|
|
178
|
+
| Component | Root class | Purpose |
|
|
245
179
|
|---|---|---|
|
|
246
|
-
| `
|
|
247
|
-
| `
|
|
248
|
-
| `
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
|
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 |
|
|
255
197
|
|---|---|---|
|
|
256
|
-
| `
|
|
257
|
-
| `
|
|
258
|
-
| `
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
- **一致性有门禁守着**:`dist-parity` 把每个产物与源码喂给浏览器的 CSSOM,
|
|
275
|
-
必须解析出**同一份规则集**;`dist-fresh` 防"源码改了但 dist 没重建"。
|
|
276
|
-
|
|
277
|
-
**采纳一个组件到底要付多少**:见 `dist/COSTS.md`(由脚本生成,每个数字都能复算)。
|
|
278
|
-
`tokens` 的 min 版 **2.1 KB gzip**,比任何一个组件自己都贵 —— 那就是"只用一个组件"的真实起步价。
|
|
279
|
-
|
|
280
|
-
**4 · 要成套的页面(可选)** —— 页面骨架
|
|
281
|
-
|
|
282
|
-
`01-tokens/page.css` 是**页面级**的骨架:页面框、内容列宽、标题阶梯、
|
|
283
|
-
行内代码、说明块。**它是选配的**,只有写了 `class="page"` 的页面才生效:
|
|
284
|
-
|
|
285
|
-
```html
|
|
286
|
-
<link rel="stylesheet" href="01-tokens/tokens.css">
|
|
287
|
-
<link rel="stylesheet" href="01-tokens/typography.css">
|
|
288
|
-
<link rel="stylesheet" href="01-tokens/page.css">
|
|
289
|
-
<!-- 骨架要放在组件 CSS 之前:组件靠"后来者同特异性胜出"覆盖骨架,不用 !important -->
|
|
290
|
-
<link rel="stylesheet" href="02-primitives/button/button.css">
|
|
291
|
-
...
|
|
292
|
-
<body class="page">
|
|
293
|
-
<main class="wrap"> <!-- 内容列,宽度 = var(--measure-page) -->
|
|
294
|
-
<h1>标题</h1>
|
|
295
|
-
<p class="lede">导语</p>
|
|
296
|
-
<h2 class="rule-top">带分隔线的小节</h2>
|
|
297
|
-
</main>
|
|
298
|
-
</body>
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
为什么是 `class="page"` 而不是直接给 `body` / `h1` 写规则:
|
|
302
|
-
裸标签选择器的作用域是**整个文档**,会改掉宿主页面自己的同名元素。
|
|
303
|
-
挂一个类名是**显式选配** —— 不写就不生效,库对宿主页面零副作用。
|
|
304
|
-
|
|
305
|
-
要改全局观感,改这几处就够了,**不要在页面里再写一遍**:
|
|
306
|
-
|
|
307
|
-
| 想改什么 | 改哪里 |
|
|
308
|
-
|---|---|
|
|
309
|
-
| 内容列宽 | `--measure-page`(所有 `.wrap` 一起变) |
|
|
310
|
-
| 标题字号 / 字距 | `--fs-2xl` / `--tracking-title` |
|
|
311
|
-
| 页面内边距 | `--sp-6`(页面框)、`--sp-4`(左右下限) |
|
|
312
|
-
| 行内代码底色 | `--surface-sunken` |
|
|
313
|
-
| 说明块 | `--surface-sunken`(`.note--warn` 用 `--warning-bg`) |
|
|
314
|
-
|
|
315
|
-
页面里重写这些选择器**不会报错,但也不会生效**(会被 `.page` 前缀的定义
|
|
316
|
-
以更高特异性静默盖掉,成为死声明)⇒ `05-audit/shell-gate.py` 会拦住它。
|
|
317
|
-
|
|
318
|
-
## 目录
|
|
319
|
-
|
|
320
|
-
| 路径 | 内容 |
|
|
321
|
-
|---|---|
|
|
322
|
-
| `01-tokens/` | 设计令牌(颜色 / 间距 / 字号 / 圆角)、排版基线、页面骨架(`page.css`,选配)、`behavior/` 微行为核 |
|
|
323
|
-
| `02-primitives/` | 基础组件:button / input / select / combobox / date-range 等 |
|
|
324
|
-
| `03-patterns/` | 复合模式:nav / tabs / overlay / list / tree / table 等 |
|
|
325
|
-
| `04-recipes/` | 页面级示例:`longform`(长文排版)· `analysis-report`(组合型研究报告)· `table`(专业数据表格)· `data-showcase`(数据展示能力对照) |
|
|
326
|
-
| `09-assets/` | 图表资产:`sparkline`(迷你趋势线)· `scientific-plot`(二维科学绘图:坐标轴/误差棒/置信区间带/对数轴)· `echarts-adapter`(把令牌喂给 ECharts,按需,本库不含 ECharts) |
|
|
327
|
-
| `ai/` | **机器可读契约**:`components.json` / `tokens.json` / schema / 校验器 / 命令行 |
|
|
328
|
-
| `adapters/` | 场景适配层(如演示文稿),**不进核心** |
|
|
329
|
-
| `benchmark/` | 兼容性基准(10 类编辑意图,当前无模型实测记录) |
|
|
330
|
-
| `docs/` | `INVARIANT.md`(不变式)· `GUIDANCE.md`(建议)· `BENCHMARK.md`(对标) |
|
|
331
|
-
| `types/` | TypeScript 类型定义(描述 `window` 上的全局对象) |
|
|
332
|
-
|
|
333
|
-
## 示例与验证状态
|
|
334
|
-
|
|
335
|
-
### 怎么跑示例
|
|
336
|
-
|
|
337
|
-
```bash
|
|
338
|
-
npm ci
|
|
339
|
-
python -m http.server 8000 # 在仓库根起静态服务
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
| 示例 | 地址 | 展示什么 |
|
|
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 |
|
|
343
216
|
|---|---|---|
|
|
344
|
-
|
|
|
345
|
-
|
|
|
346
|
-
|
|
|
347
|
-
|
|
|
348
|
-
| 科学绘图 | `/09-assets/scientific-plot/demo.html` | 坐标轴、误差棒、置信区间带、对数轴 |
|
|
349
|
-
|
|
350
|
-
### 怎么自己验证(不想只信我们的话)
|
|
351
|
-
|
|
352
|
-
```bash
|
|
353
|
-
python -m http.server 8000 & # 🔴 必须先起静态服务:一部分门禁要真浏览器渲染
|
|
354
|
-
bash 05-audit/check-all.sh # 全量门禁约 130 项,本机约 8 分钟
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
每一项的输出是 `PASS` / `FAIL` / `SKIP`,末尾给出失败条数与退出码(全绿为 0)。
|
|
358
|
-
|
|
359
|
-
- **`SKIP` 是真话,不是通过。** 缺依赖的项会明确写"装了才会跑",
|
|
360
|
-
例如 `visual`(逐张比对视觉基线)需要 Pillow:`pip install pillow`。
|
|
361
|
-
真浏览器类门禁需要 `npm ci`。
|
|
362
|
-
- **环境不全时它不会给你假绿。** 忘了起静态服务,真浏览器类门禁会直接报:
|
|
363
|
-
「基线跑不起来(一条 FAIL 都没有):多半是崩了或 8000 端口没有静态服务」。
|
|
364
|
-
—— 这正是本库对"门禁报通过却什么也没查"的处置:**宁可红,不假装绿。**
|
|
365
|
-
- 只跑一项:`python 05-audit/deprecation-gate.py`、`node 05-audit/table-check.js`、
|
|
366
|
-
`node 05-audit/scientific-plot-check.js`。
|
|
367
|
-
- 想看每道门禁**自己有没有牙**:`bash 05-audit/behavior-reverse.sh`
|
|
368
|
-
(对门禁做突变,验证它会红、且只红该红的那一条)。
|
|
369
|
-
- 想知道**我们踩过哪些坑**:`ERRORS.md`。只记真的红过的门禁和真的做错过的事,
|
|
370
|
-
每条写清症状 → 根因 → 纠正规则,规则都能照着执行。
|
|
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) |
|
|
371
221
|
|
|
372
|
-
###
|
|
222
|
+
### assets (4)
|
|
373
223
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
### 明确不承诺的
|
|
381
|
-
|
|
382
|
-
- **未在 iOS / Android 真机 WebView 上验证**(见下一节)。
|
|
383
|
-
- 不做虚拟滚动:大表格的行数上限交给调用方判断。
|
|
384
|
-
- 不提供 React / Vue 组件,只提供 CSS 类与可选的行为脚本。
|
|
385
|
-
- `scientific-plot` 不做插值、回归或任何统计计算,也不宣称显著性。
|
|
386
|
-
- 示例页里的数据**全部是演示数据**,不是真实实验结果或业务数据。
|
|
387
|
-
|
|
388
|
-
## 浏览器支持
|
|
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 |
|
|
389
230
|
|
|
390
|
-
|
|
391
|
-
|---|---|
|
|
392
|
-
| Chrome / Edge(桌面) | 已验证 |
|
|
393
|
-
| Firefox(桌面) | 已验证 |
|
|
394
|
-
| iOS Safari / WKWebView | **未在真机验证** |
|
|
395
|
-
| Android WebView | **未在真机验证** |
|
|
231
|
+
---
|
|
396
232
|
|
|
397
|
-
|
|
398
|
-
不代表已在真机 WebView 上跑过完整测试。生产前请在自己的目标环境验证。
|
|
233
|
+
## Bundle cost
|
|
399
234
|
|
|
400
|
-
|
|
235
|
+
Adopting a component costs three things: `tokens` (always required), the component CSS, and optionally component JS.
|
|
401
236
|
|
|
402
|
-
|
|
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.
|
|
403
238
|
|
|
404
|
-
|
|
405
|
-
:root {
|
|
406
|
-
--accent: #0a7c5a; /* 品牌主色 */
|
|
407
|
-
--r-md: 10px; /* 圆角 */
|
|
408
|
-
--sp-3: 12px; /* 间距 */
|
|
409
|
-
}
|
|
410
|
-
```
|
|
239
|
+
Two builds ship:
|
|
411
240
|
|
|
412
|
-
|
|
241
|
+
| | Comments | Minified | Use it for |
|
|
242
|
+
|---|---|---|---|
|
|
243
|
+
| `dist/` | stripped, formatting kept | no | copying, debugging |
|
|
244
|
+
| `dist/**/*.min.css` | stripped | yes | production |
|
|
413
245
|
|
|
414
|
-
|
|
246
|
+
The source tree keeps every comment — that is documentation, not payload.
|
|
415
247
|
|
|
416
|
-
|
|
417
|
-
|---|---|
|
|
418
|
-
| 跟随系统 | 什么都不做(默认) |
|
|
419
|
-
| 强制暗 | `<html data-theme="dark">` |
|
|
420
|
-
| 强制亮 | `<html data-theme="light">` |
|
|
248
|
+
---
|
|
421
249
|
|
|
422
|
-
|
|
250
|
+
## Browser support
|
|
423
251
|
|
|
424
|
-
|
|
425
|
-
它**只翻属性,不含任何色值**(色值的真值只有一份:`tokens.css`)。
|
|
426
|
-
支持三态:跟随系统 / 亮 / 暗,`window.Theme.set('dark' | 'light' | 'auto')`。
|
|
252
|
+
[`SUPPORT.md`](SUPPORT.md) lists every engine with the evidence behind its status. Two conventions matter there:
|
|
427
253
|
|
|
428
|
-
|
|
429
|
-
|
|
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.
|
|
430
256
|
|
|
431
|
-
##
|
|
257
|
+
## Theming
|
|
432
258
|
|
|
433
|
-
|
|
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.
|
|
434
260
|
|
|
435
|
-
```
|
|
436
|
-
|
|
437
|
-
node ai/cli.js tokens --mode=dark # 列出暗色令牌
|
|
438
|
-
node ai/cli.js check doc.json # 校验一份**契约文档**(读 JSON)
|
|
439
|
-
node ai/cli.js diff a.json b.json # 两份契约文档按语义 id 比对
|
|
261
|
+
```html
|
|
262
|
+
<div data-theme="dark">…</div>
|
|
440
263
|
```
|
|
441
264
|
|
|
442
|
-
|
|
443
|
-
> 想校验一个真实页面,请先用契约格式描述它,或直接跑 `npm run gate`
|
|
444
|
-
> (那里有真浏览器,能验的是渲染结果而不是源文件文本)。
|
|
445
|
-
|
|
446
|
-
- `ai/components.json` / `ai/tokens.json` 由源码**生成**(`--check` 已接门禁)
|
|
447
|
-
⇒ 改了源码忘记重新生成就红。真值只有一份,不靠"记得同步"。
|
|
448
|
-
- 组件**成熟度是算出来的**,不是人写的(没人会主动把自己的组件标成 beta)。
|
|
449
|
-
- 档位 `creative / standard / strict` 决定校验严格程度。
|
|
450
|
-
门禁会证明它有鉴别力:同一份文档在 `strict` 下的报错数必须**多于** `creative`。
|
|
451
|
-
- 文档里带未知 `extensions` 时旧版校验器只忽略、不判非法(前向兼容)。
|
|
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".
|
|
452
266
|
|
|
453
|
-
##
|
|
267
|
+
## Machine-readable contract
|
|
454
268
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
| 层 | 文件 | 性质 |
|
|
458
|
-
|---|---|---|
|
|
459
|
-
| **不变式** | `docs/INVARIANT.md` | 客观事实,永不变。有门禁守边界 |
|
|
460
|
-
| **契约** | `ai/*.json` + `API.md` | 约定,随版本变 |
|
|
461
|
-
| **建议** | `docs/GUIDANCE.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.
|
|
462
270
|
|
|
463
|
-
|
|
464
|
-
对标了谁、故意不学谁,见 `docs/BENCHMARK.md`。
|
|
271
|
+
## Accessibility
|
|
465
272
|
|
|
466
|
-
|
|
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.
|
|
467
274
|
|
|
468
|
-
|
|
469
|
-
- 焦点环遵循系统设置,高对比度模式下浏览器会加强
|
|
470
|
-
- 尊重 `prefers-reduced-motion`
|
|
471
|
-
|
|
472
|
-
## 开发
|
|
275
|
+
## Development
|
|
473
276
|
|
|
474
277
|
```bash
|
|
475
|
-
npm ci
|
|
476
|
-
npm
|
|
477
|
-
npm run
|
|
478
|
-
npm
|
|
479
|
-
npm run
|
|
480
|
-
npm run ai -- check path/to/doc.json # 机器可读契约的命令行(读 JSON 文档)
|
|
481
|
-
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/
|
|
482
283
|
```
|
|
483
284
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
类型声明在 `types/index.d.ts`。改动它之前先看
|
|
487
|
-
[docs/ROADMAP.md](docs/ROADMAP.md) 里的「契约类事项」——
|
|
488
|
-
那几项没做完之前,本库还不适合作为长期依赖引入。
|
|
489
|
-
|
|
490
|
-
## 许可
|
|
285
|
+
## License
|
|
491
286
|
|
|
492
|
-
MIT
|
|
287
|
+
MIT.
|