@aziontech/theme 4.2.0 → 4.3.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 +110 -335
- package/dist/v4/globals.css +249 -72
- package/dist/v4/globals.scss +249 -72
- package/package.json +4 -13
- package/src/scripts/build-tokens.mjs +57 -7
- package/src/scripts/compile-primitives.js +9 -5
- package/src/scripts/compile-theme.js +12 -6
- package/src/scripts/refs.d.ts +1 -0
- package/src/scripts/refs.d.ts.map +1 -1
- package/src/scripts/refs.js +11 -0
- package/src/scripts/zero-unit.mjs +64 -0
- package/src/tokens/README.md +44 -29
- package/src/tokens/index.d.ts +0 -1
- package/src/tokens/index.js +0 -1
- package/src/tokens/primitives/animations/animate.d.ts +6 -0
- package/src/tokens/primitives/animations/animate.d.ts.map +1 -1
- package/src/tokens/primitives/animations/animate.js +14 -3
- package/src/tokens/primitives/animations/keyframes.d.ts +13 -1
- package/src/tokens/primitives/animations/keyframes.d.ts.map +1 -1
- package/src/tokens/primitives/animations/keyframes.js +23 -4
- package/src/tokens/primitives/colors/colors.d.ts +4 -0
- package/src/tokens/primitives/colors/colors.d.ts.map +1 -1
- package/src/tokens/primitives/colors/colors.js +9 -0
- package/src/tokens/primitives/shape/container.d.ts.map +1 -1
- package/src/tokens/primitives/shape/container.js +30 -13
- package/src/tokens/primitives/typography/leading.d.ts +1 -0
- package/src/tokens/primitives/typography/leading.js +1 -0
- package/src/tokens/primitives/typography/tracking.js +12 -6
- package/src/tokens/semantic/colors.js +5 -2
- package/src/tokens/semantic/layouts.data.d.ts +65 -0
- package/src/tokens/semantic/layouts.data.d.ts.map +1 -0
- package/src/tokens/semantic/layouts.data.js +282 -0
- package/src/tokens/semantic/texts.data.d.ts +28 -10
- package/src/tokens/semantic/texts.data.d.ts.map +1 -1
- package/src/tokens/semantic/texts.data.js +50 -30
- package/src/tokens/semantic/z-indices.data.d.ts +1 -1
- package/src/tokens/semantic/z-indices.data.js +1 -1
- package/src/tokens/theme/accent.js +18 -6
- package/src/tokens/theme/background.d.ts +12 -0
- package/src/tokens/theme/background.js +11 -2
- package/src/tokens/theme/border.js +26 -4
- package/src/tokens/theme/code-sintax.d.ts +6 -0
- package/src/tokens/theme/code-sintax.js +2 -0
- package/src/tokens/theme/feedback/info.js +2 -2
- package/src/tokens/theme/surfaces.d.ts +12 -0
- package/src/tokens/theme/surfaces.d.ts.map +1 -1
- package/src/tokens/theme/surfaces.js +4 -0
- package/src/tokens/theme/text.js +2 -2
- package/src/tokens/theme.d.ts +4 -0
- package/src/scripts/css-vars.d.ts +0 -7
- package/src/scripts/css-vars.d.ts.map +0 -1
- package/src/scripts/css-vars.js +0 -46
- package/src/scripts/resolve.d.ts +0 -5
- package/src/scripts/resolve.d.ts.map +0 -1
- package/src/scripts/resolve.js +0 -107
package/README.md
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
# @aziontech/theme
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Azion's design-token system, compiled into a single **Tailwind CSS v4** stylesheet: primitive palettes, brand colors, light/dark semantic tokens, the full text-style scale, motion utilities and `@keyframes`, and the `@font-face` set — plus the raw token data as importable JavaScript.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- **Design Tokens**: Primitives and Semantic Colors tokens generated from Figma Variables;
|
|
8
|
-
- **Brand Colors**: Azion's official color palette with primary (orange), accent (violet), and surface colors;
|
|
9
|
-
- **Theme Support**: Built-in light and dark mode theming;
|
|
10
|
-
- **Tailwind Integration**: Plugin and preset for seamless Tailwind CSS integration;
|
|
11
|
-
- **CSS Variables**: Automatic CSS variable generation for dynamic theming;
|
|
12
|
-
- **Widget Support**: Separate theme variant for embedded widgets;
|
|
5
|
+
The package ships one prebuilt artifact (`dist/v4/globals.css`) and four small JS entry points. There is no Tailwind preset, plugin, or `tailwind.config.js` step — v4 reads the `@theme` / `@utility` definitions directly from the imported CSS.
|
|
13
6
|
|
|
14
7
|
## Installation
|
|
15
8
|
|
|
@@ -21,429 +14,211 @@ pnpm add @aziontech/theme
|
|
|
21
14
|
yarn add @aziontech/theme
|
|
22
15
|
```
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### Option 1: CSS Import (Recommended for web applications)
|
|
17
|
+
Tailwind CSS v4 must be present in the consuming build — the stylesheet begins with `@import "tailwindcss"`.
|
|
27
18
|
|
|
28
|
-
|
|
19
|
+
## Quick start
|
|
29
20
|
|
|
30
|
-
|
|
31
|
-
// Default theme (includes light/dark mode support)
|
|
32
|
-
import '@aziontech/theme'
|
|
33
|
-
```
|
|
21
|
+
### 1. Import the stylesheet
|
|
34
22
|
|
|
35
|
-
|
|
23
|
+
In your app's root CSS:
|
|
36
24
|
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
<!-- Your application content -->
|
|
40
|
-
</div>
|
|
41
|
-
|
|
42
|
-
<!-- For dark mode -->
|
|
43
|
-
<div class="azion azion-dark">
|
|
44
|
-
<!-- Your application content -->
|
|
45
|
-
</div>
|
|
25
|
+
```css
|
|
26
|
+
@import '@aziontech/theme';
|
|
46
27
|
```
|
|
47
28
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
#### Using the Preset
|
|
51
|
-
|
|
52
|
-
Add the preset to your `tailwind.config.js`:
|
|
29
|
+
or from JavaScript (Vite and friends):
|
|
53
30
|
|
|
54
31
|
```javascript
|
|
55
|
-
import
|
|
56
|
-
|
|
57
|
-
export default {
|
|
58
|
-
presets: [preset]
|
|
59
|
-
// your config
|
|
60
|
-
}
|
|
32
|
+
import '@aziontech/theme'
|
|
61
33
|
```
|
|
62
34
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
For static utility classes with light/dark mode support:
|
|
35
|
+
That single import provides:
|
|
66
36
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
tokenUtilities({
|
|
73
|
-
darkSelector: '.dark',
|
|
74
|
-
extraDarkSelectors: ['.azion.azion-dark']
|
|
75
|
-
})
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
```
|
|
37
|
+
- the `@font-face` declarations for the Azion type system (no separate font imports needed);
|
|
38
|
+
- every primitive CSS variable (colors, spacing, shape, typography, effects, breakpoints);
|
|
39
|
+
- the semantic light/dark variables (`--primary`, `--text-default`, `--surface-0`…);
|
|
40
|
+
- text-style utilities (`text-heading-2xl`, `text-big-number-md`, …) with responsive sizes;
|
|
41
|
+
- animation utilities and their `@keyframes` (consumers pair every motion class with a `motion-reduce:` fallback).
|
|
79
42
|
|
|
80
|
-
###
|
|
43
|
+
### 2. Switch themes
|
|
81
44
|
|
|
82
|
-
|
|
45
|
+
Light is the default (`:root`). Dark mode activates on any of these hooks:
|
|
83
46
|
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
borderSemantic
|
|
93
|
-
} from '@aziontech/theme/tokens'
|
|
94
|
-
|
|
95
|
-
// Use primitive colors
|
|
96
|
-
const primaryColor = primitives.orange['500'] // '#fe601f'
|
|
97
|
-
const accentColor = primitives.violet['500'] // '#8a84ec'
|
|
98
|
-
|
|
99
|
-
// Use semantic tokens (returns token references)
|
|
100
|
-
const textColor = textSemantic.light.textColorBase // tokenRef('primitives.neutral.900')
|
|
47
|
+
```html
|
|
48
|
+
<html data-theme="dark">
|
|
49
|
+
<!-- or -->
|
|
50
|
+
<body class="dark">
|
|
51
|
+
<!-- or the legacy pair -->
|
|
52
|
+
<div class="azion azion-dark"></div>
|
|
53
|
+
</body>
|
|
54
|
+
</html>
|
|
101
55
|
```
|
|
102
56
|
|
|
103
|
-
### Option 4: CSS Variables Injection
|
|
104
|
-
|
|
105
|
-
Inject CSS variables dynamically at runtime:
|
|
106
|
-
|
|
107
57
|
```javascript
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// Injects <style data-azion-tokens> into document.head
|
|
111
|
-
const styleElement = injectCssVars()
|
|
58
|
+
// Toggle at runtime
|
|
59
|
+
document.documentElement.dataset.theme = 'dark' // or 'light'
|
|
112
60
|
```
|
|
113
61
|
|
|
114
|
-
|
|
62
|
+
Light-mode selectors: `:root`, `[data-theme='light']`, `.azion.azion-light`.
|
|
63
|
+
Dark-mode selectors: `[data-theme='dark']`, `.dark`, `.azion.azion-dark`.
|
|
115
64
|
|
|
116
|
-
|
|
65
|
+
## Exports
|
|
117
66
|
|
|
118
|
-
|
|
67
|
+
The entire public surface, from `package.json#exports`:
|
|
119
68
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
primitives
|
|
124
|
-
primitives
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
```
|
|
69
|
+
| Path | What it is |
|
|
70
|
+
| ------------------------------- | -------------------------------------------------------------------------- |
|
|
71
|
+
| `@aziontech/theme` | the compiled stylesheet (`dist/v4/globals.css`) |
|
|
72
|
+
| `@aziontech/theme/colors` | color primitives: `primitives`, `brandPrimitives`, `surfacePrimitives` |
|
|
73
|
+
| `@aziontech/theme/animations` | motion primitives: `animate`, `curve`, `duration`, `useWhen` |
|
|
74
|
+
| `@aziontech/theme/texts` | `textsData` — font-size/line-height/weight bundles per text style |
|
|
75
|
+
| `@aziontech/theme/theme-colors` | semantic compiler: `compileThemeVars`, `compileThemeCss`, `injectThemeCss` |
|
|
128
76
|
|
|
129
|
-
|
|
77
|
+
## JavaScript token access
|
|
130
78
|
|
|
131
|
-
|
|
132
|
-
- `orange`: Primary brand color (11 shades)
|
|
133
|
-
- `violet`: Accent brand color (11 shades)
|
|
134
|
-
- `neutral`: Gray scale for surfaces (11 shades)
|
|
135
|
-
- `gray`, `slate`: Additional gray variants
|
|
136
|
-
- `red`: Semantic danger color
|
|
137
|
-
- `green`: Semantic success color
|
|
138
|
-
- `yellow`: Semantic warning color
|
|
139
|
-
- `blue`: Link colors
|
|
140
|
-
|
|
141
|
-
### Brand Primitives
|
|
142
|
-
|
|
143
|
-
Azion-specific brand colors:
|
|
79
|
+
### Color primitives
|
|
144
80
|
|
|
145
81
|
```javascript
|
|
146
|
-
import { brandPrimitives } from '@aziontech/theme/
|
|
82
|
+
import { primitives, brandPrimitives, surfacePrimitives } from '@aziontech/theme/colors'
|
|
147
83
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
```
|
|
84
|
+
primitives.orange[500] // '#F3652B' — primary brand
|
|
85
|
+
primitives.blue[500] // '#0072F5' — accent
|
|
86
|
+
primitives.violet[500] // '#8A84EC' — brand.accent palette
|
|
87
|
+
primitives.gray[900] // '#141414'
|
|
153
88
|
|
|
154
|
-
|
|
89
|
+
brandPrimitives.primary[500] // '#F3652B'
|
|
90
|
+
brandPrimitives.absolute.white // '#FFFFFF'
|
|
155
91
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
```javascript
|
|
159
|
-
import { surfacePrimitives } from '@aziontech/theme/tokens'
|
|
160
|
-
|
|
161
|
-
surfacePrimitives.surface['0'] // White
|
|
162
|
-
surfacePrimitives.surface['50'] // Lightest gray
|
|
163
|
-
surfacePrimitives.surface['900'] // Very dark gray
|
|
164
|
-
surfacePrimitives.surface['950'] // Almost black
|
|
92
|
+
surfacePrimitives.surface[0] // '#FFFFFF'
|
|
93
|
+
surfacePrimitives.surface[950] // '#0A0A0A'
|
|
165
94
|
```
|
|
166
95
|
|
|
167
|
-
|
|
96
|
+
Available palettes: `base`, `blue`, `gray`, `slate`, `orange`, `violet`, `yellow`, `green`, `red` — plus the `brand`, `surface`, and `alpha` groups.
|
|
168
97
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
#### Background Tokens
|
|
98
|
+
### Motion primitives
|
|
172
99
|
|
|
173
100
|
```javascript
|
|
174
|
-
import {
|
|
175
|
-
|
|
176
|
-
// Light mode
|
|
177
|
-
backgroundSemantic.light.bgLayer1 // Surface 0 (white)
|
|
178
|
-
backgroundSemantic.light.bgLayer2 // Surface 50
|
|
179
|
-
backgroundSemantic.light.bgCanvas // Surface 100
|
|
101
|
+
import { curve, duration, animate } from '@aziontech/theme/animations'
|
|
180
102
|
|
|
181
|
-
//
|
|
182
|
-
|
|
183
|
-
|
|
103
|
+
curve['productive-exit'] // easing cubic-bezier
|
|
104
|
+
duration['fast-02'] // ms value
|
|
105
|
+
animate.shimmer // keyframe-backed animation definition
|
|
184
106
|
```
|
|
185
107
|
|
|
186
|
-
|
|
108
|
+
### Text styles
|
|
187
109
|
|
|
188
110
|
```javascript
|
|
189
|
-
import {
|
|
190
|
-
|
|
191
|
-
// Light mode
|
|
192
|
-
textSemantic.light.textColorBase // neutral.900
|
|
193
|
-
textSemantic.light.textColorMuted // neutral.600
|
|
194
|
-
textSemantic.light.textColorLink // blue.600
|
|
195
|
-
|
|
196
|
-
// Dark mode
|
|
197
|
-
textSemantic.dark.textColorBase // neutral.50
|
|
198
|
-
textSemantic.dark.textColorMuted // neutral.400
|
|
199
|
-
textSemantic.dark.textColorLink // blue.300
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
#### Border Tokens
|
|
203
|
-
|
|
204
|
-
```javascript
|
|
205
|
-
import { borderSemantic } from '@aziontech/theme/tokens'
|
|
206
|
-
|
|
207
|
-
borderSemantic.light.borderBase // surface.200
|
|
208
|
-
borderSemantic.light.borderPrimary // primary.500
|
|
209
|
-
borderSemantic.light.borderDanger // red.600
|
|
210
|
-
|
|
211
|
-
borderSemantic.dark.borderBase // surface.700
|
|
212
|
-
borderSemantic.dark.borderDanger // red.400
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## Theming
|
|
111
|
+
import { textsData } from '@aziontech/theme/texts'
|
|
216
112
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
```html
|
|
220
|
-
<div class="azion azion-light">
|
|
221
|
-
<!-- Light theme content -->
|
|
222
|
-
</div>
|
|
113
|
+
textsData['text-heading-2xl']
|
|
114
|
+
// { fontSize: { _: '1.875rem', sm: '3rem', md: '3.5rem' }, lineHeight: 1.25, fontWeight: 400 }
|
|
223
115
|
```
|
|
224
116
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
```html
|
|
228
|
-
<div class="azion azion-dark">
|
|
229
|
-
<!-- Dark theme content -->
|
|
230
|
-
</div>
|
|
231
|
-
```
|
|
117
|
+
Responsive `fontSize` keys (`_`, `sm`, `md`, …) become `@media (min-width: …)` overrides in the compiled utilities.
|
|
232
118
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
```html
|
|
236
|
-
<div class="azion dark">
|
|
237
|
-
<!-- Dark theme content -->
|
|
238
|
-
</div>
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Dynamic Theme Switching
|
|
119
|
+
### Semantic variables as JS (Node / build steps / runtime)
|
|
242
120
|
|
|
243
121
|
```javascript
|
|
244
|
-
|
|
245
|
-
const root = document.querySelector('.azion')
|
|
246
|
-
root.classList.toggle('azion-dark')
|
|
247
|
-
root.classList.toggle('azion-light')
|
|
248
|
-
```
|
|
122
|
+
import { compileThemeVars, compileThemeCss, injectThemeCss } from '@aziontech/theme/theme-colors'
|
|
249
123
|
|
|
250
|
-
|
|
124
|
+
compileThemeVars()
|
|
125
|
+
// → { light: { '--primary': '#F3652B', '--text-default': '#141414', … }, dark: { … } }
|
|
251
126
|
|
|
252
|
-
|
|
127
|
+
compileThemeCss()
|
|
128
|
+
// → ':root, [data-theme=light], .azion.azion-light { … }\n\n[data-theme=dark], .dark, … { … }'
|
|
253
129
|
|
|
254
|
-
|
|
255
|
-
<!-- Background colors -->
|
|
256
|
-
<div class="bg-layer1">Layer 1 background</div>
|
|
257
|
-
<div class="bg-canvas">Canvas background</div>
|
|
258
|
-
<div class="bg-base">Base background</div>
|
|
259
|
-
|
|
260
|
-
<!-- Text colors -->
|
|
261
|
-
<p class="text-base">Base text</p>
|
|
262
|
-
<p class="text-muted">Muted text</p>
|
|
263
|
-
<a class="text-link">Link text</a>
|
|
264
|
-
|
|
265
|
-
<!-- Border colors -->
|
|
266
|
-
<div class="border border-base">Default border</div>
|
|
267
|
-
<div class="border border-primary">Primary border</div>
|
|
130
|
+
injectThemeCss() // appends a <style data-azion-theme> element to <head>
|
|
268
131
|
```
|
|
269
132
|
|
|
270
|
-
|
|
133
|
+
Only useful when you can't precompile — production usage should prefer the static stylesheet.
|
|
271
134
|
|
|
272
|
-
|
|
135
|
+
## CSS variables
|
|
273
136
|
|
|
274
|
-
|
|
275
|
-
<!-- These generate static values for both light and dark -->
|
|
276
|
-
<div class="bg-layer1">Light: white / Dark: surface-800</div>
|
|
277
|
-
<div class="text-base">Light: neutral-900 / Dark: neutral-50</div>
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### Complete Tailwind Config Example
|
|
281
|
-
|
|
282
|
-
```javascript
|
|
283
|
-
import { preset, tokenUtilities } from '@aziontech/theme/tokens'
|
|
284
|
-
|
|
285
|
-
export default {
|
|
286
|
-
content: ['./src/**/*.{js,ts,jsx,tsx}'],
|
|
287
|
-
presets: [preset],
|
|
288
|
-
darkMode: 'class',
|
|
289
|
-
plugins: [
|
|
290
|
-
tokenUtilities({
|
|
291
|
-
darkSelector: '.dark',
|
|
292
|
-
extraDarkSelectors: ['.azion.azion-dark']
|
|
293
|
-
})
|
|
294
|
-
]
|
|
295
|
-
}
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
## CSS Variables
|
|
299
|
-
|
|
300
|
-
All semantic tokens are available as CSS variables:
|
|
137
|
+
The semantic layer flips automatically between modes:
|
|
301
138
|
|
|
302
139
|
```css
|
|
303
|
-
/* Automatically generated */
|
|
304
140
|
:root,
|
|
305
141
|
[data-theme='light'],
|
|
306
142
|
.azion.azion-light {
|
|
307
|
-
--
|
|
308
|
-
--text-
|
|
309
|
-
|
|
310
|
-
--border-default: #e5e5e5;
|
|
143
|
+
--primary: #f3652b;
|
|
144
|
+
--text-default: #141414;
|
|
145
|
+
/* … */
|
|
311
146
|
}
|
|
312
147
|
|
|
313
148
|
[data-theme='dark'],
|
|
314
149
|
.dark,
|
|
315
150
|
.azion.azion-dark {
|
|
316
151
|
--text-default: #fafafa;
|
|
317
|
-
|
|
318
|
-
--background-surface: #262626;
|
|
319
|
-
--border-default: #404040;
|
|
152
|
+
/* … */
|
|
320
153
|
}
|
|
321
154
|
```
|
|
322
155
|
|
|
323
|
-
Use
|
|
156
|
+
Use them directly:
|
|
324
157
|
|
|
325
158
|
```css
|
|
326
159
|
.custom-component {
|
|
327
160
|
color: var(--text-default);
|
|
328
|
-
|
|
329
|
-
border-color: var(--border-default);
|
|
161
|
+
border-color: var(--primary);
|
|
330
162
|
}
|
|
331
163
|
```
|
|
332
164
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
For embedded widgets and iframes, use the widget theme variant:
|
|
336
|
-
|
|
337
|
-
```javascript
|
|
338
|
-
import '@aziontech/theme/widget'
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
The widget theme includes:
|
|
342
|
-
|
|
343
|
-
- Compact variable definitions
|
|
344
|
-
- Optimized for isolated contexts
|
|
345
|
-
- Same token structure as main theme
|
|
346
|
-
|
|
347
|
-
## API Reference
|
|
165
|
+
Utility equivalents are generated in the same stylesheet (e.g. `@utility text-default`), so `class="text-default"` works wherever Tailwind runs.
|
|
348
166
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
#### Default Export
|
|
352
|
-
|
|
353
|
-
- `@aziontech/theme` - Main CSS theme (default.js)
|
|
354
|
-
- `@aziontech/theme/widget` - Widget CSS theme (widget.js)
|
|
355
|
-
- `@aziontech/theme/tokens` - JavaScript token system (src/tokens/index.js)
|
|
356
|
-
|
|
357
|
-
#### Token Exports
|
|
358
|
-
|
|
359
|
-
```javascript
|
|
360
|
-
// Primitive tokens
|
|
361
|
-
export { primitives } from './primitives/colors.js'
|
|
362
|
-
export { brandPrimitives, surfacePrimitives } from './primitives/brand.js'
|
|
363
|
-
|
|
364
|
-
// Semantic tokens
|
|
365
|
-
export { textSemantic } from './semantic/text.js'
|
|
366
|
-
export { backgroundSemantic } from './semantic/backgrounds.js'
|
|
367
|
-
export { borderSemantic } from './semantic/borders.js'
|
|
368
|
-
|
|
369
|
-
// Build utilities
|
|
370
|
-
export { tokenRef } from './build/refs.js'
|
|
371
|
-
export { resolveRefsToCssVars } from './build/resolve.js'
|
|
372
|
-
export { createCssVars, cssVarsString, injectCssVars } from './build/css-vars.js'
|
|
373
|
-
export { preset } from './build/preset.js'
|
|
374
|
-
export { tokenUtilities } from './build/tailwind-plugin'
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
## Token Resolution
|
|
167
|
+
## Token resolution
|
|
378
168
|
|
|
379
169
|
Tokens use a reference system for maintainability:
|
|
380
170
|
|
|
381
171
|
```javascript
|
|
382
172
|
// Define token reference
|
|
383
|
-
const textColor = tokenRef('primitives.
|
|
384
|
-
|
|
385
|
-
// Resolve to actual value
|
|
386
|
-
resolveRefsToCssVars({
|
|
387
|
-
primitives,
|
|
388
|
-
textSemantic
|
|
389
|
-
})
|
|
390
|
-
// Output: { '--text-textColorBase': '#171717' }
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
## Development
|
|
173
|
+
const textColor = tokenRef('primitives.gray.900')
|
|
394
174
|
|
|
395
|
-
|
|
175
|
+
// The compilers (scripts/compile-primitives.js, scripts/compile-theme.js)
|
|
176
|
+
// resolve refs to literal values at build time — and throw, listing every
|
|
177
|
+
// miss, if a ref does not resolve.
|
|
178
|
+
compileThemeVars()
|
|
179
|
+
// Output: { light: { '--text-default': '#141414', … }, dark: { … } }
|
|
180
|
+
```
|
|
396
181
|
|
|
397
|
-
|
|
398
|
-
- pnpm (v9+)
|
|
182
|
+
The full reference — supported `tokenRef` prefixes, the build pipeline, how to add a token — lives in [`src/tokens/README.md`](./src/tokens/README.md).
|
|
399
183
|
|
|
400
|
-
|
|
184
|
+
## Development
|
|
401
185
|
|
|
402
186
|
```bash
|
|
403
|
-
#
|
|
404
|
-
pnpm
|
|
405
|
-
|
|
406
|
-
#
|
|
407
|
-
pnpm pack:dry
|
|
408
|
-
|
|
409
|
-
# Publish (requires dist build)
|
|
410
|
-
pnpm publish
|
|
187
|
+
pnpm build:tokens # node src/scripts/build-tokens.mjs → dist/v4/globals.{css,scss}
|
|
188
|
+
pnpm build:dts # vue-tsc --declaration (emit .d.ts next to sources)
|
|
189
|
+
pnpm format # prettier over scripts/ and src/
|
|
190
|
+
pnpm pack:dry # inspect the tarball contents
|
|
411
191
|
```
|
|
412
192
|
|
|
413
|
-
|
|
193
|
+
`dist/` is committed, and `prepack` reruns `build:tokens` + `build:dts` — every publish rebuilds the artifact from source, so a stale or hand-edited `dist/` can never ship.
|
|
194
|
+
|
|
195
|
+
### Project structure
|
|
414
196
|
|
|
415
197
|
```
|
|
416
198
|
packages/theme/
|
|
417
|
-
├──
|
|
418
|
-
├── widget.js # Widget entry point
|
|
199
|
+
├── tokens.js # in-repo JS barrel (not shipped — use the subpath exports)
|
|
419
200
|
├── src/
|
|
420
|
-
│ ├──
|
|
421
|
-
│ │ ├──
|
|
422
|
-
│ │ ├──
|
|
423
|
-
│ │ ├──
|
|
424
|
-
│ │
|
|
425
|
-
│
|
|
426
|
-
│
|
|
427
|
-
│
|
|
428
|
-
│
|
|
429
|
-
│
|
|
430
|
-
|
|
431
|
-
│ ├── semantic/ # Context-aware tokens
|
|
432
|
-
│ └── build/ # Build utilities
|
|
433
|
-
│ ├── preset.js
|
|
434
|
-
│ ├── css-vars.js
|
|
435
|
-
│ └── tailwind-plugin
|
|
201
|
+
│ ├── tokens/
|
|
202
|
+
│ │ ├── primitives/ # colors (brand/surface/alpha), typography, shape, effects, animations, …
|
|
203
|
+
│ │ ├── semantic/ # texts/containers/spacings/z-indices data + semantic color refs
|
|
204
|
+
│ │ ├── theme/ # light/dark semantic groups (primary, background, text, ring, feedback/…)
|
|
205
|
+
│ │ └── README.md # in-depth token documentation
|
|
206
|
+
│ └── scripts/
|
|
207
|
+
│ ├── refs.js # tokenRef + isTokenRef + assertResolvedRefs
|
|
208
|
+
│ ├── compile-primitives.js
|
|
209
|
+
│ ├── compile-theme.js # exported as ./theme-colors
|
|
210
|
+
│ └── build-tokens.mjs # main entrypoint: emits dist/v4
|
|
211
|
+
├── dist/v4/globals.css # the shipped stylesheet (committed; rebuilt on publish)
|
|
436
212
|
└── package.json
|
|
437
213
|
```
|
|
438
214
|
|
|
439
|
-
## Browser
|
|
215
|
+
## Browser support
|
|
440
216
|
|
|
441
|
-
|
|
442
|
-
- Chrome, Firefox, Safari, Edge (latest versions)
|
|
217
|
+
Modern evergreen browsers with CSS custom-properties support (Chrome, Firefox, Safari, Edge).
|
|
443
218
|
|
|
444
219
|
## Versioning
|
|
445
220
|
|
|
446
|
-
This package follows [Semantic Versioning](https://semver.org/).
|
|
221
|
+
This package follows [Semantic Versioning](https://semver.org/). Versions are managed by [release-please](https://github.com/googleapis/release-please): merges to `main` update a Release PR, and merging that Release PR cuts the version and publishes.
|
|
447
222
|
|
|
448
223
|
## Contributing
|
|
449
224
|
|