@eocrm/design-tokens

中文文档
0.8.16发布于 2026/11/13Apache-2.0ES Module零依赖构建来源已验证近 30 天下载 4798

Shared EOCRM visual tokens for web and Kotlin Multiplatform/Compose. The npm package contains generated Sass; the Maven artifact contains a generated, strongly typed Compose API. Both are published with the same version as @eocrm/design-system.

原始使用文档
文档目录5 节
  1. Web
  2. Kotlin Multiplatform and Compose
  3. Accents
  4. Contributing
  5. License

@eocrm/design-tokens

Shared EOCRM visual tokens for web and Kotlin Multiplatform/Compose. The npm package contains generated Sass; the Maven artifact contains a generated, strongly typed Compose API. Both are published with the same version as @eocrm/design-system.

Live playground (tokens and components, rendered from main): https://eocrm.github.io/design-system/

Web

The package is public on npmjs (no .npmrc or token needed):

npm install @eocrm/design-tokens

Import the light/theme-neutral contract and dark-theme overrides:

@use '@eocrm/design-tokens/styles/tokens.scss';
@use '@eocrm/design-tokens/styles/dark.scss';

React consumers import the compiled @eocrm/design-system/styles/global.css (or tokens.css) and do not need this package; install it for Sass variables or the contract directly.

Kotlin Multiplatform and Compose

GitHub Packages requires authentication even for public Maven packages. For local development, use a classic personal access token with read:packages; keep gpr.user and gpr.key in your user-level ~/.gradle/gradle.properties, not in a repository. In GitHub Actions, grant the consuming repository access to the package and use the workflow's GITHUB_TOKEN.

repositories {
    maven {
        url = uri("https://maven.pkg.github.com/eocrm/design-system")
        credentials {
            username = providers.gradleProperty("gpr.user").orNull
            password = providers.gradleProperty("gpr.key").orNull
        }
    }
}

dependencies {
    commonMainImplementation("com.eocrm.design:design-tokens-compose:1.2.3")
}

Use the generated theme objects directly:

import com.eocrm.design.tokens.EocrmDarkTokens
import com.eocrm.design.tokens.EocrmLightTokens

val background = EocrmLightTokens.colors.background
val darkBackground = EocrmDarkTokens.colors.background
val spacing = EocrmLightTokens.dimensions.space4

The artifact supports JVM, Android, iOS device (iosArm64), and Apple Silicon iOS simulator (iosSimulatorArm64). It intentionally does not publish an Intel iosX64 target.

Accents

tokens.json may have a root accents key: { "<name>": { "<tokenId>": { "light": "#rrggbb", "dark": "#rrggbb" } } }. Each accent emits a [data-accent='<name>'] block overriding those tokens in every theme block (light, forced dark, OS dark), and a Compose Eocrm<Name>LightTokens / Eocrm<Name>DarkTokens pair. The validator rejects:

  • unknown-accent-token — the token id does not exist
  • accent-non-color — the token is not a colour
  • accent-unthemed — the base token is not light/dark themed
  • accent-alias — the value is an alias instead of a colour
  • invalid-token-value — a malformed colour

Contributing

src/tokens.json is the only editable source of token values. Do not edit anything under generated/ or generated Kotlin files under compose/src/commonMain; regeneration replaces them.

npm run tokens:validate
npm run tokens:generate
npm run tokens:test
npm run tokens:check
packages/design-tokens/compose/gradlew --no-daemon -p packages/design-tokens/compose jvmTest assemble

Commit generated outputs alongside source changes. tokens:check validates the schema and semantic contract, runs tests, and fails on generated drift.

See Shared design ownership for the boundary between neutral tokens, React components, Compose product UI, and native platform behavior.

License

Apache License 2.0.

版本与发布记录

@eocrm/design-tokens 共发布 27 个版本,首次发布于 2026/11/02;过去 12 个月发布了 27 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.8.16latest2026/11/13今天
0.8.152026/11/13今天
0.8.142026/11/13今天
0.8.132026/11/113 天前
0.8.122026/11/113 天前
0.8.112026/11/094 天前

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

@eocrm/design-tokens 是什么?

Shared EOCRM visual tokens for web and Kotlin Multiplatform/Compose. The npm package contains generated Sass; the Maven artifact contains a generated, strongly typed Compose API. Both are published with the same version as @eocrm/design-system.

如何安装 @eocrm/design-tokens?

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

@eocrm/design-tokens 支持 TypeScript 吗?

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

@eocrm/design-tokens 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@eocrm/design-tokens 可以商用吗?

@eocrm/design-tokens 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

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

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

@eocrm/design-tokens 还在维护吗?

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