@qw-ui/tokens 0.3.0-next.40 → 0.3.0-next.43
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 -56
- package/dist/color-architecture.d.ts +28 -4
- package/dist/derive/index.d.ts +1 -1
- package/dist/derive/reference.d.ts +12 -1
- package/dist/derive/semantic.d.ts +7 -0
- package/dist/index.js +389 -247
- package/dist/index.js.map +1 -1
- package/dist/tailwind.css +6 -0
- package/dist/tokens.css +52 -1
- package/dist/tokens.json +96 -2
- package/dist/tokens.live.css +52 -1
- package/dist/tokens.ts +101 -7
- package/package.json +11 -29
package/README.md
CHANGED
|
@@ -1,79 +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(可选生成参数) ── alias / derive / calibrate ──► T2 Reference
|
|
11
|
-
│
|
|
12
|
-
▼
|
|
13
|
-
T3 Semantic (--qw-sem-*) → Component / Style
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
T2 是完整机械标尺,可来自 Seed、设计校准、标准常量或外部标准;每条都带 DTCG
|
|
17
|
-
provenance。T3 只引用 T2,组件与业务只碰 T3。
|
|
3
|
+
设计 Token 与主题。Design tokens and theme utilities for qw-ui.
|
|
18
4
|
|
|
19
5
|
## 安装
|
|
20
6
|
|
|
7
|
+
当前开发版本使用 `next`:
|
|
8
|
+
|
|
21
9
|
```bash
|
|
22
|
-
|
|
10
|
+
npm install @qw-ui/tokens@next
|
|
23
11
|
```
|
|
24
12
|
|
|
25
|
-
|
|
13
|
+
包发布于 [公共 npm](https://www.npmjs.com/package/@qw-ui/tokens)。如环境配置了其他镜像,可在安装命令后追加 `--registry=https://registry.npmjs.org/`。
|
|
26
14
|
|
|
27
15
|
## 最小示例
|
|
28
16
|
|
|
29
17
|
```ts
|
|
30
|
-
|
|
31
|
-
import
|
|
18
|
+
import '@qw-ui/tokens/tokens.css';
|
|
19
|
+
import { defaultSeed, derive } from '@qw-ui/tokens';
|
|
32
20
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// 3. TS 侧拿 token 路径类型 / 原始 JSON
|
|
37
|
-
import type { TokenPath } from "@qw-ui/tokens/token-paths";
|
|
38
|
-
import tokens from "@qw-ui/tokens/tokens.json" with { type: "json" };
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
CSS 里直接用变量:
|
|
42
|
-
|
|
43
|
-
```css
|
|
44
|
-
.card { color: var(--qw-sem-color-content-primary); background: var(--qw-sem-color-surface-base); }
|
|
21
|
+
const theme = derive(defaultSeed);
|
|
22
|
+
console.log(theme);
|
|
45
23
|
```
|
|
46
24
|
|
|
47
|
-
##
|
|
25
|
+
## 使用说明
|
|
48
26
|
|
|
49
|
-
|
|
50
|
-
|---|---|---|
|
|
51
|
-
| `tokens.css` | 默认静态变量,构建期固化 | 需整页换文件 |
|
|
52
|
-
| `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 为准。
|
|
53
28
|
|
|
54
|
-
|
|
29
|
+
## 兼容性
|
|
55
30
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
| 包 | 关系 |
|
|
59
|
-
|---|---|
|
|
60
|
-
| [@qw-ui/react](../react/README.md) / [@qw-ui/vue](../vue/README.md) | 消费 T3 token 渲染组件,需先引本包 CSS |
|
|
61
|
-
| [@qw-ui/theme-editor](../theme-editor/README.md) | 可视化编辑 Seed → 实时预览三层级联 |
|
|
62
|
-
| `@qw-ui/styles-core`(private,不发布) | vanilla-extract 样式事实源,只读本包 T3 token |
|
|
63
|
-
|
|
64
|
-
设计稿老色值 → T3 映射见 skill `qw-legacy-token-map`。
|
|
31
|
+
CSS 面向 Chrome 123 / iOS Safari 16.4。主题派生 API 可用于 Node 构建工具和浏览器。
|
|
65
32
|
|
|
66
33
|
## 版本通道
|
|
67
34
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
| `next`(预发布) | `pnpm add @qw-ui/tokens@next` | `release/next` 通道,高频自增 `x.y.z-next.N` |
|
|
72
|
-
|
|
73
|
-
9 个公开包 `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/*` 包应选择同批版本;内部运行时依赖由包管理器安装。
|
|
74
38
|
|
|
75
|
-
##
|
|
39
|
+
## 文档与许可证
|
|
76
40
|
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
41
|
+
- [组件文档与接入指南](https://qw-ui.qianwen.com/)
|
|
42
|
+
- [npm 版本列表](https://www.npmjs.com/package/@qw-ui/tokens?activeTab=versions)
|
|
43
|
+
- MIT,详见包内 `LICENSE`。
|
|
@@ -9,10 +9,18 @@ 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>>;
|
|
13
20
|
/**
|
|
14
|
-
* Figma「Color Token System
|
|
15
|
-
*
|
|
21
|
+
* Figma「Color Token System」既有角色及用户批准的本地补充角色。
|
|
22
|
+
* 既有角色与 Figma 节点 22258:49986 对齐;新角色等待 Figma 同步,不冒充已回流。
|
|
23
|
+
* light/dark 均引用 T2;`effect.shadow.*.color` 为复合阴影的颜色
|
|
16
24
|
* 分量(对应 Figma 变量 `--qw-sem-effect-shadow-*-color`)。
|
|
17
25
|
*/
|
|
18
26
|
export declare const FIGMA_T3_COLOR_ROLES: {
|
|
@@ -56,6 +64,10 @@ export declare const FIGMA_T3_COLOR_ROLES: {
|
|
|
56
64
|
readonly light: "color.gray.50";
|
|
57
65
|
readonly dark: "color.black.900";
|
|
58
66
|
};
|
|
67
|
+
readonly "content.danger": {
|
|
68
|
+
readonly light: "color.red.600";
|
|
69
|
+
readonly dark: "color.red.300";
|
|
70
|
+
};
|
|
59
71
|
readonly "content.primary": {
|
|
60
72
|
readonly light: "color.black.base";
|
|
61
73
|
readonly dark: "color.white.base";
|
|
@@ -96,6 +108,10 @@ export declare const FIGMA_T3_COLOR_ROLES: {
|
|
|
96
108
|
readonly light: "color.white.base";
|
|
97
109
|
readonly dark: "color.white.base";
|
|
98
110
|
};
|
|
111
|
+
readonly "content.on-brand": {
|
|
112
|
+
readonly light: "color.white.base";
|
|
113
|
+
readonly dark: "color.black.contrast-endpoint";
|
|
114
|
+
};
|
|
99
115
|
readonly "content.on-warning-subtle": {
|
|
100
116
|
readonly light: "color.yellow.800";
|
|
101
117
|
readonly dark: "color.yellow.200";
|
|
@@ -108,6 +124,10 @@ export declare const FIGMA_T3_COLOR_ROLES: {
|
|
|
108
124
|
readonly light: "color.gray.300";
|
|
109
125
|
readonly dark: "color.gray.600";
|
|
110
126
|
};
|
|
127
|
+
readonly "border.control": {
|
|
128
|
+
readonly light: "color.gray.600";
|
|
129
|
+
readonly dark: "color.gray.base";
|
|
130
|
+
};
|
|
111
131
|
readonly "border.focus": {
|
|
112
132
|
readonly light: "color.brand.base";
|
|
113
133
|
readonly dark: "color.brand.500";
|
|
@@ -169,8 +189,8 @@ export declare const FIGMA_T3_COLOR_ROLES: {
|
|
|
169
189
|
readonly dark: "color.blue.a20";
|
|
170
190
|
};
|
|
171
191
|
readonly "control-action.danger.default": {
|
|
172
|
-
readonly light: "color.red.
|
|
173
|
-
readonly dark: "color.red.
|
|
192
|
+
readonly light: "color.red.600";
|
|
193
|
+
readonly dark: "color.red.600";
|
|
174
194
|
};
|
|
175
195
|
readonly "control-action.danger.subtle": {
|
|
176
196
|
readonly light: "color.red.a10";
|
|
@@ -240,6 +260,10 @@ export declare const FIGMA_T3_COLOR_ROLES: {
|
|
|
240
260
|
readonly light: "color.black.a50";
|
|
241
261
|
readonly dark: "color.black.a50";
|
|
242
262
|
};
|
|
263
|
+
readonly "overlay.control-on-media": {
|
|
264
|
+
readonly light: "color.black.a50";
|
|
265
|
+
readonly dark: "color.white.a40";
|
|
266
|
+
};
|
|
243
267
|
readonly shadow: {
|
|
244
268
|
readonly light: "color.black.a10";
|
|
245
269
|
readonly dark: "color.black.a50";
|
package/dist/derive/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type { Step, Ramp } from "./oklch.js";
|
|
|
6
6
|
export type { SemanticMode as Mode } from "./semantic.js";
|
|
7
7
|
export type { ReferenceRecipe, ReferenceTokens, ReferenceBuild, Derivation, ReferenceSourceKind, ShadowLevel, ShadowShape, } from "./reference.js";
|
|
8
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, FONT_FAMILY_ROLES, TYPOGRAPHY_ROLES, TYPOGRAPHY_FIELDS, COLOR_ROLES, SHADOW_COMPOSITE_ROLES, } from "./semantic.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 取值)。 */
|
|
@@ -16,7 +16,8 @@ import type { Seed } from "../schema.js";
|
|
|
16
16
|
* 颜色层对齐 Figma `Color/qw` 变量集合:
|
|
17
17
|
* - T1 Seed 为 12 个单色种子;
|
|
18
18
|
* - T2 Reference 为每个 seed 的 A5-A100 Alpha 通道、50-900 OKLCH 设计校准实色色阶、
|
|
19
|
-
* base
|
|
19
|
+
* base 引用,以及 RFC0012 批准的纯黑 standard-constant 数学端点。
|
|
20
|
+
* T2 Color 不接受其它零散补色或「色阶 × Alpha」组合。
|
|
20
21
|
*/
|
|
21
22
|
export type ShadowLevel = "sm" | "md" | "lg";
|
|
22
23
|
/**
|
|
@@ -104,6 +105,12 @@ export type Derivation =
|
|
|
104
105
|
kind: "literal";
|
|
105
106
|
value: string | number;
|
|
106
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";
|
|
113
|
+
}
|
|
107
114
|
/** 阴影档位:形状 = shadow.base × 档位比例,颜色 = alphaStep × 档位倍数。 */
|
|
108
115
|
| {
|
|
109
116
|
kind: "shadowLayer";
|
|
@@ -181,6 +188,10 @@ export declare const RADIUS_FACTORS: {
|
|
|
181
188
|
};
|
|
182
189
|
/** 5. 圆角刻度:sm/md/lg/xl 由 radius.base 按系数派生,full 直通独立裁切基准。xl=2×base 对齐治理稿 Radius v2 的 T2 double。 */
|
|
183
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[];
|
|
184
195
|
/** 6. 控件/图标尺寸:md = base 直通,sm/lg = base ∓ spacing.step × n(控件 ×2、图标 ×1)。 */
|
|
185
196
|
export declare function buildControlIconSizeRecipes(): ReferenceRecipe[];
|
|
186
197
|
/** 描边宽度梯度系数(Figma Stroke v1:Half/Base/Double/Triple = 0.5/1/2/3)。 */
|
|
@@ -24,6 +24,13 @@ export declare const FOCUS_RING_ROLES: Record<string, string>;
|
|
|
24
24
|
export declare const INDICATOR_ROLES: Record<string, string>;
|
|
25
25
|
/** 展示类专用尺寸:Avatar 直径三档(Figma 头像 S/M/L)。 */
|
|
26
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>;
|
|
27
34
|
export declare const INSET_STACK_ROLES: Record<string, string>;
|
|
28
35
|
export declare const Z_INDEX_ROLES: Record<string, string>;
|
|
29
36
|
export declare const MOTION_DURATION_ROLES: Record<string, string>;
|