Loading...
Loading...
Compare original and translation side by side
| Category | Rule File | Impact | When to Use |
|---|---|---|---|
| W3C Token Format | | CRITICAL | Creating or reading |
| Contrast Enforcement | | CRITICAL | Validating WCAG contrast at token definition time |
| Three-Tier Hierarchy | | HIGH | Organizing tokens into global/alias/component layers |
| OKLCH Color Space | | HIGH | Defining colors with perceptual uniformity |
| Spacing & Depth | | HIGH | Defining elevation shadows and spacing scales as tokens |
| Style Dictionary | | HIGH | Transforming tokens to CSS/Tailwind/iOS/Android |
| Theming & Dark Mode | | HIGH | Implementing theme switching and dark mode |
| Versioning | | HIGH | Evolving tokens without breaking consumers |
| 类别 | 规则文件 | 重要程度 | 适用场景 |
|---|---|---|---|
| W3C令牌格式 | | 关键 | 创建或读取 |
| 对比度强制校验 | | 关键 | 在令牌定义阶段验证WCAG对比度时 |
| 三级令牌层级 | | 高 | 将令牌组织为全局/别名/组件层级时 |
| OKLCH色彩空间 | | 高 | 定义具有感知一致性的颜色时 |
| 间距与层级 | | 高 | 将层级阴影和间距尺度定义为令牌时 |
| Style Dictionary | | 高 | 将令牌转换为CSS/Tailwind/iOS/Android格式时 |
| 主题与暗色模式 | | 高 | 实现主题切换与暗色模式时 |
| 版本管理 | | 高 | 在不影响消费者的前提下迭代令牌时 |
.tokens.json{
"color": {
"primary": {
"50": {
"$type": "color",
"$value": "oklch(0.97 0.01 250)",
"$description": "Lightest primary shade"
},
"500": {
"$type": "color",
"$value": "oklch(0.55 0.18 250)",
"$description": "Base primary"
},
"900": {
"$type": "color",
"$value": "oklch(0.25 0.10 250)",
"$description": "Darkest primary shade"
}
}
},
"spacing": {
"sm": {
"$type": "dimension",
"$value": "8px"
},
"md": {
"$type": "dimension",
"$value": "16px"
},
"lg": {
"$type": "dimension",
"$value": "24px"
}
}
}.tokens.json{
"color": {
"primary": {
"50": {
"$type": "color",
"$value": "oklch(0.97 0.01 250)",
"$description": "Lightest primary shade"
},
"500": {
"$type": "color",
"$value": "oklch(0.55 0.18 250)",
"$description": "Base primary"
},
"900": {
"$type": "color",
"$value": "oklch(0.25 0.10 250)",
"$description": "Darkest primary shade"
}
}
},
"spacing": {
"sm": {
"$type": "dimension",
"$value": "8px"
},
"md": {
"$type": "dimension",
"$value": "16px"
},
"lg": {
"$type": "dimension",
"$value": "24px"
}
}
}| Tier | Purpose | Example |
|---|---|---|
| Global | Raw values | |
| Alias | Semantic meaning | |
| Component | Scoped usage | |
{
"color": {
"blue": {
"500": { "$type": "color", "$value": "oklch(0.55 0.18 250)" }
},
"primary": { "$type": "color", "$value": "{color.blue.500}" },
"action": {
"default": { "$type": "color", "$value": "{color.primary}" }
}
}
}| 层级 | 用途 | 示例 |
|---|---|---|
| 全局 | 原始值 | |
| 别名 | 语义化命名 | |
| 组件 | 作用域化使用 | |
{
"color": {
"blue": {
"500": { "$type": "color", "$value": "oklch(0.55 0.18 250)" }
},
"primary": { "$type": "color", "$value": "{color.blue.500}" },
"action": {
"default": { "$type": "color", "$value": "{color.primary}" }
}
}
}hsl(60, 100%, 50%)hsl(240, 100%, 50%)/* OKLCH: L (0-1 lightness), C (0-0.4 chroma/saturation), H (0-360 hue) */
--color-primary: oklch(0.55 0.18 250);
--color-primary-hover: oklch(0.50 0.18 250); /* Just reduce L for darker */hsl(60, 100%, 50%)hsl(240, 100%, 50%)/* OKLCH: L(0-1明度)、C(0-0.4色度/饱和度)、H(0-360色相) */
--color-primary: oklch(0.55 0.18 250);
--color-primary-hover: oklch(0.50 0.18 250); /* 仅降低L值实现深色效果 */config.jsonrules/tokens-style-dictionary.mdconfig.jsonrules/tokens-style-dictionary.md:root {
--color-surface: oklch(0.99 0.00 0);
--color-on-surface: oklch(0.15 0.00 0);
}
[data-theme="dark"] {
--color-surface: oklch(0.15 0.00 0);
--color-on-surface: oklch(0.95 0.00 0);
}rules/tokens-theming-darkmode.md:root {
--color-surface: oklch(0.99 0.00 0);
--color-on-surface: oklch(0.15 0.00 0);
}
[data-theme="dark"] {
--color-surface: oklch(0.15 0.00 0);
--color-on-surface: oklch(0.95 0.00 0);
}rules/tokens-theming-darkmode.md{
"color": {
"brand": {
"$type": "color",
"$value": "oklch(0.55 0.18 250)",
"$extensions": {
"com.tokens.deprecated": {
"since": "2.0.0",
"replacement": "color.primary.500",
"removal": "3.0.0"
}
}
}
}
}rules/tokens-versioning.md{
"color": {
"brand": {
"$type": "color",
"$value": "oklch(0.55 0.18 250)",
"$extensions": {
"com.tokens.deprecated": {
"since": "2.0.0",
"replacement": "color.primary.500",
"removal": "3.0.0"
}
}
}
}
}rules/tokens-versioning.md| Decision | Recommendation |
|---|---|
| Token format | W3C DTCG |
| Color space | OKLCH for perceptual uniformity |
| Hierarchy | Three-tier: global, alias, component |
| Build tool | Style Dictionary 4.x with W3C parser |
| Theming | CSS custom properties with |
| Token references | Use |
| 决策项 | 推荐方案 |
|---|---|
| 令牌格式 | 带 |
| 色彩空间 | 采用OKLCH以实现感知一致性 |
| 层级结构 | 三级:全局、别名、组件 |
| 构建工具 | 带W3C解析器的Style Dictionary 4.x |
| 主题配置 | 结合 |
| 令牌引用 | 使用 |
#hex16px$type#hex16px$type| Resource | Description |
|---|---|
| references/w3c-token-spec.md | W3C DTCG specification overview |
| references/style-dictionary-config.md | Style Dictionary 4.x configuration guide |
| references/token-naming-conventions.md | Naming patterns and conventions |
| 资源 | 描述 |
|---|---|
| references/w3c-token-spec.md | W3C DTCG规范概述 |
| references/style-dictionary-config.md | Style Dictionary 4.x配置指南 |
| references/token-naming-conventions.md | 命名模式与规范 |
design-system-architectfrontend-ui-developeraccessibilitydesign-system-architectfrontend-ui-developeraccessibilityork:ui-componentsork:accessibilityork:responsive-patternsork:figma-design-handoffork:ui-componentsork:accessibilityork:responsive-patternsork:figma-design-handoff