@earendil-works/design-tokens

中文文档
0.1.0发布于 2026/11/05ISC零依赖近 30 天下载 1.2万

W3C DTCG design tokens powered by Terrazzo.

原始使用文档
文档目录4 节
  1. Use
  2. Develop
  3. Output
  4. Guides

Design Tokens

@earendil-works/design-tokens provides shared and brand-specific W3C DTCG tokens, built with Terrazzo.

Use

npm install @earendil-works/design-tokens

Import exactly one brand stylesheet:

@import '@earendil-works/design-tokens/radius.css';

Other entry points: pi.css, earendil.css, lefos.css, elanor.css.

Light semantic colors are the default. Dark overrides apply automatically through prefers-color-scheme: dark.

To check your CSS against the tokens, use the Stylelint plugin. It rejects hardcoded values and unknown custom properties, checks that tokens suit their CSS properties, and requires semantic tokens outside foundation files.

Develop

Run commands from the repository root.

pnpm tokens:generate       # Compile recipes into primitive tokens
pnpm tokens:check          # Type-check tooling, check generation, validate tokens
pnpm tokens:check:contrast # Check semantic color contrast only
pnpm tokens:build          # Build all brands

For one brand, use pnpm tokens:build:radius, pnpm tokens:build:pi, pnpm tokens:build:earendil, pnpm tokens:build:lefos, or pnpm tokens:build:elanor.

Edit recipes, not generated values. Shared settings live in generation/config.json; recipe paths mirror their output under tokens/.

tokens:check checks for stale generated sources, validates tokens and resolvers against DTCG 2025.10, checks required resting-state contrast pairs, and runs Terrazzo's cross-file checks for every brand. The root pnpm check includes these checks.

Validation uses the vendored DTCG schemas offline. To refresh them, run pnpm tokens:schemas:update, then review and commit the schemas and checksum manifest together. See the schema notice for provenance and licensing.

Output

Each dist/<brand>/ contains:

  • tokens.css: primitives, mode-independent semantics, and light semantic colors under :root with color-scheme: light dark; dark semantic.color.* overrides in prefers-color-scheme: dark.
  • tokens.catalog.json: CSS custom properties with resolved CSS/DTCG values and alias targets with every modifier at its default context, the values that differ per modifier context (such as contexts.colorScheme.dark), each modifier's contexts and how the CSS switches them on, and $extensions (including print builds). Exported as @earendil-works/design-tokens/<brand>.catalog.json for linting and build tools.
  • Figma-compatible JSON from terrazzo-plugin-figma-json.

Guides

版本与发布记录

@earendil-works/design-tokens 共发布 2 个版本,首次发布于 2026/11/05;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.1.0latest2026/11/058 天前
0.0.0-stage2026/11/058 天前

关于 @earendil-works/design-tokens 的常见问题

@earendil-works/design-tokens 是什么?

W3C DTCG design tokens powered by Terrazzo.

如何安装 @earendil-works/design-tokens?

在项目目录运行 npm install @earendil-works/design-tokens,或使用 pnpm add / yarn add / bun add。

@earendil-works/design-tokens 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/earendil-works__design-tokens 是否存在。

@earendil-works/design-tokens 可以商用吗?

@earendil-works/design-tokens 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@earendil-works/design-tokens 的下载量有多少?

根据 npm 官方下载统计,@earendil-works/design-tokens 在 2026/10/13 – 2026/11/11 这 30 天内被下载 11,600 次,日均约 387 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@earendil-works/design-tokens 还在维护吗?

最新版本 0.1.0 发布于 2026/11/05(8 天前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/11/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。