@kiva/kv-tokens 4.0.0-next.1 → 4.0.1
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/README.md +46 -3
- package/dist/dtcg/tokens.json +2076 -0
- package/package.json +13 -7
- package/tokens/core/.gitkeep +0 -0
- package/tokens/core/color.json +66 -0
- package/tokens/core/misc.json +27 -0
- package/tokens/core/size.json +52 -0
- package/tokens/core/typography.json +68 -0
- package/tokens/semantic/.gitkeep +0 -0
- package/tokens/semantic/themes/dark-green.json +35 -0
- package/tokens/semantic/themes/dark-mint.json +33 -0
- package/tokens/semantic/themes/dark-stone.json +38 -0
- package/tokens/semantic/themes/dark.json +38 -0
- package/tokens/semantic/themes/default.json +45 -0
- package/tokens/semantic/themes/green-dark.json +33 -0
- package/tokens/semantic/themes/green-light.json +10 -0
- package/tokens/semantic/themes/marigold-light.json +35 -0
- package/tokens/semantic/themes/mint.json +36 -0
- package/tokens/semantic/themes/stone-dark.json +35 -0
- package/tokens/semantic/themes/stone-light.json +30 -0
- package/build/build.js +0 -23
- package/build/formats/css-themes.js +0 -60
- package/build/formats/js-tokens.js +0 -91
- package/build/style-dictionary.config.js +0 -45
- package/build/transforms/dimension-to-number.js +0 -17
package/README.md
CHANGED
|
@@ -18,10 +18,10 @@ import designTokens from '@kiva/kv-tokens';
|
|
|
18
18
|
const primaryTextColor = designTokens.colors.theme.DEFAULT.text.primary;
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
You can also import the generated
|
|
21
|
+
You can also import the generated JS module directly (flat named exports plus the nested default):
|
|
22
22
|
|
|
23
23
|
```js
|
|
24
|
-
import tokens, { colorBrandDefault } from '@kiva/kv-tokens/
|
|
24
|
+
import tokens, { colorBrandDefault } from '@kiva/kv-tokens/js';
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Using the Tailwind Preset
|
|
@@ -59,11 +59,54 @@ Our Tailwind config has some differences to the standard install. Notably
|
|
|
59
59
|
| Subpath | Resolves to | Use for |
|
|
60
60
|
| ------------------------------ | --------------------------- | ----------------------------------------- |
|
|
61
61
|
| `@kiva/kv-tokens` | `index.js` | Default: tokens object + theme/tailwind helpers |
|
|
62
|
-
| `@kiva/kv-tokens/tokens` | `dist/
|
|
62
|
+
| `@kiva/kv-tokens/tokens` | `dist/dtcg/tokens.json` | Single merged DTCG source manifest (aliases preserved) |
|
|
63
|
+
| `@kiva/kv-tokens/tokens/*` | `tokens/*` | Individual DTCG source files |
|
|
63
64
|
| `@kiva/kv-tokens/tailwind` | `configs/tailwind.config.js`| Tailwind preset |
|
|
65
|
+
| `@kiva/kv-tokens/js` | `dist/js/tokens.js` | Generated JS tokens (flat + nested) |
|
|
64
66
|
| `@kiva/kv-tokens/css` | `dist/css/tokens.css` | Themed CSS custom properties |
|
|
65
67
|
| `@kiva/kv-tokens/scss` | `dist/scss/tokens.scss` | SCSS `$variable` map |
|
|
66
68
|
|
|
69
|
+
## Importing Source Tokens
|
|
70
|
+
|
|
71
|
+
The `./tokens` subpath exports the design tokens **as authored** in [W3C DTCG](https://design-tokens.github.io/community-group/format/) format, with aliases (e.g. `"{color.brand.DEFAULT}"`), `$type`, and `$description` metadata preserved. This is the canonical source for downstream tooling that wants the untransformed shape:
|
|
72
|
+
|
|
73
|
+
- Figma plugins / Tokens Studio / Specify and other DTCG-native tools
|
|
74
|
+
- Alternative build pipelines (e.g. a mobile app using a different token transform)
|
|
75
|
+
- Drift-detection scripts comparing an external export against our source of truth
|
|
76
|
+
- Documentation generators and agent reference material that reason about token intent
|
|
77
|
+
|
|
78
|
+
### Single merged manifest
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
import tokens from '@kiva/kv-tokens/tokens' with { type: 'json' };
|
|
82
|
+
|
|
83
|
+
tokens.color.brand.DEFAULT; // { $type: 'color', $value: '#2AA967' }
|
|
84
|
+
tokens.theme.DEFAULT.text.primary; // { $type: 'color', $value: '#223829' }
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The manifest is produced by [`build/build-dtcg.js`](build/build-dtcg.js), which deep-merges every source file under [`tokens/`](tokens/) and errors if two files define a leaf at the same path.
|
|
88
|
+
|
|
89
|
+
### Individual source files
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
import coreColors from '@kiva/kv-tokens/tokens/core/color.json' with { type: 'json' };
|
|
93
|
+
import defaultTheme from '@kiva/kv-tokens/tokens/semantic/themes/default.json' with { type: 'json' };
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Or read them off disk from `node_modules/@kiva/kv-tokens/tokens/…` — useful for skill files and other tools that prefer file paths over module imports.
|
|
97
|
+
|
|
98
|
+
**Note on stability:** once shipped, the on-disk layout of `tokens/` (directory names, file names) is part of this package's public contract. Reorganizing it is a breaking change.
|
|
99
|
+
|
|
100
|
+
For the transformed, resolved-values-with-code-facing-names shape used by component code, prefer the default export of `@kiva/kv-tokens` or the flat-and-nested `@kiva/kv-tokens/js` module.
|
|
101
|
+
|
|
102
|
+
## Local Development
|
|
103
|
+
|
|
104
|
+
The `dist/` directory is gitignored but regenerated automatically by the `prepare` lifecycle script whenever you run `npm install` — both at the monorepo root and inside this package. After a fresh clone, `npm install` leaves `dist/` ready to use, so downstream workspace packages like [`@kiva/kv-components`](../kv-components/) can consume tokens without a separate build step.
|
|
105
|
+
|
|
106
|
+
The same `prepare` hook runs before `npm publish` (and `lerna publish`), so published tarballs always contain a fresh `dist/`.
|
|
107
|
+
|
|
108
|
+
If you edit a token source file during development, rerun `npm run build` to regenerate `dist/`. See [Editing Tokens](#editing-tokens) below.
|
|
109
|
+
|
|
67
110
|
## Editing Tokens
|
|
68
111
|
|
|
69
112
|
Tokens live under [`tokens/`](tokens/) as DTCG JSON:
|