@uncinq/component-tokens 1.9.3 → 1.10.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.
@@ -0,0 +1,170 @@
1
+ ---
2
+ isIndex: false
3
+ title: Reference
4
+ description: Every token for all 26 components, generated from the JSON sources so it can never drift from the shipped CSS.
5
+ weight: 3
6
+ ---
7
+
8
+ Every table below is generated at build time from `dist/tokens.json`, which Style Dictionary produces from the same JSON sources as the CSS. Nothing here is written by hand, so a token cannot appear in the reference without existing in the package, or change value without the page changing with it.
9
+
10
+ Values are shown as they ship. A token that references a semantic token shows `var(--the-semantic-token)` rather than a resolved color or length, because that reference is what makes an override of the semantic layer propagate. See [Style Dictionary](../style-dictionary/) for why the build keeps it that way.
11
+
12
+ {{< alert-block state="info" >}}
13
+ Reading this offline, from the repository or from `node_modules`? The tables below are rendered by the documentation site. The same data, in machine-readable form, sits in `dist/tokens.json`, and the final CSS is in `dist/css/components/`.
14
+ {{< /alert-block >}}
15
+
16
+ ### alert
17
+
18
+ Inline notification banner. 9 tokens.
19
+
20
+ {{< tokens pkg="component" file="components/alert" >}}
21
+
22
+ ### badge
23
+
24
+ Badge, pill and tag. 12 tokens.
25
+
26
+ {{< tokens pkg="component" file="components/badge" >}}
27
+
28
+ ### breadcrumb
29
+
30
+ Breadcrumb navigation. 10 tokens.
31
+
32
+ {{< tokens pkg="component" file="components/breadcrumb" >}}
33
+
34
+ ### button
35
+
36
+ Button, all variants and sizes. 28 tokens.
37
+
38
+ {{< tokens pkg="component" file="components/button" >}}
39
+
40
+ ### card
41
+
42
+ Card, an alias layer over item. 36 tokens.
43
+
44
+ {{< tokens pkg="component" file="components/card" >}}
45
+
46
+ ### carousel
47
+
48
+ Carousel, arrows and pagination. 28 tokens.
49
+
50
+ {{< tokens pkg="component" file="components/carousel" >}}
51
+
52
+ ### container
53
+
54
+ Layout container, max-widths and bleed. 17 tokens.
55
+
56
+ {{< tokens pkg="component" file="components/container" >}}
57
+
58
+ ### details
59
+
60
+ Native details and accordion. 25 tokens.
61
+
62
+ {{< tokens pkg="component" file="components/details" >}}
63
+
64
+ ### drawer
65
+
66
+ Off-canvas panel. 22 tokens.
67
+
68
+ {{< tokens pkg="component" file="components/drawer" >}}
69
+
70
+ ### dropdown
71
+
72
+ Dropdown menu. 21 tokens.
73
+
74
+ {{< tokens pkg="component" file="components/dropdown" >}}
75
+
76
+ ### embed
77
+
78
+ Video and iframe wrapper. 7 tokens.
79
+
80
+ {{< tokens pkg="component" file="components/embed" >}}
81
+
82
+ ### figure
83
+
84
+ Figure and figcaption. 4 tokens.
85
+
86
+ {{< tokens pkg="component" file="components/figure" >}}
87
+
88
+ ### heading
89
+
90
+ Heading typography scale. 3 tokens.
91
+
92
+ {{< tokens pkg="component" file="components/heading" >}}
93
+
94
+ ### hero
95
+
96
+ Hero and banner section. 17 tokens.
97
+
98
+ {{< tokens pkg="component" file="components/hero" >}}
99
+
100
+ ### item
101
+
102
+ Item, the canonical card-like unit. 55 tokens.
103
+
104
+ {{< tokens pkg="component" file="components/item" >}}
105
+
106
+ ### items
107
+
108
+ Items grid and list wrapper. 3 tokens.
109
+
110
+ {{< tokens pkg="component" file="components/items" >}}
111
+
112
+ ### link
113
+
114
+ Inline link. 4 tokens.
115
+
116
+ {{< tokens pkg="component" file="components/link" >}}
117
+
118
+ ### list
119
+
120
+ Styled list. 6 tokens.
121
+
122
+ {{< tokens pkg="component" file="components/list" >}}
123
+
124
+ ### logo
125
+
126
+ Logotype. 7 tokens.
127
+
128
+ {{< tokens pkg="component" file="components/logo" >}}
129
+
130
+ ### map
131
+
132
+ Embedded map. 5 tokens.
133
+
134
+ {{< tokens pkg="component" file="components/map" >}}
135
+
136
+ ### media
137
+
138
+ Media object, image plus text. 4 tokens.
139
+
140
+ {{< tokens pkg="component" file="components/media" >}}
141
+
142
+ ### modal
143
+
144
+ Centered dialog. 21 tokens.
145
+
146
+ {{< tokens pkg="component" file="components/modal" >}}
147
+
148
+ ### nav
149
+
150
+ Navigation bar. 15 tokens.
151
+
152
+ {{< tokens pkg="component" file="components/nav" >}}
153
+
154
+ ### pagination
155
+
156
+ Pagination control. 17 tokens.
157
+
158
+ {{< tokens pkg="component" file="components/pagination" >}}
159
+
160
+ ### surtitle
161
+
162
+ Small label above a heading. 8 tokens.
163
+
164
+ {{< tokens pkg="component" file="components/surtitle" >}}
165
+
166
+ ### table
167
+
168
+ Data table. 6 tokens.
169
+
170
+ {{< tokens pkg="component" file="components/table" >}}
@@ -0,0 +1,124 @@
1
+ ---
2
+ isIndex: false
3
+ title: Style Dictionary
4
+ description: How component token JSON is compiled to CSS, and how cross-package references to design-tokens are resolved.
5
+ weight: 5
6
+ ---
7
+
8
+
9
+ [Style Dictionary v5](https://styledictionary.com/) transforms the DTCG JSON token files into CSS custom properties.
10
+
11
+ ## Run the build
12
+
13
+ ```bash
14
+ npm run build
15
+ ```
16
+
17
+ Output is written to `dist/css/components/`. One CSS file is generated per JSON source file.
18
+
19
+ ```
20
+ tokens/components/button.json → dist/css/components/button.css
21
+ tokens/components/badge.json → dist/css/components/badge.css
22
+ ```
23
+
24
+ `dist/css/index.css` is auto-generated too, in a step that runs after Style Dictionary. It discovers the token files from disk, so adding a JSON source needs no manual edit anywhere. Each generated file declares its own `@layer tokens`, which is why a plain `@import` is enough and no `layer()` qualifier is used.
25
+
26
+ ---
27
+
28
+ ## Cross-package references
29
+
30
+ Component tokens reference semantic tokens from `@uncinq/design-tokens` using DTCG `{dotted.path}` syntax:
31
+
32
+ ```json
33
+ {
34
+ "btn": {
35
+ "border": {
36
+ "radius": { "$value": "{radius.control}", "$type": "dimension" }
37
+ }
38
+ }
39
+ }
40
+ ```
41
+
42
+ The design-tokens sources are loaded as `include`, from `node_modules/@uncinq/design-tokens/tokens`, so these references do resolve at build time. The build fails fast with a clear message if that package is missing:
43
+
44
+ ```js
45
+ const designTokensPath = './node_modules/@uncinq/design-tokens/tokens';
46
+ if (!fs.existsSync(designTokensPath)) {
47
+ throw new Error('Missing @uncinq/design-tokens — run npm install first.');
48
+ }
49
+ ```
50
+
51
+ Resolution is only used for validation, though. The output deliberately keeps the reference rather than the resolved value: the format reads `token.original.$value` and rewrites the DTCG reference as a CSS `var()`.
52
+
53
+ ```
54
+ {radius.control} → var(--radius-control)
55
+ {color.text.muted} → var(--color-text-muted)
56
+ ```
57
+
58
+ That is what makes the layering work at runtime. A project that overrides `--color-brand` moves every component token pointing at it, because the component CSS still says `var(--color-brand)` rather than a baked-in color.
59
+
60
+ `log: { errors: { brokenReferences: 'console' } }` remains set as a safety net, so a typo in a reference reports on the console instead of aborting the whole build.
61
+
62
+ Path segments named `default` are stripped, mirroring the `@uncinq/design-tokens` convention:
63
+
64
+ ```
65
+ {color.brand.default} → var(--color-brand)
66
+ {color.text.default} → var(--color-text)
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Adding a new component
72
+
73
+ 1. Create `tokens/components/{name}.json` with DTCG structure.
74
+ 2. Run `npm run build`.
75
+
76
+ That is the whole procedure. `dist/css/components/{name}.css` is generated, and the `@import` is added to `dist/css/index.css` automatically, because both the build and the index step discover token files from disk rather than from a hardcoded list.
77
+
78
+ ---
79
+
80
+ ## Token naming
81
+
82
+ Token JSON paths map directly to CSS custom property names. Use camelCase for compound CSS property names — the build converts them to kebab-case:
83
+
84
+ | JSON path | CSS variable |
85
+ | --- | --- |
86
+ | `btn.border.radius` | `--btn-border-radius` |
87
+ | `btn.color.background` | `--btn-color-background` |
88
+ | `btn.color.background.hover` | `--btn-color-background-hover` |
89
+ | `btn.color.textDecoration` | `--btn-color-text-decoration` |
90
+ | `btn.color.background.default` | `--btn-color-background` (default stripped) |
91
+ | `btn.text.decorationLine` | `--btn-text-decoration-line` |
92
+
93
+ States (`hover`, `active`, `focus`, `disabled`, `checked`) are nested one level deeper under the property group.
94
+
95
+ ---
96
+
97
+ ## References
98
+
99
+ - [Style Dictionary v5 docs](https://styledictionary.com/)
100
+ - [@uncinq/design-tokens](https://github.com/uncinq/design-tokens) — primitive and semantic tokens referenced by this package
101
+
102
+ ---
103
+
104
+ ## The JSON manifest
105
+
106
+ Alongside the CSS, the build writes `dist/tokens.json`: a flat array of every token the package ships.
107
+
108
+ ```json
109
+ [
110
+ {
111
+ "name": "--btn-color-background",
112
+ "value": "var(--color-brand)",
113
+ "type": "color",
114
+ "file": "components/button",
115
+ "description": ""
116
+ }
117
+ ]
118
+ ```
119
+
120
+ The documentation site renders its reference tables from this file, which is why the reference cannot drift from the stylesheets.
121
+
122
+ The guarantee comes from a single shared function. `tokenToCssValue()` serializes a token to its CSS value, and **both** the CSS format and the manifest format call it. There is no second implementation of the naming or the value logic to fall out of step, and the build asserts the equivalence: the manifest holds exactly one entry per declaration emitted in `dist/css/`, with the same name and the same value.
123
+
124
+ `description` comes from the DTCG `$description` key. Adding one to a token source makes it appear in the published reference with no other change.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uncinq/component-tokens",
3
- "version": "1.9.3",
3
+ "version": "1.10.0",
4
4
  "description": "Framework-agnostic CSS design tokens — component layers.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -23,6 +23,8 @@
23
23
  ],
24
24
  "files": [
25
25
  "dist/css/",
26
+ "dist/tokens.json",
27
+ "docs/",
26
28
  "tokens/"
27
29
  ],
28
30
  "exports": {
@@ -34,8 +34,20 @@
34
34
  "$type": "color"
35
35
  },
36
36
  "text": {
37
- "$value": "{color.text.onSurface}",
38
- "$type": "color"
37
+ "default": {
38
+ "$value": "{color.text.onSurface}",
39
+ "$type": "color"
40
+ },
41
+ "active": {
42
+ "$value": "{color.text.onSurface}",
43
+ "$type": "color",
44
+ "$description": "Links inside the panel keep the panel text colour unless this is overridden."
45
+ },
46
+ "hover": {
47
+ "$value": "{color.text.onSurface}",
48
+ "$type": "color",
49
+ "$description": "Links inside the panel keep the panel text colour unless this is overridden."
50
+ }
39
51
  }
40
52
  },
41
53
  "end": {
@@ -3,7 +3,7 @@
3
3
  "border": {
4
4
  "radius": {
5
5
  "$value": "{radius.none}",
6
- "$type": "dimensions"
6
+ "$type": "dimension"
7
7
  }
8
8
  },
9
9
  "color": {
@@ -30,8 +30,20 @@
30
30
  "$type": "color"
31
31
  },
32
32
  "text": {
33
- "$value": "{color.text.onSurface}",
34
- "$type": "color"
33
+ "default": {
34
+ "$value": "{color.text.onSurface}",
35
+ "$type": "color"
36
+ },
37
+ "active": {
38
+ "$value": "{color.text.onSurface}",
39
+ "$type": "color",
40
+ "$description": "Links inside the panel keep the panel text colour unless this is overridden."
41
+ },
42
+ "hover": {
43
+ "$value": "{color.text.onSurface}",
44
+ "$type": "color",
45
+ "$description": "Links inside the panel keep the panel text colour unless this is overridden."
46
+ }
35
47
  }
36
48
  },
37
49
  "margin": {