@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.
package/README.md CHANGED
@@ -4,233 +4,103 @@
4
4
 
5
5
  <img width="1280" height="640" alt="share-component-tokens" src="https://github.com/user-attachments/assets/ef2387ee-2c45-4706-9e28-0f0341a100ed" />
6
6
 
7
- ## What are component tokens?
7
+ Component tokens map semantic values onto the parts of a UI component. 26 components, 390 tokens, authored in [DTCG](https://tr.designtokens.org/format/) JSON and compiled to CSS custom properties.
8
8
 
9
- Component tokens are CSS custom properties scoped to a specific UI component. They sit at the top of the [DTCG](https://tr.designtokens.org/format/) three-layer model:
9
+ ## Installation
10
10
 
11
- ```text
12
- primitive → semantic → component
13
- (raw values) (purpose) (component-scoped)
14
- ```
11
+ This package references semantic tokens from [@uncinq/design-tokens](https://github.com/uncinq/design-tokens), which must be imported first.
15
12
 
16
- Where primitive and semantic tokens are provided by [@uncinq/design-tokens](https://github.com/uncinq/design-tokens), component tokens map those semantic values to specific parts of a component:
13
+ ```bash
14
+ npm install @uncinq/design-tokens @uncinq/component-tokens
15
+ ```
17
16
 
18
17
  ```css
19
- /* semantic token from @uncinq/design-tokens */
20
- --color-brand: var(--color-indigo-600);
21
-
22
- /* component token from @uncinq/component-tokens */
23
- --btn-color-background: var(--color-brand);
18
+ @import '@uncinq/design-tokens';
19
+ @import '@uncinq/component-tokens';
24
20
  ```
25
21
 
26
- A component token answers: **"which semantic value does this part of this component use?"**
27
-
28
- ---
22
+ Per component:
29
23
 
30
- ## Naming convention
31
-
32
- All component tokens follow the pattern: `--{component}-{property}-{sub-property?}-{state?}`
33
-
34
- The property mirrors the CSS property name, so the token reads the same way as the CSS declaration it controls — colors excepted, where `color` leads and the role follows (see the rules below).
35
-
36
- ```text
37
- --{component} --btn
38
- -{property} --btn-padding-inline
39
- -{sub-property} --btn-color-text-decoration
40
- -{state} --btn-color-background-hover
24
+ ```css
25
+ @import '@uncinq/design-tokens';
26
+ @import '@uncinq/component-tokens/css/components/button.css';
41
27
  ```
42
28
 
43
- ### Rules
29
+ Without a build step:
44
30
 
45
- - **Lowercase kebab-case** — always
46
- - **Component name first** — `--btn-*`, `--badge-*`, `--hero-*`
47
- - **`color-[role]` for all color tokens** — `color` is the category prefix, the UI role follows: `color-background`, `color-border`, `color-text`, `color-accent`, `color-placeholder`. This groups all color tokens alphabetically under `color-*`. `background` is never abbreviated: `color-background` not `color-bg`.
48
- - **States at the end** — `-hover`, `-focus`, `-active`, `-disabled`
49
- - **Reference semantic tokens** — never raw values; always `var(--semantic-token)`
50
- - **Alphabetical order** — tokens within a file are sorted alphabetically within each group; group related tokens with a comment when the component has many properties:
31
+ ```html
32
+ <link rel="stylesheet" href="https://unpkg.com/@uncinq/design-tokens">
33
+ <link rel="stylesheet" href="https://unpkg.com/@uncinq/component-tokens">
34
+ ```
51
35
 
52
- | Token | Role | CSS property |
53
- | --- | --- | --- |
54
- | `--btn-color-background` | background | `background-color` |
55
- | `--btn-color-border` | border | `border-color` |
56
- | `--btn-color-text` | text | `color` |
57
- | `--btn-color-text-decoration` | text-decoration | `text-decoration-color` |
58
- | `--form-color-accent` | accent | `color` |
59
- | `--input-color-placeholder` | placeholder | `color` |
36
+ ## Where this sits
60
37
 
61
- ```css
62
- /* Border */
63
- --btn-border-radius: var(--radius-control);
64
- --btn-border-width: var(--border-width-sm);
65
-
66
- /* Color */
67
- --btn-color-background: var(--color-brand);
68
- --btn-color-border: var(--color-brand);
69
- --btn-color-text: var(--color-text-on-brand);
70
- --btn-color-text-decoration: transparent;
71
-
72
- /* Spacing */
73
- --btn-gap: var(--spacing-xs);
74
- --btn-padding-inline: var(--spacing-control);
75
- --btn-padding-block: var(--spacing-control);
76
38
  ```
77
-
78
- ### Examples
39
+ primitive → semantic → component
40
+ (raw values) (purpose) (this package)
41
+ ```
79
42
 
80
43
  ```css
81
- --btn-color-background: var(--color-brand);
82
- --btn-color-border: var(--color-brand);
83
- --btn-color-text: var(--color-text-on-brand);
84
- --btn-border-radius: var(--radius-control);
85
- --btn-padding-inline: var(--spacing-control);
86
- --btn-padding-block: var(--spacing-control);
87
-
88
- --badge-border-radius: var(--radius-sm);
89
- --badge-color-background: var(--color-background-muted);
90
-
91
- --hero-color-background: var(--color-background);
92
- --hero-color-text: var(--color-text);
93
- --hero-media-brightness: 0.5;
44
+ --color-sienna-600: oklch(0.53 0.195 22); /* primitive */
45
+ --color-brand: var(--color-sienna-600); /* semantic */
46
+ --btn-color-background: var(--color-brand); /* component */
94
47
  ```
95
48
 
96
- ---
49
+ A component token answers **"which semantic value does this part of this component use?"**. The extra hop is what lets a project restyle buttons alone without moving the brand color, and what records accessibility decisions such as `--btn-color-text: var(--color-text-on-brand)`.
97
50
 
98
- ## CSS cascade layers
51
+ ## Overriding
99
52
 
100
- All tokens are declared inside `@layer tokens`, the lowest-priority layer in the stack. This means any project can override any token simply by declaring its own `@layer tokens` block after this package:
53
+ All tokens live in `@layer tokens`. Re-declare any of them after the import, same layer, later source order wins:
101
54
 
102
55
  ```css
103
- @import '@uncinq/component-tokens';
104
-
105
- /* your project overrides — same layer, wins by source order */
106
56
  @layer tokens {
107
57
  :root {
108
58
  --btn-color-background: var(--color-light);
109
- --hero-height: 80svh;
59
+ --btn-border-radius: 0;
110
60
  }
111
61
  }
112
62
  ```
113
63
 
114
- ---
115
-
116
- ## Prerequisites
117
-
118
- This package references semantic tokens from [@uncinq/design-tokens](https://github.com/uncinq/design-tokens). Import it before this package:
64
+ Because they are custom properties, a scoped override works too, and is usually the better tool for a contextual variation:
119
65
 
120
66
  ```css
121
- @import '@uncinq/design-tokens';
122
- @import '@uncinq/component-tokens';
123
- ```
124
-
125
- ---
126
-
127
- ## Installation
128
-
129
- ```bash
130
- npm install @uncinq/component-tokens
131
- # or
132
- yarn add @uncinq/component-tokens
133
- ```
134
-
135
- ### Usage — full import
136
-
137
- ```css
138
- @import '@uncinq/design-tokens';
139
- @import '@uncinq/component-tokens';
140
- ```
141
-
142
- ### Usage — per component
143
-
144
- ```css
145
- @import '@uncinq/design-tokens';
146
- @import '@uncinq/component-tokens/css/components/button.css';
147
- @import '@uncinq/component-tokens/css/components/badge.css';
148
- ```
149
-
150
- ### Usage — CDN (no build step)
151
-
152
- ```html
153
- <link rel="stylesheet" href="https://unpkg.com/@uncinq/design-tokens">
154
- <link rel="stylesheet" href="https://unpkg.com/@uncinq/component-tokens">
67
+ .promo-section {
68
+ --btn-color-background: var(--color-light);
69
+ }
155
70
  ```
156
71
 
157
- ---
72
+ ## Components covered
158
73
 
159
- ## Customization
74
+ `alert` `badge` `breadcrumb` `button` `card` `carousel` `container` `details` `drawer` `dropdown` `embed` `figure` `heading` `hero` `item` `items` `link` `list` `logo` `map` `media` `modal` `nav` `pagination` `surtitle` `table`
160
75
 
161
- ### CSS override (recommended)
76
+ ## Documentation
162
77
 
163
- Re-declare any token inside `@layer tokens` after the import. Same layer, later source order wins:
78
+ Full documentation: **[socle.uncinq.dev/docs/component-tokens/](https://socle.uncinq.dev/docs/component-tokens/)**
164
79
 
165
- ```css
166
- @import '@uncinq/component-tokens';
80
+ It is also versioned with the code in [`docs/`](docs/), and ships inside the npm package, so it is readable offline and from `node_modules`:
167
81
 
168
- @layer tokens {
169
- :root {
170
- --btn-color-background: var(--color-light);
171
- --btn-border-radius: 0;
172
- }
173
- }
174
- ```
175
-
176
- ### JSON + rebuild
82
+ - [Naming](docs/naming.md) — the grammar, and why colors invert the property order
83
+ - [Customizing](docs/customizing.md) — which layer to override, and when to add a token
84
+ - [Reference](docs/reference.md) — every token for all 26 components, generated from the sources
85
+ - [DTCG format](docs/dtcg.md) — the authoring format
86
+ - [Style Dictionary](docs/style-dictionary.md) — the build and cross-package references
177
87
 
178
- For deeper changes (adding new tokens, renaming), fork the JSON source files and run the build pipeline locally:
88
+ ## Build
179
89
 
180
90
  ```bash
181
- npm install
182
- npm run build # generates dist/css/components/*.css
91
+ npm install # @uncinq/design-tokens is required to resolve references
92
+ npm run build # tokens/**/*.json dist/css/**
183
93
  ```
184
94
 
185
- See [docs/STYLE-DICTIONARY.md](docs/STYLE-DICTIONARY.md) for build pipeline details and token naming conventions.
186
-
187
- ---
188
-
189
- ## File structure
190
-
191
- ```text
192
- tokens/ ← DTCG JSON source files (edit these)
193
- components/
194
- alert.json
195
- badge.json
196
- button.json
197
-
198
-
199
- dist/css/ ← generated CSS (do not edit)
200
- index.css ← imports all component token files
201
- components/
202
- alert.css ← alert / notification banner
203
- badge.css ← badge / pill / tag
204
- breadcrumb.css ← breadcrumb navigation
205
- button.css ← button (all variants)
206
- card.css ← card (alias → item tokens)
207
- carousel.css ← carousel / slider
208
- container.css ← layout container + grid columns
209
- details.css ← <details> / accordion
210
- drawer.css ← off-canvas panel / drawer
211
- dropdown.css ← dropdown menu
212
- embed.css ← video / iframe embed wrapper
213
- figure.css ← <figure> + <figcaption>
214
- heading.css ← heading typography scale
215
- hero.css ← hero / banner section
216
- item.css ← item (canonical card-like unit)
217
- items.css ← items grid / list wrapper
218
- link.css ← inline link
219
- list.css ← styled list
220
- logo.css ← logotype
221
- map.css ← embedded map
222
- media.css ← media object (image + text)
223
- modal.css ← centered dialog / modal
224
- nav.css ← navigation bar
225
- pagination.css ← pagination control
226
- surtitle.css ← small label above a heading
227
- table.css ← data table
228
- ```
229
-
230
- ---
95
+ Token files are discovered from disk, so adding `tokens/components/{name}.json` needs no other edit: both the component CSS and `dist/css/index.css` are regenerated. `dist/` is generated and committed, never edit it by hand.
231
96
 
232
97
  ## References
233
98
 
234
99
  - [DTCG specification](https://tr.designtokens.org/format/) — W3C Community Group draft
235
- - [@uncinq/design-tokens](https://github.com/uncinq/design-tokens) — primitive + semantic layers
100
+ - [`@uncinq/design-tokens`](https://github.com/uncinq/design-tokens) — primitive and semantic layers
101
+ - [`@uncinq/css-components`](https://github.com/uncinq/css-components) — the CSS consuming these tokens
236
102
  - [MDN: CSS cascade layers](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Cascade_layers)
103
+
104
+ ## License
105
+
106
+ MIT © [Un Cinq](https://uncinq.dev/)
@@ -13,6 +13,8 @@
13
13
  --drawer-color-background: var(--color-background-surface);
14
14
  --drawer-color-border: var(--color-border);
15
15
  --drawer-color-text: var(--color-text-on-surface);
16
+ --drawer-color-text-active: var(--color-text-on-surface);
17
+ --drawer-color-text-hover: var(--color-text-on-surface);
16
18
  --drawer-end: 0;
17
19
  --drawer-height: 50vh;
18
20
  --drawer-padding-block: var(--spacing-surface);
@@ -12,6 +12,8 @@
12
12
  --modal-color-background: var(--color-background-surface);
13
13
  --modal-color-border: var(--color-border);
14
14
  --modal-color-text: var(--color-text-on-surface);
15
+ --modal-color-text-active: var(--color-text-on-surface);
16
+ --modal-color-text-hover: var(--color-text-on-surface);
15
17
  --modal-margin: var(--spacing-sm);
16
18
  --modal-max-height: 100dvh;
17
19
  --modal-max-width: 30rem;