@qw-ui/tokens 0.3.0-next.4 → 0.3.0-next.42
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/README.md +20 -53
- package/dist/color-architecture.d.ts +163 -2
- package/dist/derive/index.d.ts +3 -3
- package/dist/derive/live-css.d.ts +1 -1
- package/dist/derive/reference.d.ts +73 -13
- package/dist/derive/semantic.d.ts +24 -1
- package/dist/derive/tailwind.d.ts +31 -0
- package/dist/design-doc.d.ts +1 -1
- package/dist/figma/color-contract.d.ts +2 -0
- package/dist/figma/color-snapshot.d.ts +4 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1027 -366
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +3 -3
- package/dist/tailwind.css +85 -0
- package/dist/tokens.css +308 -218
- package/dist/tokens.json +290 -93
- package/dist/tokens.live.css +178 -9
- package/dist/tokens.ts +293 -131
- package/package.json +12 -29
- package/dist/compat/build.d.ts +0 -14
- package/dist/compat/color.d.ts +0 -8
- package/dist/compat/index.d.ts +0 -5
- package/dist/compat/schema.d.ts +0 -114
package/README.md
CHANGED
|
@@ -1,76 +1,43 @@
|
|
|
1
1
|
# @qw-ui/tokens
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
**层级 L1 · 设计令牌**。qw-ui 全链路样式的单一数据源,所有组件颜色/尺寸只允许引用本包派生出的 **T3 Semantic token(`--qw-sem-*`)**,禁止直写字面量。
|
|
6
|
-
|
|
7
|
-
## 三层派生
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
T1 Seed ──derive() OKLCH──► T2 Reference ──► T3 Semantic (--qw-sem-*)
|
|
11
|
-
(少量种子色) (完整色阶) (组件消费的语义角色)
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Style Dictionary 把三层编译成 CSS 变量与 TS 类型。组件与业务只碰 T3。
|
|
3
|
+
设计 Token 与主题。Design tokens and theme utilities for qw-ui.
|
|
15
4
|
|
|
16
5
|
## 安装
|
|
17
6
|
|
|
7
|
+
当前开发版本使用 `next`:
|
|
8
|
+
|
|
18
9
|
```bash
|
|
19
|
-
|
|
10
|
+
npm install @qw-ui/tokens@next
|
|
20
11
|
```
|
|
21
12
|
|
|
22
|
-
|
|
13
|
+
包发布于 [公共 npm](https://www.npmjs.com/package/@qw-ui/tokens)。如环境配置了其他镜像,可在安装命令后追加 `--registry=https://registry.npmjs.org/`。
|
|
23
14
|
|
|
24
15
|
## 最小示例
|
|
25
16
|
|
|
26
17
|
```ts
|
|
27
|
-
|
|
28
|
-
import
|
|
18
|
+
import '@qw-ui/tokens/tokens.css';
|
|
19
|
+
import { defaultSeed, derive } from '@qw-ui/tokens';
|
|
29
20
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// 3. TS 侧拿 token 路径类型 / 原始 JSON
|
|
34
|
-
import type { TokenPath } from "@qw-ui/tokens/token-paths";
|
|
35
|
-
import tokens from "@qw-ui/tokens/tokens.json" with { type: "json" };
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
CSS 里直接用变量:
|
|
39
|
-
|
|
40
|
-
```css
|
|
41
|
-
.card { color: var(--qw-sem-color-content-primary); background: var(--qw-sem-color-surface-base); }
|
|
21
|
+
const theme = derive(defaultSeed);
|
|
22
|
+
console.log(theme);
|
|
42
23
|
```
|
|
43
24
|
|
|
44
|
-
##
|
|
25
|
+
## 使用说明
|
|
45
26
|
|
|
46
|
-
|
|
47
|
-
|---|---|---|
|
|
48
|
-
| `tokens.css` | 默认静态变量,构建期固化 | 需整页换文件 |
|
|
49
|
-
| `tokens.live.css` | 语义变量随 `<html data-qw-mode>` / Provider 解析 | 运行时切换(见下) |
|
|
27
|
+
应用使用 `tokens.css` 提供默认变量;组件消费 `--qw-sem-*` 语义变量。可通过容器的 `data-qw-mode="dark"` 使用暗色主题。`tokens.live.css`、`tailwind.css`、`tokens.json` 等公开资源按项目需求选择,具体入口以 package exports 为准。
|
|
50
28
|
|
|
51
|
-
|
|
29
|
+
## 兼容性
|
|
52
30
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
| 包 | 关系 |
|
|
56
|
-
|---|---|
|
|
57
|
-
| [@qw-ui/react](../react/README.md) / [@qw-ui/vue](../vue/README.md) | 消费 T3 token 渲染组件,需先引本包 CSS |
|
|
58
|
-
| [@qw-ui/theme-editor](../theme-editor/README.md) | 可视化编辑 Seed → 实时预览三层级联 |
|
|
59
|
-
| `@qw-ui/styles-core`(private,不发布) | vanilla-extract 样式事实源,只读本包 T3 token |
|
|
60
|
-
|
|
61
|
-
设计稿老色值 → T3 映射见 skill `qw-legacy-token-map`。
|
|
31
|
+
CSS 面向 Chrome 123 / iOS Safari 16.4。主题派生 API 可用于 Node 构建工具和浏览器。
|
|
62
32
|
|
|
63
33
|
## 版本通道
|
|
64
34
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
| `next`(预发布) | `pnpm add @qw-ui/tokens@next` | `release/next` 通道,高频自增 `x.y.z-next.N` |
|
|
69
|
-
|
|
70
|
-
8 个公开包 `fixed` 锁步同版本号。npm 发布固定走 `registry.npmjs.org`;内网装依赖走 `registry.anpm.alibaba-inc.com`(tnpm 代理),发布 registry 不要指向内网。流程详见 [development-workflow.md](../../docs/development-workflow.md)。
|
|
35
|
+
- `next`:main 更新并通过检查后自动发布,用于试用当前能力。
|
|
36
|
+
- `latest`:负责人手动发布的正式版本。正式版可用后,使用 `npm install @qw-ui/tokens@latest`;正式版支持范围以该版本 README 为准。
|
|
37
|
+
- 生产项目建议锁定明确版本。配套使用的 `@qw-ui/*` 包应选择同批版本;内部运行时依赖由包管理器安装。
|
|
71
38
|
|
|
72
|
-
##
|
|
39
|
+
## 文档与许可证
|
|
73
40
|
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
41
|
+
- [组件文档与接入指南](https://qw-ui.qianwen.com/)
|
|
42
|
+
- [npm 版本列表](https://www.npmjs.com/package/@qw-ui/tokens?activeTab=versions)
|
|
43
|
+
- MIT,详见包内 `LICENSE`。
|
|
@@ -9,7 +9,20 @@ export type T2AlphaStep = (typeof T2_ALPHA_STEPS)[number];
|
|
|
9
9
|
export type T2AlphaKey = (typeof T2_ALPHA_KEYS)[number];
|
|
10
10
|
export declare const T2_OKLCH_STEPS: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
11
11
|
export type T2OklchStep = (typeof T2_OKLCH_STEPS)[number];
|
|
12
|
+
/** RFC0012 approved local standard endpoint; Figma synchronization is pending. */
|
|
13
|
+
export declare const T2_BLACK_CONTRAST_ENDPOINT: {
|
|
14
|
+
readonly step: "contrast-endpoint";
|
|
15
|
+
readonly value: "#000000";
|
|
16
|
+
readonly source: "CSS Color sRGB black mathematical endpoint; specs/rfcs/0012-brand-solid-text-contrast.md";
|
|
17
|
+
readonly rationale: "The zero sRGB endpoint is a standard constant for on-brand AA text, independent of Seed and existing color scales.";
|
|
18
|
+
};
|
|
12
19
|
export declare const FIGMA_T2_SOLID_SCALE: Record<T1ColorKey, Record<T2OklchStep, string>>;
|
|
20
|
+
/**
|
|
21
|
+
* Figma「Color Token System」既有角色及用户批准的本地补充角色。
|
|
22
|
+
* 既有角色与 Figma 节点 22258:49986 对齐;新角色等待 Figma 同步,不冒充已回流。
|
|
23
|
+
* light/dark 均引用 T2;`effect.shadow.*.color` 为复合阴影的颜色
|
|
24
|
+
* 分量(对应 Figma 变量 `--qw-sem-effect-shadow-*-color`)。
|
|
25
|
+
*/
|
|
13
26
|
export declare const FIGMA_T3_COLOR_ROLES: {
|
|
14
27
|
readonly "surface.base": {
|
|
15
28
|
readonly light: "color.white.base";
|
|
@@ -31,6 +44,30 @@ export declare const FIGMA_T3_COLOR_ROLES: {
|
|
|
31
44
|
readonly light: "color.blue.50";
|
|
32
45
|
readonly dark: "color.blue.800";
|
|
33
46
|
};
|
|
47
|
+
readonly "surface.canvas": {
|
|
48
|
+
readonly light: "color.white.base";
|
|
49
|
+
readonly dark: "color.black.900";
|
|
50
|
+
};
|
|
51
|
+
readonly "surface.sunken": {
|
|
52
|
+
readonly light: "color.gray.100";
|
|
53
|
+
readonly dark: "color.gray.800";
|
|
54
|
+
};
|
|
55
|
+
readonly "surface.selected": {
|
|
56
|
+
readonly light: "color.black.a5";
|
|
57
|
+
readonly dark: "color.white.a10";
|
|
58
|
+
};
|
|
59
|
+
readonly "surface.inverse": {
|
|
60
|
+
readonly light: "color.black.800";
|
|
61
|
+
readonly dark: "color.black.800";
|
|
62
|
+
};
|
|
63
|
+
readonly "surface.canvas-subtle": {
|
|
64
|
+
readonly light: "color.gray.50";
|
|
65
|
+
readonly dark: "color.black.900";
|
|
66
|
+
};
|
|
67
|
+
readonly "content.danger": {
|
|
68
|
+
readonly light: "color.red.600";
|
|
69
|
+
readonly dark: "color.red.300";
|
|
70
|
+
};
|
|
34
71
|
readonly "content.primary": {
|
|
35
72
|
readonly light: "color.black.base";
|
|
36
73
|
readonly dark: "color.white.base";
|
|
@@ -51,6 +88,34 @@ export declare const FIGMA_T3_COLOR_ROLES: {
|
|
|
51
88
|
readonly light: "color.gray.400";
|
|
52
89
|
readonly dark: "color.gray.500";
|
|
53
90
|
};
|
|
91
|
+
readonly "content.disabled": {
|
|
92
|
+
readonly light: "color.black.a30";
|
|
93
|
+
readonly dark: "color.white.a30";
|
|
94
|
+
};
|
|
95
|
+
readonly "content.link": {
|
|
96
|
+
readonly light: "color.blue.700";
|
|
97
|
+
readonly dark: "color.blue.400";
|
|
98
|
+
};
|
|
99
|
+
readonly "content.icon-subtle": {
|
|
100
|
+
readonly light: "color.black.a5";
|
|
101
|
+
readonly dark: "color.white.a10";
|
|
102
|
+
};
|
|
103
|
+
readonly "content.inverse": {
|
|
104
|
+
readonly light: "color.white.base";
|
|
105
|
+
readonly dark: "color.black.base";
|
|
106
|
+
};
|
|
107
|
+
readonly "content.on-solid": {
|
|
108
|
+
readonly light: "color.white.base";
|
|
109
|
+
readonly dark: "color.white.base";
|
|
110
|
+
};
|
|
111
|
+
readonly "content.on-brand": {
|
|
112
|
+
readonly light: "color.white.base";
|
|
113
|
+
readonly dark: "color.black.contrast-endpoint";
|
|
114
|
+
};
|
|
115
|
+
readonly "content.on-warning-subtle": {
|
|
116
|
+
readonly light: "color.yellow.800";
|
|
117
|
+
readonly dark: "color.yellow.200";
|
|
118
|
+
};
|
|
54
119
|
readonly "border.default": {
|
|
55
120
|
readonly light: "color.gray.100";
|
|
56
121
|
readonly dark: "color.gray.700";
|
|
@@ -59,10 +124,26 @@ export declare const FIGMA_T3_COLOR_ROLES: {
|
|
|
59
124
|
readonly light: "color.gray.300";
|
|
60
125
|
readonly dark: "color.gray.600";
|
|
61
126
|
};
|
|
127
|
+
readonly "border.control": {
|
|
128
|
+
readonly light: "color.gray.600";
|
|
129
|
+
readonly dark: "color.gray.base";
|
|
130
|
+
};
|
|
62
131
|
readonly "border.focus": {
|
|
63
132
|
readonly light: "color.brand.base";
|
|
64
133
|
readonly dark: "color.brand.500";
|
|
65
134
|
};
|
|
135
|
+
readonly "border.subtle": {
|
|
136
|
+
readonly light: "color.black.a5";
|
|
137
|
+
readonly dark: "color.white.a5";
|
|
138
|
+
};
|
|
139
|
+
readonly "border.disabled": {
|
|
140
|
+
readonly light: "color.black.a10";
|
|
141
|
+
readonly dark: "color.white.a10";
|
|
142
|
+
};
|
|
143
|
+
readonly "border.on-media": {
|
|
144
|
+
readonly light: "color.white.base";
|
|
145
|
+
readonly dark: "color.white.base";
|
|
146
|
+
};
|
|
66
147
|
readonly "fill.subtle": {
|
|
67
148
|
readonly light: "color.gray.50";
|
|
68
149
|
readonly dark: "color.white.a20";
|
|
@@ -79,6 +160,10 @@ export declare const FIGMA_T3_COLOR_ROLES: {
|
|
|
79
160
|
readonly light: "color.gray.50";
|
|
80
161
|
readonly dark: "color.gray.900";
|
|
81
162
|
};
|
|
163
|
+
readonly "fill.track": {
|
|
164
|
+
readonly light: "color.black.a10";
|
|
165
|
+
readonly dark: "color.white.a20";
|
|
166
|
+
};
|
|
82
167
|
readonly "action.brand": {
|
|
83
168
|
readonly light: "color.brand.base";
|
|
84
169
|
readonly dark: "color.brand.500";
|
|
@@ -95,6 +180,38 @@ export declare const FIGMA_T3_COLOR_ROLES: {
|
|
|
95
180
|
readonly light: "color.white.base";
|
|
96
181
|
readonly dark: "color.black.base";
|
|
97
182
|
};
|
|
183
|
+
readonly "control-action.brand.subtle": {
|
|
184
|
+
readonly light: "color.brand.a10";
|
|
185
|
+
readonly dark: "color.brand.a20";
|
|
186
|
+
};
|
|
187
|
+
readonly "control-action.product.subtle": {
|
|
188
|
+
readonly light: "color.blue.a10";
|
|
189
|
+
readonly dark: "color.blue.a20";
|
|
190
|
+
};
|
|
191
|
+
readonly "control-action.danger.default": {
|
|
192
|
+
readonly light: "color.red.600";
|
|
193
|
+
readonly dark: "color.red.600";
|
|
194
|
+
};
|
|
195
|
+
readonly "control-action.danger.subtle": {
|
|
196
|
+
readonly light: "color.red.a10";
|
|
197
|
+
readonly dark: "color.red.a20";
|
|
198
|
+
};
|
|
199
|
+
readonly "control-action.neutral.subtle": {
|
|
200
|
+
readonly light: "color.black.a5";
|
|
201
|
+
readonly dark: "color.white.a10";
|
|
202
|
+
};
|
|
203
|
+
readonly "control-selection.brand": {
|
|
204
|
+
readonly light: "color.brand.a10";
|
|
205
|
+
readonly dark: "color.brand.a20";
|
|
206
|
+
};
|
|
207
|
+
readonly "control-selection.product": {
|
|
208
|
+
readonly light: "color.blue.a10";
|
|
209
|
+
readonly dark: "color.blue.a20";
|
|
210
|
+
};
|
|
211
|
+
readonly "selection.text-background": {
|
|
212
|
+
readonly light: "color.blue.a20";
|
|
213
|
+
readonly dark: "color.blue.a40";
|
|
214
|
+
};
|
|
98
215
|
readonly "status.success": {
|
|
99
216
|
readonly light: "color.green.base";
|
|
100
217
|
readonly dark: "color.green.base";
|
|
@@ -111,12 +228,56 @@ export declare const FIGMA_T3_COLOR_ROLES: {
|
|
|
111
228
|
readonly light: "color.blue.base";
|
|
112
229
|
readonly dark: "color.blue.600";
|
|
113
230
|
};
|
|
231
|
+
readonly "status.success-subtle": {
|
|
232
|
+
readonly light: "color.green.a10";
|
|
233
|
+
readonly dark: "color.green.a20";
|
|
234
|
+
};
|
|
235
|
+
readonly "status.warning-subtle": {
|
|
236
|
+
readonly light: "color.yellow.a20";
|
|
237
|
+
readonly dark: "color.yellow.a20";
|
|
238
|
+
};
|
|
239
|
+
readonly "status.danger-subtle": {
|
|
240
|
+
readonly light: "color.red.a10";
|
|
241
|
+
readonly dark: "color.red.a20";
|
|
242
|
+
};
|
|
243
|
+
readonly "status.info-subtle": {
|
|
244
|
+
readonly light: "color.blue.a10";
|
|
245
|
+
readonly dark: "color.blue.a20";
|
|
246
|
+
};
|
|
114
247
|
readonly "overlay.scrim": {
|
|
115
248
|
readonly light: "color.black.a50";
|
|
116
249
|
readonly dark: "color.black.a70";
|
|
117
250
|
};
|
|
118
251
|
readonly "overlay.guide": {
|
|
119
|
-
readonly light: "color.
|
|
120
|
-
readonly dark: "color.
|
|
252
|
+
readonly light: "color.blue.a10";
|
|
253
|
+
readonly dark: "color.blue.a20";
|
|
254
|
+
};
|
|
255
|
+
readonly "overlay.media-subtle": {
|
|
256
|
+
readonly light: "color.black.a40";
|
|
257
|
+
readonly dark: "color.black.a40";
|
|
258
|
+
};
|
|
259
|
+
readonly "overlay.media-strong": {
|
|
260
|
+
readonly light: "color.black.a50";
|
|
261
|
+
readonly dark: "color.black.a50";
|
|
262
|
+
};
|
|
263
|
+
readonly "overlay.control-on-media": {
|
|
264
|
+
readonly light: "color.black.a50";
|
|
265
|
+
readonly dark: "color.white.a40";
|
|
266
|
+
};
|
|
267
|
+
readonly shadow: {
|
|
268
|
+
readonly light: "color.black.a10";
|
|
269
|
+
readonly dark: "color.black.a50";
|
|
270
|
+
};
|
|
271
|
+
readonly "effect.shadow.card.color": {
|
|
272
|
+
readonly light: "color.black.a10";
|
|
273
|
+
readonly dark: "color.black.a50";
|
|
274
|
+
};
|
|
275
|
+
readonly "effect.shadow.floating.color": {
|
|
276
|
+
readonly light: "color.black.a10";
|
|
277
|
+
readonly dark: "color.black.a50";
|
|
278
|
+
};
|
|
279
|
+
readonly "effect.shadow.dialog.color": {
|
|
280
|
+
readonly light: "color.black.a10";
|
|
281
|
+
readonly dark: "color.black.a50";
|
|
121
282
|
};
|
|
122
283
|
};
|
package/dist/derive/index.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ export type { Layer } from "./naming.js";
|
|
|
4
4
|
export { ramp, STEPS, L_TARGETS, chromaFactor, contrastRatio } from "./oklch.js";
|
|
5
5
|
export type { Step, Ramp } from "./oklch.js";
|
|
6
6
|
export type { SemanticMode as Mode } from "./semantic.js";
|
|
7
|
-
export type { ReferenceRecipe, ReferenceTokens, ReferenceBuild, Derivation, ShadowLevel, ShadowShape, } from "./reference.js";
|
|
8
|
-
export { buildReference, allReferenceRecipes, evaluateDerivation, seedRefsOf, formatDerivation, seedValueAt, RAMP_COLORS, BLACK_ALPHA, WHITE_ALPHA, RADIUS_FACTORS, FONT_SIZE_FACTORS, DURATION_FACTORS, SHADOW_LEVELS, FONT_FAMILY_KEYS, } from "./reference.js";
|
|
9
|
-
export { buildSemanticStructural, buildSemanticColor, semanticRoleEntries, RADIUS_ROLES, CONTROL_HEIGHT_ROLES, ICON_SIZE_ROLES, INSET_STACK_ROLES, Z_INDEX_ROLES, MOTION_DURATION_ROLES, FONT_FAMILY_ROLES, TYPOGRAPHY_ROLES, TYPOGRAPHY_FIELDS, COLOR_ROLES, SHADOW_COMPOSITE_ROLES, } from "./semantic.js";
|
|
7
|
+
export type { ReferenceRecipe, ReferenceTokens, ReferenceBuild, Derivation, ReferenceSourceKind, ShadowLevel, ShadowShape, } from "./reference.js";
|
|
8
|
+
export { buildReference, allReferenceRecipes, evaluateDerivation, seedRefsOf, sourceKindOf, formatDerivation, seedValueAt, RAMP_COLORS, BLACK_ALPHA, WHITE_ALPHA, RADIUS_FACTORS, FONT_SIZE_FACTORS, DURATION_FACTORS, SHADOW_LEVELS, FONT_FAMILY_KEYS, } from "./reference.js";
|
|
9
|
+
export { buildSemanticStructural, buildSemanticColor, semanticRoleEntries, RADIUS_ROLES, CONTROL_HEIGHT_ROLES, ICON_SIZE_ROLES, INSET_STACK_ROLES, Z_INDEX_ROLES, MOTION_DURATION_ROLES, MOTION_EASING_ROLES, SKELETON_SIZE_ROLES, LOADING_SIZE_ROLES, LAYOUT_GAP_ROLES, FONT_FAMILY_ROLES, TYPOGRAPHY_ROLES, TYPOGRAPHY_FIELDS, COLOR_ROLES, SHADOW_COMPOSITE_ROLES, } from "./semantic.js";
|
|
10
10
|
export type { SemanticRoleEntry, ColorRoleRefs, TypographyRole } from "./semantic.js";
|
|
11
11
|
export interface DerivedTokens {
|
|
12
12
|
/** 亮色全量 CSS 变量:--qw-ref-* ∪ --qw-sem-*(light 取值)。 */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Derivation } from "./reference.js";
|
|
2
2
|
import type { Seed } from "../schema.js";
|
|
3
|
-
/** Seed 拍平成 `--qw-seed-*` → CSS
|
|
3
|
+
/** Seed 拍平成 `--qw-seed-*` → CSS 值;T2 仍可包含校准值或标准常量。 */
|
|
4
4
|
export declare function seedCssVars(seed: Seed): Record<string, string>;
|
|
5
5
|
/** 一条 Derivation → 引用 `--qw-seed-*` 的 CSS 原生表达式。 */
|
|
6
6
|
export declare function derivationToCssExpr(d: Derivation): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Step } from "./oklch.js";
|
|
2
|
-
import { type T2OklchStep } from "../color-architecture.js";
|
|
2
|
+
import { type T1ColorKey, type T2OklchStep } from "../color-architecture.js";
|
|
3
3
|
import type { Seed } from "../schema.js";
|
|
4
4
|
/**
|
|
5
5
|
* T2 Reference(Primitive)派生 —— RFC 0001 §2.1,v3 声明式重构。
|
|
@@ -11,13 +11,27 @@ import type { Seed } from "../schema.js";
|
|
|
11
11
|
* 3. live CSS 生成(derive/live-css.ts,relative color / calc 表达式);
|
|
12
12
|
* 4. Token Studio 的派生公式展示(formatDerivation)。
|
|
13
13
|
*
|
|
14
|
-
* `seedRefs` 由 AST 自动推导(seedRefsOf
|
|
15
|
-
*
|
|
14
|
+
* `sourceKind` 与 `seedRefs` 由 AST 自动推导(sourceKindOf / seedRefsOf);
|
|
15
|
+
* Seed 来源类必须有血缘,标准常量与外部标准则记录来源/理由,不伪造 Seed。
|
|
16
16
|
* 颜色层对齐 Figma `Color/qw` 变量集合:
|
|
17
17
|
* - T1 Seed 为 12 个单色种子;
|
|
18
|
-
* - T2 Reference 为每个 seed 的 A5-A100 Alpha 通道、50-900 OKLCH 设计校准实色色阶、
|
|
18
|
+
* - T2 Reference 为每个 seed 的 A5-A100 Alpha 通道、50-900 OKLCH 设计校准实色色阶、
|
|
19
|
+
* base 引用,以及 RFC0012 批准的纯黑 standard-constant 数学端点。
|
|
20
|
+
* T2 Color 不接受其它零散补色或「色阶 × Alpha」组合。
|
|
19
21
|
*/
|
|
20
22
|
export type ShadowLevel = "sm" | "md" | "lg";
|
|
23
|
+
/**
|
|
24
|
+
* T2 Reference 的规范来源类型。
|
|
25
|
+
*
|
|
26
|
+
* DTCG 不要求 Reference 必须引用 Seed;它只规范 token、group 与 alias 的表达。
|
|
27
|
+
* qw-ui 用本字段补足跨 Figma / code 的血缘治理:
|
|
28
|
+
* - seed-alias:原样承接一个 T1;
|
|
29
|
+
* - seed-derived:通过确定公式从一个或多个 T1 生成;
|
|
30
|
+
* - design-calibrated:保留 T1 设计血缘,但 canonical 值由设计校准拍板;
|
|
31
|
+
* - standard-constant:机械标准或数学端点,不伪造 T1;
|
|
32
|
+
* - external-standard:来自外部平台/规范,由外部来源负责版本化。
|
|
33
|
+
*/
|
|
34
|
+
export type ReferenceSourceKind = "seed-alias" | "seed-derived" | "design-calibrated" | "standard-constant" | "external-standard";
|
|
21
35
|
export type Derivation =
|
|
22
36
|
/** 直通引用 Seed 字段(dimension/number/duration 字符串或数字)。 */
|
|
23
37
|
{
|
|
@@ -86,10 +100,16 @@ export type Derivation =
|
|
|
86
100
|
kind: "cubicBezier";
|
|
87
101
|
seedRef: string;
|
|
88
102
|
}
|
|
89
|
-
/**
|
|
103
|
+
/** canonical 常量(机械标准或数学端点,非主题生成参数)。 */
|
|
90
104
|
| {
|
|
91
105
|
kind: "literal";
|
|
92
|
-
value: string;
|
|
106
|
+
value: string | number;
|
|
107
|
+
}
|
|
108
|
+
/** UA-owned CSS environment value; preserved as an expression, never a guessed device length. */
|
|
109
|
+
| {
|
|
110
|
+
kind: "cssEnvironment";
|
|
111
|
+
name: `safe-area-inset-${"top" | "right" | "bottom" | "left"}`;
|
|
112
|
+
fallback: "0px";
|
|
93
113
|
}
|
|
94
114
|
/** 阴影档位:形状 = shadow.base × 档位比例,颜色 = alphaStep × 档位倍数。 */
|
|
95
115
|
| {
|
|
@@ -99,8 +119,14 @@ export type Derivation =
|
|
|
99
119
|
export interface ReferenceRecipe {
|
|
100
120
|
path: string[];
|
|
101
121
|
cssVar: string;
|
|
102
|
-
/**
|
|
122
|
+
/** 规范来源;决定 seedRefs 是否必须非空。 */
|
|
123
|
+
sourceKind: ReferenceSourceKind;
|
|
124
|
+
/** 由 derivation 自动推导的可选 Seed 依赖(点分路径),供可追溯性校验与血缘展示。 */
|
|
103
125
|
seedRefs: string[];
|
|
126
|
+
/** 标准、设计稿或外部规范的可读来源;非 Seed 来源类必填。 */
|
|
127
|
+
source?: string;
|
|
128
|
+
/** 为什么该值属于 T2 而不是 T1 的简短依据。 */
|
|
129
|
+
rationale?: string;
|
|
104
130
|
derivation: Derivation;
|
|
105
131
|
}
|
|
106
132
|
/** 拍平后的 CSS 变量映射:cssVar → 字符串值(--qw-ref-* 全集)。 */
|
|
@@ -125,6 +151,8 @@ export interface ReferenceBuild {
|
|
|
125
151
|
}
|
|
126
152
|
/** 按点分路径读 Seed 字段("size.spacing.step" → seed.size.spacing.step)。 */
|
|
127
153
|
export declare function seedValueAt(seed: Seed, dotted: string): unknown;
|
|
154
|
+
/** 从 Seed 颜色点分路径("color.brand")取 T1 键。 */
|
|
155
|
+
export declare function seedKeyOf(seedRef: string): T1ColorKey;
|
|
128
156
|
export declare function formatFontFamily(list: string[]): string;
|
|
129
157
|
/** 阴影档位系数:形状(offset/blur/spread 缩放)+ 颜色(alphaStep 倍数)。 */
|
|
130
158
|
export declare const SHADOW_LEVELS: Record<ShadowLevel, {
|
|
@@ -136,6 +164,8 @@ export declare const SHADOW_LEVELS: Record<ShadowLevel, {
|
|
|
136
164
|
export declare function evaluateDerivation(d: Derivation, seed: Seed): string;
|
|
137
165
|
/** Seed 依赖推导:AST 里出现的全部 Seed 点分路径。 */
|
|
138
166
|
export declare function seedRefsOf(d: Derivation): string[];
|
|
167
|
+
/** Derivation AST → 规范来源分类;作为 Figma/DTCG provenance 的唯一映射口。 */
|
|
168
|
+
export declare function sourceKindOf(d: Derivation): ReferenceSourceKind;
|
|
139
169
|
/** 人读派生公式(Token Studio 展示用)。 */
|
|
140
170
|
export declare function formatDerivation(d: Derivation): string;
|
|
141
171
|
export declare const RAMP_COLORS: readonly ["brand", "black", "white", "gray", "red", "orange", "yellow", "green", "cyan", "blue", "purple", "brown"];
|
|
@@ -149,18 +179,48 @@ export declare const WHITE_ALPHA: ReadonlyArray<readonly [string, number]>;
|
|
|
149
179
|
export declare function buildAlphaScaleRecipes(): ReferenceRecipe[];
|
|
150
180
|
/** 4. 间距刻度 = spacing.step × N (N=1..8)。 */
|
|
151
181
|
export declare function buildSpacingRecipes(): ReferenceRecipe[];
|
|
152
|
-
/** 圆角档位系数(sm/lg 从 base 派生;默认 base=8px → 4/8/14)。 */
|
|
182
|
+
/** 圆角档位系数(sm/lg/xl 从 base 派生;默认 base=8px → 4/8/14/16)。 */
|
|
153
183
|
export declare const RADIUS_FACTORS: {
|
|
154
184
|
readonly sm: 0.5;
|
|
155
185
|
readonly md: 1;
|
|
156
186
|
readonly lg: 1.75;
|
|
187
|
+
readonly xl: 2;
|
|
157
188
|
};
|
|
158
|
-
/** 5. 圆角刻度:sm/md/lg 由 radius.base 按系数派生,full 直通独立裁切基准。 */
|
|
189
|
+
/** 5. 圆角刻度:sm/md/lg/xl 由 radius.base 按系数派生,full 直通独立裁切基准。xl=2×base 对齐治理稿 Radius v2 的 T2 double。 */
|
|
159
190
|
export declare function buildRadiusRecipes(): ReferenceRecipe[];
|
|
191
|
+
/** Existing public placeholder geometry: font-relative text and calibrated media. */
|
|
192
|
+
export declare function buildPlaceholderSizeRecipes(): ReferenceRecipe[];
|
|
193
|
+
/** Loading logo boxes follow the independent existing public size contract. */
|
|
194
|
+
export declare function buildLoadingSizeRecipes(): ReferenceRecipe[];
|
|
160
195
|
/** 6. 控件/图标尺寸:md = base 直通,sm/lg = base ∓ spacing.step × n(控件 ×2、图标 ×1)。 */
|
|
161
196
|
export declare function buildControlIconSizeRecipes(): ReferenceRecipe[];
|
|
162
|
-
/**
|
|
163
|
-
export declare
|
|
197
|
+
/** 描边宽度梯度系数(Figma Stroke v1:Half/Base/Double/Triple = 0.5/1/2/3)。 */
|
|
198
|
+
export declare const STROKE_WIDTH_FACTORS: {
|
|
199
|
+
readonly half: 0.5;
|
|
200
|
+
readonly double: 2;
|
|
201
|
+
readonly triple: 3;
|
|
202
|
+
};
|
|
203
|
+
/** 7. 描边宽度(Figma Stroke v1):base 直通 Seed,half/double/triple 按系数派生。 */
|
|
204
|
+
export declare function buildStrokeWidthRecipes(): ReferenceRecipe[];
|
|
205
|
+
/** 六档动作控件高度(Figma Action Control v1):现有公开尺寸契约,不能由单一 T1 Base 可靠派生,直接定义在 T2(T1 不设 Control Size)。 */
|
|
206
|
+
export declare const ACTION_CONTROL_HEIGHTS: {
|
|
207
|
+
readonly "2xs": 24;
|
|
208
|
+
readonly xs: 28;
|
|
209
|
+
readonly sm: 32;
|
|
210
|
+
readonly md: 36;
|
|
211
|
+
readonly lg: 42;
|
|
212
|
+
readonly xl: 50;
|
|
213
|
+
};
|
|
214
|
+
/** 7b. 动作控件尺寸:六档高度 + 2XS 图标特例(Square 复用同档 Height,不另设 token)。 */
|
|
215
|
+
export declare function buildActionControlRecipes(): ReferenceRecipe[];
|
|
216
|
+
/** Avatar 三档直径(Figma 头像 · Avatar S/M/L = 40/50/58)。 */
|
|
217
|
+
export declare const AVATAR_DIAMETERS: {
|
|
218
|
+
readonly sm: 40;
|
|
219
|
+
readonly md: 50;
|
|
220
|
+
readonly lg: 58;
|
|
221
|
+
};
|
|
222
|
+
/** 7c. 展示类专用尺寸:Avatar 直径(Icon Size 规范要求 Avatar 直径使用自己的语义,禁止借用 Icon/Control 刻度)。 */
|
|
223
|
+
export declare function buildAvatarDiameterRecipes(): ReferenceRecipe[];
|
|
164
224
|
/** 8. 行高(typography 类目):normal 直通 Seed,tight/relaxed = base ∓ 0.25。 */
|
|
165
225
|
export declare function buildLineHeightRecipes(): ReferenceRecipe[];
|
|
166
226
|
/** 9. 禁用态不透明度 —— 直通引用。 */
|
|
@@ -168,9 +228,9 @@ export declare function buildOpacityRecipes(): ReferenceRecipe[];
|
|
|
168
228
|
/** 10. 层级刻度 = zIndex.step × N (N=1..4);角色分配交给 Semantic 层。 */
|
|
169
229
|
export declare function buildZIndexRecipes(): ReferenceRecipe[];
|
|
170
230
|
export declare const FONT_FAMILY_KEYS: readonly ["text", "number", "code", "textMacLatin", "textMacZh", "textMacJa", "textWindowsLatin", "textWindowsZh", "textWindowsJa"];
|
|
171
|
-
/** 字号档位倍数(沿用既定视觉:14px 基准 → 12/16/20/24)。 */
|
|
231
|
+
/** 字号档位倍数(沿用既定视觉:14px 基准 → 11/12/16/20/24;xs=11 对齐治理稿 T2 Font Size 2XS)。 */
|
|
172
232
|
export declare const FONT_SIZE_FACTORS: Record<string, number>;
|
|
173
|
-
/** 11.
|
|
233
|
+
/** 11. 排版原子:字体族来自平台 Seed;字重是机械标准常量;字号按既定倍数派生。 */
|
|
174
234
|
export declare function buildTypographyRecipes(): ReferenceRecipe[];
|
|
175
235
|
/** 动效时长档位倍数。 */
|
|
176
236
|
export declare const DURATION_FACTORS: {
|
|
@@ -14,6 +14,23 @@ export type SemanticMode = "light" | "dark";
|
|
|
14
14
|
export declare const RADIUS_ROLES: Record<string, string>;
|
|
15
15
|
export declare const CONTROL_HEIGHT_ROLES: Record<string, string>;
|
|
16
16
|
export declare const ICON_SIZE_ROLES: Record<string, string>;
|
|
17
|
+
export declare const ACTION_CONTROL_HEIGHT_ROLES: Record<string, string>;
|
|
18
|
+
export declare const ACTION_CONTROL_PADDING_INLINE_ROLES: Record<string, string>;
|
|
19
|
+
export declare const ACTION_CONTROL_ICON_ROLES: Record<string, string>;
|
|
20
|
+
export declare const ACTION_CONTROL_GAP_ROLES: Record<string, string>;
|
|
21
|
+
export declare const BORDER_WIDTH_ROLES: Record<string, string>;
|
|
22
|
+
export declare const DIVIDER_WIDTH_ROLES: Record<string, string>;
|
|
23
|
+
export declare const FOCUS_RING_ROLES: Record<string, string>;
|
|
24
|
+
export declare const INDICATOR_ROLES: Record<string, string>;
|
|
25
|
+
/** 展示类专用尺寸:Avatar 直径三档(Figma 头像 S/M/L)。 */
|
|
26
|
+
export declare const AVATAR_DIAMETER_ROLES: Record<string, string>;
|
|
27
|
+
/** Independent placeholder roles reference T2 directly, never other T3 roles. */
|
|
28
|
+
export declare const SKELETON_SIZE_ROLES: Record<string, string>;
|
|
29
|
+
export declare const MOTION_EASING_ROLES: Record<string, string>;
|
|
30
|
+
export declare const LOADING_SIZE_ROLES: Record<string, string>;
|
|
31
|
+
export declare const LAYOUT_GAP_ROLES: Record<string, string>;
|
|
32
|
+
export declare const SAFE_AREA_INSET_ROLES: Record<string, string>;
|
|
33
|
+
export declare const SAFE_AREA_MINIMUM_ROLES: Record<string, string>;
|
|
17
34
|
export declare const INSET_STACK_ROLES: Record<string, string>;
|
|
18
35
|
export declare const Z_INDEX_ROLES: Record<string, string>;
|
|
19
36
|
export declare const MOTION_DURATION_ROLES: Record<string, string>;
|
|
@@ -33,8 +50,14 @@ export interface ColorRoleRefs {
|
|
|
33
50
|
light: string;
|
|
34
51
|
dark: string;
|
|
35
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* 颜色角色的 Semantic 变量路径:绝大多数角色落在 `--qw-sem-color-*` 下;
|
|
55
|
+
* `effect.shadow.*.color` 是复合阴影的颜色分量,对应 Figma 变量
|
|
56
|
+
* `--qw-sem-effect-shadow-*-color`,不带 `color-` 前缀。
|
|
57
|
+
*/
|
|
58
|
+
export declare function colorRoleSemPath(role: string): string[];
|
|
36
59
|
export declare const COLOR_ROLES: Record<string, ColorRoleRefs>;
|
|
37
|
-
/** 复合阴影角色:形状取 Reference effect.shadow.<level
|
|
60
|
+
/** 复合阴影角色:形状取 Reference effect.shadow.<level>,颜色取各自的 effect.shadow.<role>.color 分量。 */
|
|
38
61
|
export declare const SHADOW_COMPOSITE_ROLES: Record<string, ShadowLevel>;
|
|
39
62
|
export type SemanticRoleEntry = {
|
|
40
63
|
kind: "structural";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tailwind v4 适配器 —— dist/tailwind.css 的生成引擎。
|
|
3
|
+
*
|
|
4
|
+
* 把 T3 Semantic 变量映射进 Tailwind v4 的 @theme 命名空间,让工具类
|
|
5
|
+
* (bg-surface-base / text-content-primary / rounded-control / p-inset-md …)
|
|
6
|
+
* 直接吃组件库 token。只映射 T3(--qw-sem-*),--qw-ref-* 永不出现在产物里。
|
|
7
|
+
*
|
|
8
|
+
* 必须用 `@theme inline`:值是对外部变量的引用时,inline 让工具类直接内联
|
|
9
|
+
* var(--qw-sem-*),在使用元素处求值——子树级 [data-qw-mode="dark"] 覆盖才能
|
|
10
|
+
* 生效;非 inline 会在 :root 处解析一次,子树暗色失效。
|
|
11
|
+
*
|
|
12
|
+
* 映射规则(确定性,token 变了产物自动跟):
|
|
13
|
+
* - --qw-sem-color-<x> → --color-<x>
|
|
14
|
+
* - --qw-sem-size-radius-<x> → --radius-<x>
|
|
15
|
+
* - --qw-sem-size-inset-<x> → --spacing-inset-<x>
|
|
16
|
+
* - --qw-sem-size-stack-<x> → --spacing-stack-<x>
|
|
17
|
+
* - --qw-sem-typography-font-family-<x> → --font-<x>
|
|
18
|
+
* - --qw-sem-effect-shadow-<x> → --shadow-<x>
|
|
19
|
+
* - --qw-sem-motion-easing-<x> → --ease-<x>
|
|
20
|
+
*
|
|
21
|
+
* 其余子族(size 的 control-height/icon 等、typography 角色组、motion duration)
|
|
22
|
+
* 无对应 Tailwind 主题命名空间,不映射,消费方直接用 var(--qw-sem-*)。
|
|
23
|
+
* effect 的 shadow-<x>-color 是复合阴影的颜色通道,不是 box-shadow 值,同样不映射。
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* 从 derive() 的 flat 变量映射(light 即可——变量名亮暗一致)挑出可映射的
|
|
27
|
+
* T3 token,产出 Tailwind @theme 变量 → `var(--qw-sem-*)` 引用表。
|
|
28
|
+
*/
|
|
29
|
+
export declare function tailwindThemeVars(flat: Record<string, string>): Record<string, string>;
|
|
30
|
+
/** 组装 dist/tailwind.css 文本(消费方需先引入 tokens.css 提供 --qw-sem-* 取值)。 */
|
|
31
|
+
export declare function buildTailwindCss(flat: Record<string, string>): string;
|
package/dist/design-doc.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export declare function buildReferenceDesignDoc(): Json;
|
|
|
5
5
|
export declare function buildSemanticDesignDoc(): Json;
|
|
6
6
|
/** 生成 design/semantic.color.tokens.json(light/dark 合并视图)。 */
|
|
7
7
|
export declare function buildSemanticColorDesignDoc(): Json;
|
|
8
|
-
/**
|
|
8
|
+
/** 生成文件的文件名 → 生成器映射,供导出脚本与 parity 测试共用。 */
|
|
9
9
|
export declare const GENERATED_DESIGN_DOCS: Record<string, () => Json>;
|
|
10
10
|
export {};
|
|
@@ -10,5 +10,7 @@ export interface FigmaColorTokenValidationResult {
|
|
|
10
10
|
t3: number;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
+
/** T3 角色全集(qw 路径),由 FIGMA_T3_COLOR_ROLES 投影。 */
|
|
14
|
+
export declare function figmaT3RolePaths(): string[];
|
|
13
15
|
export declare function validateFigmaColorTokens(doc: unknown): FigmaColorTokenValidationResult;
|
|
14
16
|
export declare function assertFigmaColorTokens(doc: unknown): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,10 @@ export { hexToSeedColor, seedColorToHex, seedColorToCss } from "./color.js";
|
|
|
5
5
|
export type { SeedColorValue } from "./color.js";
|
|
6
6
|
export { FIGMA_COLOR_COLLECTION, FIGMA_COLOR_PREFIX, FIGMA_T1_SEED_HEX, FIGMA_T2_SOLID_SCALE, FIGMA_T3_COLOR_ROLES, T1_COLOR_KEYS, T2_ALPHA_KEYS, T2_ALPHA_STEPS, T2_OKLCH_STEPS, } from "./color-architecture.js";
|
|
7
7
|
export type { T1ColorKey, T2AlphaKey, T2AlphaStep, T2OklchStep } from "./color-architecture.js";
|
|
8
|
-
export { derive, toVar, ramp, STEPS, L_TARGETS, contrastRatio, buildReference, allReferenceRecipes, evaluateDerivation, formatDerivation, seedRefsOf, seedValueAt, buildSemanticStructural, buildSemanticColor, semanticRoleEntries, RAMP_COLORS, COLOR_ROLES, TYPOGRAPHY_ROLES, SHADOW_COMPOSITE_ROLES, } from "./derive/index.js";
|
|
9
|
-
export type { DerivedTokens, Mode, Layer, Step, Ramp, ReferenceRecipe, ReferenceBuild, ReferenceTokens, Derivation, SemanticRoleEntry, ColorRoleRefs, } from "./derive/index.js";
|
|
8
|
+
export { derive, toVar, ramp, STEPS, L_TARGETS, contrastRatio, buildReference, allReferenceRecipes, evaluateDerivation, formatDerivation, seedRefsOf, sourceKindOf, seedValueAt, buildSemanticStructural, buildSemanticColor, semanticRoleEntries, RAMP_COLORS, COLOR_ROLES, TYPOGRAPHY_ROLES, SHADOW_COMPOSITE_ROLES, } from "./derive/index.js";
|
|
9
|
+
export type { DerivedTokens, Mode, Layer, Step, Ramp, ReferenceRecipe, ReferenceBuild, ReferenceTokens, Derivation, ReferenceSourceKind, SemanticRoleEntry, ColorRoleRefs, } from "./derive/index.js";
|
|
10
10
|
export { buildLiveCss, seedCssVars, derivationToCssExpr } from "./derive/live-css.js";
|
|
11
11
|
export type { LiveCssOptions } from "./derive/live-css.js";
|
|
12
|
-
export {
|
|
13
|
-
export
|
|
12
|
+
export { buildFigmaColorSnapshot } from "./figma/color-snapshot.js";
|
|
13
|
+
export { validateFigmaColorTokens, assertFigmaColorTokens, figmaT3RolePaths, } from "./figma/color-contract.js";
|
|
14
|
+
export type { FigmaColorTokenValidationResult } from "./figma/color-contract.js";
|