@bitrise/bitkit-v2 0.3.255-beta.1718 → 0.3.255-beta.1719
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/docs/design-tokens.md +94 -0
- package/package.json +2 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Design tokens — source of truth & sync
|
|
2
|
+
|
|
3
|
+
How bitkit-v2's color tokens relate to the design source, and how to keep them in sync.
|
|
4
|
+
|
|
5
|
+
## The pipeline
|
|
6
|
+
|
|
7
|
+
The **source of truth is the design team's Tokens Studio export** — a single
|
|
8
|
+
`tokens.json` (DTCG / Figma Tokens format) generated from Figma. It currently
|
|
9
|
+
lives in the `bitkit-tokens` repo at `data/tokens.json`.
|
|
10
|
+
|
|
11
|
+
bitkit-v2 holds **hand-maintained** token files that mirror that source:
|
|
12
|
+
|
|
13
|
+
| source (`tokens.json`) | bitkit-v2 file |
|
|
14
|
+
| -------------------------------------------------------- | ------------------------------------------- |
|
|
15
|
+
| `core/color-primitives.core` (`purple.50`, `red.40`, …) | `lib/theme/tokens/colors.ts` (primitives) |
|
|
16
|
+
| `semantic/theme-light.{color,sys,…}` | `lib/theme/semantic-tokens/semanticColors.ts` |
|
|
17
|
+
| `components/colors.{background,text,icon,button,status,gradient,…}` | `lib/theme/semantic-tokens/semanticColors.ts` |
|
|
18
|
+
|
|
19
|
+
When the source changes (it does, in small increments), re-sync bitkit's files
|
|
20
|
+
to match. **The JSON wins** on any conflict — including over the
|
|
21
|
+
`bitkit-color-tokens.xlsx` worksheet, which is a human-readable side view and
|
|
22
|
+
can lag behind.
|
|
23
|
+
|
|
24
|
+
## Checking for drift
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# 1. fetch the current source (auth via gh)
|
|
28
|
+
gh api repos/<owner>/bitkit-tokens/contents/data/tokens.json --jq '.content' | base64 -d > /tmp/tokens.json
|
|
29
|
+
|
|
30
|
+
# 2. diff it against bitkit's token files
|
|
31
|
+
npm run theme:diff-tokens -- /tmp/tokens.json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The script (`scripts/diff-design-tokens.cjs`) reports, for the primitive and
|
|
35
|
+
semantic+component layers:
|
|
36
|
+
|
|
37
|
+
- tokens the **source has but bitkit is missing**,
|
|
38
|
+
- tokens **bitkit has but the source doesn't** (renamed / stale / intentional extra),
|
|
39
|
+
- **light value/reference mismatches** on the common tokens.
|
|
40
|
+
|
|
41
|
+
Values are compared canonically, so equivalent spellings (`#fff` ≡ `#ffffff`,
|
|
42
|
+
`core.purple.50` ≡ `colors.purple.50`) are **not** flagged.
|
|
43
|
+
|
|
44
|
+
After any change, run `npm run theme:generate-types` then `npm run type-check`.
|
|
45
|
+
|
|
46
|
+
## Naming & layering conventions
|
|
47
|
+
|
|
48
|
+
- **Primitives** are dot-separated (`purple.50`, `white.10`) and live in `colors.ts`.
|
|
49
|
+
- **Semantic / component** tokens are slash-separated (`color/purple/base`,
|
|
50
|
+
`sys/bg/surface`, `button/primary/bg`, `gradient/ai/background/base`).
|
|
51
|
+
- References use the `{colors.…}` prefix: `{colors.purple.50}` (primitive) or
|
|
52
|
+
`{colors.sys/bg/surface}` (semantic).
|
|
53
|
+
- **`sys/*` and primitives are pruned from consumer autocomplete** (see
|
|
54
|
+
`scripts/prune-color-tokens.cjs`). They still resolve at runtime; they're just
|
|
55
|
+
hidden so consumers reach for the component layer (`color/*`, `background/*`,
|
|
56
|
+
`text/*`, `gradient/*`, …). App-shell tokens (`sys/ui/header/*`,
|
|
57
|
+
`sys/ui/sidenav/*`) are therefore intentionally hidden — they're for bitkit's
|
|
58
|
+
own header/sidenav components.
|
|
59
|
+
|
|
60
|
+
## Runtime constraint: why some values can't match the source verbatim
|
|
61
|
+
|
|
62
|
+
bitkit resolves token references to **CSS custom properties** at runtime
|
|
63
|
+
(`var(--colors-purple-50)`). Two source spellings are therefore impossible to
|
|
64
|
+
reproduce and are deliberately expressed differently — **same rendered color**:
|
|
65
|
+
|
|
66
|
+
1. **A reference inside a composite value** (gradient, `color-mix`). Chakra
|
|
67
|
+
parses any `/` inside `{…}` as a `color-mix` opacity delimiter and **throws**.
|
|
68
|
+
So gradients **inline the dot-primitive** instead of referencing the semantic
|
|
69
|
+
token:
|
|
70
|
+
- source: `linear-gradient(90deg, rgba({color.purple.minimal}, 1) 0%, …)`
|
|
71
|
+
- bitkit: `linear-gradient(90deg, {colors.purple.95} 0%, …)`
|
|
72
|
+
2. **Alpha via `rgba({ref}, a)`**. `rgba(var(--x), 0.5)` is invalid CSS, so
|
|
73
|
+
bitkit uses `color-mix(in srgb, {colors.x} 50%, transparent)` (and a literal
|
|
74
|
+
`rgba(255, 255, 255, 0)` for fully-transparent tokens).
|
|
75
|
+
|
|
76
|
+
A drift report that only flags these representation differences means bitkit is
|
|
77
|
+
**fully in sync**.
|
|
78
|
+
|
|
79
|
+
## Out of scope (intentional)
|
|
80
|
+
|
|
81
|
+
- **Dark theme** — the source ships a full `semantic/theme-dark` layer and a
|
|
82
|
+
`dark` primitive scale. bitkit does **not** implement dark mode yet, so these
|
|
83
|
+
are intentionally absent. _(Later task — revisit when dark mode is on the roadmap.)_
|
|
84
|
+
- **brand** — the source's `brand/*` primitives (and `brand/primary`) are "not
|
|
85
|
+
in design" for bitkit and were intentionally dropped.
|
|
86
|
+
|
|
87
|
+
## Notes on specific tokens
|
|
88
|
+
|
|
89
|
+
- **`text/helper`** is the canonical helper-text color. bitkit previously also
|
|
90
|
+
had `input/text/helper` (a duplicate); it was removed in favour of
|
|
91
|
+
`text/helper`. Consumer repos may still reference `input/text/helper` — migrate
|
|
92
|
+
them on the next bump.
|
|
93
|
+
- **`sys/interactive/*`** was removed (the source dropped it); the component
|
|
94
|
+
layer `interactive/*` is the replacement.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitrise/bitkit-v2",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.3.255-beta.
|
|
4
|
+
"version": "0.3.255-beta.1719",
|
|
5
5
|
"description": "Bitrise Design System Components built with Chakra UI V3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"react",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"storybook": "storybook dev -p 6006",
|
|
43
43
|
"build-storybook": "storybook build",
|
|
44
44
|
"theme:generate-types": "chakra typegen lib/theme/index.ts && node ./scripts/prune-color-tokens.cjs",
|
|
45
|
+
"theme:diff-tokens": "node ./scripts/diff-design-tokens.cjs",
|
|
45
46
|
"theme:watch": "chakra typegen lib/theme/index.ts --watch",
|
|
46
47
|
"lint": "eslint .",
|
|
47
48
|
"lint:fix": "eslint . --fix",
|