@campfire-interactive/design-tokens

中文文档
0.7.5发布于 2026/11/03零依赖近 30 天下载 1823

Shared design tokens for Campfire Suite — raw scales, semantic roles, per-app accent hooks, and an opt-in dark theme

原始使用文档
文档目录6 节
  1. ⚠ 0.2.x is a rewrite, and adoption is not open yet
  2. Install
  3. The three layers, and which one to reference
  4. Two colors, two jobs
  5. Dark mode is opt-in
  6. Status colors

@campfire-interactive/design-tokens

The source of truth for every shared value in the Campfire Suite — colors, type, spacing, radii, shadows, motion, z-index, chart series and chrome dimensions — as CSS custom properties under a --cfi- prefix.

tokens.css is the source; tokens.json is generated from it by scripts/generate.mjs and resolves the var(--cfi-app-*, fallback) chains to literals for non-CSS consumers.

⚠ 0.2.x is a rewrite, and adoption is not open yet

0.1.1 had 42 tokens. 0.2.0 has 148, in three layers, with an opt-in dark theme. The semantic naming is not settled until more than one app has migrated onto it, so treat these names as movable.

One name already moved: the orange ramp is --cfi-color-orange-*, renamed from --cfi-color-primary-*. Raw scales in this file are named by hue, so a role word in a palette slot read as "the primary color" — which is how buttons ended up wired to it. It is master-data's and pim's app-identity color. The color of anything you press is --cfi-action.

Three published packages still reference the old name with literal fallbacks (shell-header, side-nav, volume-intelligence-ui), and that is deliberate: with the token gone they keep rendering their own literals, which is exactly what they render today. No alias is provided, because an alias would resolve volume-intelligence-ui's blue buttons to orange the moment an app imports this file.

^0.1.1 does not resolve to 0.2.0 — a caret below 1.0 never crosses a minor — so nothing picks this up by accident. Bumping to ^0.2.0 is a deliberate act, and the gate for it is in the repo's CLAUDE.md.

Install

npm i @campfire-interactive/design-tokens
// once, at the app entry point, BEFORE the app's own stylesheets
import '@campfire-interactive/design-tokens/tokens.css';

Declaring the dependency does nothing on its own. It was a dependency of eleven frontends and imported by none of them; the --cfi-* variables reached those pages only because shell-header and side-nav bundle their own use of them. Import the stylesheet, or the tokens are not there.

The three layers, and which one to reference

  1. Raw scales — --cfi-color-gray-500, --cfi-font-size-sm. Palette values. Reference these only when defining a semantic token.
  2. Semantic roles — --cfi-surface, --cfi-content-muted, --cfi-border, --cfi-action, the focus ring, the overlay. This is what component CSS should use. A component that reaches past these into a raw gray cannot be re-themed and breaks in dark mode.
  3. App overrides — --cfi-app-primary and friends. The app's own identity color, for the shell badge. Set these in the consuming app.

Two colors, two jobs

--cfi-action is the suite-wide color for anything you press — buttons, links, focus rings, selected rows. Its value is omsf's #030213, because omsf is the reference for main styles. It is identical in every app; that is the point of it.

--cfi-app-primary is the app's identity color, and its only job is the app badge in the shell header plus its tile in the app switcher. The canonical value per app is the color field in shell-header's appCatalog.

Do not point one at the other. Wiring buttons to the app color makes the same primary button violet in one app, sky blue in another and indigo in a third — the opposite of a design system.

Dark mode is opt-in

<html data-theme="dark">          <!-- explicit -->
<html class="cfi-theme-auto">     <!-- follow the OS -->

Neither happens by accident, so adding this file to an app that has never considered dark mode cannot change how it looks today.

Status colors

Each semantic hue carries a -soft background and a -text foreground that meets 4.5:1 against it. Use the pair. bg-[#10B981]/10 text-[#10B981] — the shape several apps had — lands near 2:1.

版本与发布记录

@campfire-interactive/design-tokens 共发布 12 个版本,首次发布于 2026/04/16;过去 12 个月发布了 12 个版本。

版本发布日期距今
0.7.5latest2026/11/037 天前
0.7.42026/11/037 天前
0.7.32026/11/027 天前
0.7.22026/10/3010 天前
0.7.12026/10/3010 天前
0.7.02026/10/3010 天前

关于 @campfire-interactive/design-tokens 的常见问题

@campfire-interactive/design-tokens 是什么?

Shared design tokens for Campfire Suite — raw scales, semantic roles, per-app accent hooks, and an opt-in dark theme

如何安装 @campfire-interactive/design-tokens?

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

@campfire-interactive/design-tokens 支持 TypeScript 吗?

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

@campfire-interactive/design-tokens 可以商用吗?

@campfire-interactive/design-tokens 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@campfire-interactive/design-tokens 的下载量有多少?

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

@campfire-interactive/design-tokens 还在维护吗?

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