@uncinq/component-tokens 1.9.3 → 1.10.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.
@@ -0,0 +1,171 @@
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
+ icon: table
7
+ ---
8
+
9
+ 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.
10
+
11
+ 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.
12
+
13
+ {{< alert-block state="info" >}}
14
+ 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/`.
15
+ {{< /alert-block >}}
16
+
17
+ ### alert
18
+
19
+ Inline notification banner. 9 tokens.
20
+
21
+ {{< tokens pkg="component" file="components/alert" >}}
22
+
23
+ ### badge
24
+
25
+ Badge, pill and tag. 12 tokens.
26
+
27
+ {{< tokens pkg="component" file="components/badge" >}}
28
+
29
+ ### breadcrumb
30
+
31
+ Breadcrumb navigation. 10 tokens.
32
+
33
+ {{< tokens pkg="component" file="components/breadcrumb" >}}
34
+
35
+ ### button
36
+
37
+ Button, all variants and sizes. 28 tokens.
38
+
39
+ {{< tokens pkg="component" file="components/button" >}}
40
+
41
+ ### card
42
+
43
+ Card, an alias layer over item. 36 tokens.
44
+
45
+ {{< tokens pkg="component" file="components/card" >}}
46
+
47
+ ### carousel
48
+
49
+ Carousel, arrows and pagination. 28 tokens.
50
+
51
+ {{< tokens pkg="component" file="components/carousel" >}}
52
+
53
+ ### container
54
+
55
+ Layout container, max-widths and bleed. 17 tokens.
56
+
57
+ {{< tokens pkg="component" file="components/container" >}}
58
+
59
+ ### details
60
+
61
+ Native details and accordion. 25 tokens.
62
+
63
+ {{< tokens pkg="component" file="components/details" >}}
64
+
65
+ ### drawer
66
+
67
+ Off-canvas panel. 22 tokens.
68
+
69
+ {{< tokens pkg="component" file="components/drawer" >}}
70
+
71
+ ### dropdown
72
+
73
+ Dropdown menu. 21 tokens.
74
+
75
+ {{< tokens pkg="component" file="components/dropdown" >}}
76
+
77
+ ### embed
78
+
79
+ Video and iframe wrapper. 7 tokens.
80
+
81
+ {{< tokens pkg="component" file="components/embed" >}}
82
+
83
+ ### figure
84
+
85
+ Figure and figcaption. 4 tokens.
86
+
87
+ {{< tokens pkg="component" file="components/figure" >}}
88
+
89
+ ### heading
90
+
91
+ Heading typography scale. 3 tokens.
92
+
93
+ {{< tokens pkg="component" file="components/heading" >}}
94
+
95
+ ### hero
96
+
97
+ Hero and banner section. 17 tokens.
98
+
99
+ {{< tokens pkg="component" file="components/hero" >}}
100
+
101
+ ### item
102
+
103
+ Item, the canonical card-like unit. 55 tokens.
104
+
105
+ {{< tokens pkg="component" file="components/item" >}}
106
+
107
+ ### items
108
+
109
+ Items grid and list wrapper. 3 tokens.
110
+
111
+ {{< tokens pkg="component" file="components/items" >}}
112
+
113
+ ### link
114
+
115
+ Inline link. 4 tokens.
116
+
117
+ {{< tokens pkg="component" file="components/link" >}}
118
+
119
+ ### list
120
+
121
+ Styled list. 6 tokens.
122
+
123
+ {{< tokens pkg="component" file="components/list" >}}
124
+
125
+ ### logo
126
+
127
+ Logotype. 7 tokens.
128
+
129
+ {{< tokens pkg="component" file="components/logo" >}}
130
+
131
+ ### map
132
+
133
+ Embedded map. 5 tokens.
134
+
135
+ {{< tokens pkg="component" file="components/map" >}}
136
+
137
+ ### media
138
+
139
+ Media object, image plus text. 4 tokens.
140
+
141
+ {{< tokens pkg="component" file="components/media" >}}
142
+
143
+ ### modal
144
+
145
+ Centered dialog. 21 tokens.
146
+
147
+ {{< tokens pkg="component" file="components/modal" >}}
148
+
149
+ ### nav
150
+
151
+ Navigation bar. 15 tokens.
152
+
153
+ {{< tokens pkg="component" file="components/nav" >}}
154
+
155
+ ### pagination
156
+
157
+ Pagination control. 17 tokens.
158
+
159
+ {{< tokens pkg="component" file="components/pagination" >}}
160
+
161
+ ### surtitle
162
+
163
+ Small label above a heading. 8 tokens.
164
+
165
+ {{< tokens pkg="component" file="components/surtitle" >}}
166
+
167
+ ### table
168
+
169
+ Data table. 6 tokens.
170
+
171
+ {{< tokens pkg="component" file="components/table" >}}
@@ -0,0 +1,125 @@
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
+ icon: gear
7
+ ---
8
+
9
+
10
+ [Style Dictionary v5](https://styledictionary.com/) transforms the DTCG JSON token files into CSS custom properties.
11
+
12
+ ## Run the build
13
+
14
+ ```bash
15
+ npm run build
16
+ ```
17
+
18
+ Output is written to `dist/css/components/`. One CSS file is generated per JSON source file.
19
+
20
+ ```
21
+ tokens/components/button.json → dist/css/components/button.css
22
+ tokens/components/badge.json → dist/css/components/badge.css
23
+ ```
24
+
25
+ `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.
26
+
27
+ ---
28
+
29
+ ## Cross-package references
30
+
31
+ Component tokens reference semantic tokens from `@uncinq/design-tokens` using DTCG `{dotted.path}` syntax:
32
+
33
+ ```json
34
+ {
35
+ "btn": {
36
+ "border": {
37
+ "radius": { "$value": "{radius.control}", "$type": "dimension" }
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ 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:
44
+
45
+ ```js
46
+ const designTokensPath = './node_modules/@uncinq/design-tokens/tokens';
47
+ if (!fs.existsSync(designTokensPath)) {
48
+ throw new Error('Missing @uncinq/design-tokens — run npm install first.');
49
+ }
50
+ ```
51
+
52
+ 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()`.
53
+
54
+ ```
55
+ {radius.control} → var(--radius-control)
56
+ {color.text.muted} → var(--color-text-muted)
57
+ ```
58
+
59
+ 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.
60
+
61
+ `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.
62
+
63
+ Path segments named `default` are stripped, mirroring the `@uncinq/design-tokens` convention:
64
+
65
+ ```
66
+ {color.brand.default} → var(--color-brand)
67
+ {color.text.default} → var(--color-text)
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Adding a new component
73
+
74
+ 1. Create `tokens/components/{name}.json` with DTCG structure.
75
+ 2. Run `npm run build`.
76
+
77
+ 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.
78
+
79
+ ---
80
+
81
+ ## Token naming
82
+
83
+ Token JSON paths map directly to CSS custom property names. Use camelCase for compound CSS property names — the build converts them to kebab-case:
84
+
85
+ | JSON path | CSS variable |
86
+ | --- | --- |
87
+ | `btn.border.radius` | `--btn-border-radius` |
88
+ | `btn.color.background` | `--btn-color-background` |
89
+ | `btn.color.background.hover` | `--btn-color-background-hover` |
90
+ | `btn.color.textDecoration` | `--btn-color-text-decoration` |
91
+ | `btn.color.background.default` | `--btn-color-background` (default stripped) |
92
+ | `btn.text.decorationLine` | `--btn-text-decoration-line` |
93
+
94
+ States (`hover`, `active`, `focus`, `disabled`, `checked`) are nested one level deeper under the property group.
95
+
96
+ ---
97
+
98
+ ## References
99
+
100
+ - [Style Dictionary v5 docs](https://styledictionary.com/)
101
+ - [@uncinq/design-tokens](https://github.com/uncinq/design-tokens) — primitive and semantic tokens referenced by this package
102
+
103
+ ---
104
+
105
+ ## The JSON manifest
106
+
107
+ Alongside the CSS, the build writes `dist/tokens.json`: a flat array of every token the package ships.
108
+
109
+ ```json
110
+ [
111
+ {
112
+ "name": "--btn-color-background",
113
+ "value": "var(--color-brand)",
114
+ "type": "color",
115
+ "file": "components/button",
116
+ "description": ""
117
+ }
118
+ ]
119
+ ```
120
+
121
+ The documentation site renders its reference tables from this file, which is why the reference cannot drift from the stylesheets.
122
+
123
+ 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.
124
+
125
+ `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.1",
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": {