@nebutra/design-tokens 0.1.0
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/LICENSE +676 -0
- package/README.md +149 -0
- package/package.json +52 -0
- package/style-dictionary.config.mjs +697 -0
- package/tokens/core.json +207 -0
- package/tokens/semantic.json +86 -0
- package/tokens/themes/dark-dense.json +48 -0
- package/tokens/themes/dark.json +216 -0
- package/tokens/themes/gradient.json +44 -0
- package/tokens/themes/light.json +243 -0
- package/tokens/themes/minimal.json +47 -0
- package/tokens/themes/neon.json +69 -0
- package/tokens/themes/ocean.json +44 -0
- package/tokens/themes/vibrant.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# @nebutra/design-tokens
|
|
2
|
+
|
|
3
|
+
W3C DTCG (`$value`/`$type`) tokens as the new SSOT, fed through Style Dictionary 4 to generate CSS / TypeScript / Tailwind preset artifacts.
|
|
4
|
+
|
|
5
|
+
> **Coexistence, not replacement.** This package runs *alongside* `packages/design/tokens/styles.css`, `packages/design/theme/themes.css`, `packages/design/ui/src/tokens/`, and `packages/design/brand/src/`. Apps continue to consume the legacy SSOT until parity is at 100% and migrations land.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Layout
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
packages/design/design-tokens/
|
|
13
|
+
├── tokens/
|
|
14
|
+
│ ├── core.json primitive scales (nebutra-blue/cyan/neutral, status, sizes)
|
|
15
|
+
│ ├── semantic.json semantic aliases (brand.primary, status.danger, brand.gradient)
|
|
16
|
+
│ └── themes/
|
|
17
|
+
│ ├── light.json 12-step scales + shadcn HSL + Geist DS + elevation (light)
|
|
18
|
+
│ ├── dark.json same shape, dark-mode values
|
|
19
|
+
│ ├── neon.json multi-theme: AI SaaS default
|
|
20
|
+
│ ├── gradient.json multi-theme: Marketing/Growth
|
|
21
|
+
│ ├── dark-dense.json multi-theme: DevOps Dashboard
|
|
22
|
+
│ ├── minimal.json multi-theme: Blog/Portfolio
|
|
23
|
+
│ ├── vibrant.json multi-theme: Creative UI/UX
|
|
24
|
+
│ └── ocean.json multi-theme: Community
|
|
25
|
+
├── style-dictionary.config.mjs three platforms: CSS, TS, Tailwind preset
|
|
26
|
+
├── scripts/
|
|
27
|
+
│ └── verify-parity.ts diffs build/css/styles.generated.css vs legacy SSOT
|
|
28
|
+
└── build/ gitignored — generated output
|
|
29
|
+
├── css/ one file per mode + styles.generated.css
|
|
30
|
+
├── ts/ ES module + .d.ts per mode
|
|
31
|
+
└── tailwind/ .preset.cjs per mode
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Commands
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Generate all artifacts
|
|
38
|
+
pnpm --filter @nebutra/design-tokens build
|
|
39
|
+
|
|
40
|
+
# Diff generated CSS against the legacy SSOT
|
|
41
|
+
pnpm --filter @nebutra/design-tokens verify:parity
|
|
42
|
+
|
|
43
|
+
# Clean and rebuild
|
|
44
|
+
pnpm --filter @nebutra/design-tokens rebuild
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Token format
|
|
48
|
+
|
|
49
|
+
Each token follows the [W3C DTCG draft](https://design-tokens.github.io/community-group/format/):
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"color": {
|
|
54
|
+
"nebutra-blue": {
|
|
55
|
+
"500": {
|
|
56
|
+
"$value": "#0033fe",
|
|
57
|
+
"$type": "color",
|
|
58
|
+
"$description": "Base brand color — 云毓蓝"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Aliases use the `{path.to.token}` syntax:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"brand": {
|
|
70
|
+
"primary": { "$value": "{color.nebutra-blue.500}", "$type": "color" }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Naming convention (CSS variable output)
|
|
76
|
+
|
|
77
|
+
A custom Style Dictionary transform (`name/nebutra/css`) maps DTCG paths to the same names the legacy SSOT uses, e.g.:
|
|
78
|
+
|
|
79
|
+
| DTCG path | Generated CSS var |
|
|
80
|
+
|-----------------------------|-------------------------|
|
|
81
|
+
| `color.nebutra-blue.500` | `--nebutra-blue-500` |
|
|
82
|
+
| `color.tertiary-purple` | `--brand-tertiary` |
|
|
83
|
+
| `scale.neutral.1` | `--neutral-1` |
|
|
84
|
+
| `shadcn.background` | `--background` |
|
|
85
|
+
| `ds.blue-200` | `--ds-blue-200` |
|
|
86
|
+
| `elevation.xs` | `--elevation-xs` |
|
|
87
|
+
| `brand.primary` | `--brand-primary` |
|
|
88
|
+
| `brand.gradient.primary` | `--brand-gradient` |
|
|
89
|
+
| `size.container.text` | `--container-text` |
|
|
90
|
+
| `size.radius.md` | `--radius-md` |
|
|
91
|
+
| `duration.flow` | `--duration-flow` |
|
|
92
|
+
| `easing.out` | `--ease-out` |
|
|
93
|
+
| `fontFamily.sans` | `--font-sans` |
|
|
94
|
+
|
|
95
|
+
This keeps the generated CSS interchangeable with the manually-maintained `packages/design/tokens/styles.css` for ongoing parity verification.
|
|
96
|
+
|
|
97
|
+
## Build modes
|
|
98
|
+
|
|
99
|
+
The build emits one file per mode:
|
|
100
|
+
|
|
101
|
+
| Mode | Selector | Source files |
|
|
102
|
+
|--------------|---------------------------|------------------------------------------------------------|
|
|
103
|
+
| `light` | `:root` | core.json + semantic.json + themes/light.json |
|
|
104
|
+
| `dark` | `.dark` | core.json + semantic.json + themes/dark.json |
|
|
105
|
+
| `neon` | `:root` (default theme) | core.json + semantic.json + themes/neon.json |
|
|
106
|
+
| `gradient` | `[data-theme="gradient"]` | core.json + semantic.json + themes/gradient.json |
|
|
107
|
+
| `dark-dense` | `[data-theme="dark-dense"]` | core.json + semantic.json + themes/dark-dense.json |
|
|
108
|
+
| `minimal` | `[data-theme="minimal"]` | core.json + semantic.json + themes/minimal.json |
|
|
109
|
+
| `vibrant` | `[data-theme="vibrant"]` | core.json + semantic.json + themes/vibrant.json |
|
|
110
|
+
| `ocean` | `[data-theme="ocean"]` | core.json + semantic.json + themes/ocean.json |
|
|
111
|
+
|
|
112
|
+
`build/css/styles.generated.css` is the concatenation of `light.css` + `dark.css` and is the file that `verify-parity.ts` diffs against `packages/design/tokens/styles.css`.
|
|
113
|
+
|
|
114
|
+
## Parity status
|
|
115
|
+
|
|
116
|
+
Run `pnpm verify:parity` for the live report. Current baseline (Phase 1):
|
|
117
|
+
|
|
118
|
+
- `:root`: ~86%
|
|
119
|
+
- `.dark`: ~87%
|
|
120
|
+
- **Overall: ~87% tokens at parity**
|
|
121
|
+
|
|
122
|
+
The 70% parity floor is enforced; below it, the script exits non-zero.
|
|
123
|
+
|
|
124
|
+
### Known parity gaps (follow-ups)
|
|
125
|
+
|
|
126
|
+
1. **Display-P3 wide-gamut overrides** — the legacy SSOT defines `--nebutra-brand-blue` / `--nebutra-brand-cyan` aliases inside `@supports (color: color(display-p3 ...))`. Those are not yet modeled in DTCG; today the generated values are the sRGB hex fallback. Next step: add a P3 wide-gamut variant in `core.json` and emit it under a SD `mediaQuery` wrapper.
|
|
127
|
+
2. **`oklch()` overrides for `--ds-gray-*`** — the legacy file ships sRGB `hsla()` baseline values and overrides them under `@supports (color: oklch(...))`. The generated CSS currently keeps only the sRGB fallback. Next step: add a separate `themes/ds-gray-oklch.json` and a SD format that wraps it in the `@supports` block.
|
|
128
|
+
3. **Compound shorthand tokens not yet emitted**:
|
|
129
|
+
- `--transition` (combines `--transition-duration` + `--transition-easing`)
|
|
130
|
+
- `--focus-ring` (compound box-shadow recipe)
|
|
131
|
+
These can be modeled as DTCG `composite` tokens; deferred to follow-up.
|
|
132
|
+
4. **`--brand-primary` / `--brand-accent` in `.dark` mode** — the legacy SSOT keeps these mapped to the sRGB primitives, but in dark mode the visual brand is `var(--blue-9)` which itself maps to `--nebutra-blue-400`. Today the DTCG model resolves to the *core* primitive (always blue-500/cyan-500). Next step: add per-mode brand alias overrides in the dark theme file.
|
|
133
|
+
5. **Geist 12-step scale alias indirection** — `--blue-9` resolves to its primitive (`#0033fe` light / `#5c7cfa` dark) via the legacy `var(...)` chain. The verify script applies var() resolution to make the comparison fair, but the generated CSS inlines the primitive rather than emitting a `var(...)` chain. Functionally equivalent, but if app code depends on the chain (e.g. for runtime `getComputedStyle` lookups), use `outputReferences: true` in the SD config.
|
|
134
|
+
|
|
135
|
+
## Sandbox / install notes
|
|
136
|
+
|
|
137
|
+
If `pnpm add -D style-dictionary@^4 --filter @nebutra/design-tokens` is blocked in your sandbox, run it manually from the repo root. Style Dictionary 4 ships with native DTCG (`$value`/`$type`) support via the `tokens-studio` preprocessor — no plugin needed.
|
|
138
|
+
|
|
139
|
+
If Style Dictionary 4 fails to install, **Terrazzo** (https://terrazzo.app) is a drop-in alternative that also speaks DTCG and ships its own CSS / TS / Tailwind generators. Switch via:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
pnpm add -D @terrazzo/cli @terrazzo/plugin-css @terrazzo/plugin-js --filter @nebutra/design-tokens
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
…and replace `style-dictionary.config.mjs` with `terrazzo.config.js` per their docs. The tokens themselves are portable — both tools consume DTCG.
|
|
146
|
+
|
|
147
|
+
## Why not edit `packages/design/tokens/styles.css` directly?
|
|
148
|
+
|
|
149
|
+
The legacy file is hand-tuned with cascade-aware overrides (`@supports`, `@theme inline`, `@utility`), which Style Dictionary's CSS formatter does not yet emit ergonomically. Until parity reaches 100% and we adopt a tool capable of emitting those constructs (likely SD + a custom format), the manual file remains the runtime SSOT and this package is the *machine-readable* SSOT used by Figma sync, design-doc generators, and Storybook visualizations.
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nebutra/design-tokens",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "W3C DTCG ($value/$type) tokens — SSOT, Style Dictionary 4 pipeline. Coexists with @nebutra/tokens; not a replacement.",
|
|
5
|
+
"private": false,
|
|
6
|
+
"license": "AGPL-3.0",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./build/ts/tokens.js",
|
|
9
|
+
"types": "./build/ts/tokens.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
"./tokens/core.json": "./tokens/core.json",
|
|
12
|
+
"./tokens/semantic.json": "./tokens/semantic.json",
|
|
13
|
+
"./tokens/themes/light.json": "./tokens/themes/light.json",
|
|
14
|
+
"./tokens/themes/dark.json": "./tokens/themes/dark.json",
|
|
15
|
+
"./tokens/themes/neon.json": "./tokens/themes/neon.json",
|
|
16
|
+
"./tokens/themes/gradient.json": "./tokens/themes/gradient.json",
|
|
17
|
+
"./tokens/themes/dark-dense.json": "./tokens/themes/dark-dense.json",
|
|
18
|
+
"./tokens/themes/minimal.json": "./tokens/themes/minimal.json",
|
|
19
|
+
"./tokens/themes/vibrant.json": "./tokens/themes/vibrant.json",
|
|
20
|
+
"./tokens/themes/ocean.json": "./tokens/themes/ocean.json",
|
|
21
|
+
"./build/css/styles.generated.css": "./build/css/styles.generated.css"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"tokens",
|
|
25
|
+
"build",
|
|
26
|
+
"style-dictionary.config.mjs"
|
|
27
|
+
],
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"style-dictionary": "^4.4.0",
|
|
30
|
+
"tsx": "^4.21.0",
|
|
31
|
+
"typescript": "^5.9.3"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/Nebutra/Nebutra-Sailor/tree/main/packages/design/design-tokens#readme",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/Nebutra/Nebutra-Sailor.git",
|
|
37
|
+
"directory": "packages/design/design-tokens"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/Nebutra/Nebutra-Sailor/issues"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "node style-dictionary.config.mjs",
|
|
47
|
+
"clean": "rm -rf build && mkdir -p build",
|
|
48
|
+
"rebuild": "pnpm clean && pnpm build",
|
|
49
|
+
"verify:parity": "tsx scripts/verify-parity.ts",
|
|
50
|
+
"typecheck": "tsc --noEmit"
|
|
51
|
+
}
|
|
52
|
+
}
|