You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Design tokens organized as JavaScript modules, ready to be compiled into CSS custom properties. Architecture targets **Tailwind CSS v4** (CSS-first `@theme` / single stylesheet) — tokens live in JS as the source-of-truth and are compiled to CSS variables at build time.
3
+
Design tokens organized as JavaScript modules, compiled into CSS custom properties and a Tailwind config. The pipeline emits **two parallel targets** from the same source:
4
+
5
+
-**`dist/v3/`** — Tailwind v3 preset (`tailwind-preset.js` / `tailwind.config.js`) + a self-contained `globals.css` with `@tailwind` directives, `:root` / `[data-theme=dark]` blocks, responsive `@media` overrides, and the component classes.
Objects with `light` / `dark` variants. Values are `tokenRef(...)` calls that point to primitives (or to other semantic tokens like `theme.surfaces.surface-X`).
155
+
Objects with `light` / `dark` variants. Values are `tokenRef(...)` calls that point to primitives.
120
156
121
157
```js
122
158
// tokens/theme/primary.js
@@ -138,53 +174,89 @@ export const primary = {
138
174
};
139
175
```
140
176
177
+
### Responsive semantic data (`*.data.js`)
178
+
179
+
Containers, spacings, and texts use a per-breakpoint table that `build-tokens.mjs` flattens into `@media` overrides plus matching component classes (`.gap-…`, `.p-…`, `.text-…`, `.px-container`, `.py-container`, `.max-container-width`).
180
+
181
+
```js
182
+
// tokens/semantic/spacings.data.js
183
+
exportconstspacingsData= {
184
+
'gap-sm': { _:'8px', md:'12px', xl:'16px' },
185
+
'gap-md': { _:'12px', md:'16px', xl:'24px' },
186
+
// …
187
+
};
188
+
```
189
+
190
+
`_` is the base value emitted in `:root`; the breakpoint keys (`sm`, `md`, `lg`, `xl`, `2xl`) become media-query overrides.
191
+
141
192
---
142
193
143
-
## 🔧 Compile & inject
194
+
## 🔧 Building & consuming
195
+
196
+
### Building the package
197
+
198
+
```bash
199
+
# emit both v3 and v4 bundles
200
+
pnpm --filter @aziontech/theme build:tokens
201
+
202
+
# only one target
203
+
pnpm --filter @aziontech/theme build:tokens:v3
204
+
pnpm --filter @aziontech/theme build:tokens:v4
205
+
206
+
# v3 + compile final CSS with tailwindcss
207
+
pnpm --filter @aziontech/theme build:css:v3
208
+
```
209
+
210
+
Outputs land in `packages/theme/dist/v3/` and `packages/theme/dist/v4/`.
injectPrimitivesCss(); // <style data-azion-primitives> with all primitive vars
152
-
injectThemeCss(); // <style data-azion-theme> with light+dark theme vars
218
+
exportdefault {
219
+
presets: [themePreset],
220
+
content: ['./src/**/*.{vue,js,ts,jsx,tsx}'],
221
+
darkMode: ['class'],
222
+
}
223
+
```
224
+
225
+
```css
226
+
/* main.css */
227
+
@import'@aziontech/theme/v3/globals.css';
153
228
```
154
229
155
-
Then use the variables anywhere:
230
+
Utilities like `text-default`, `bg-surface`, `border-default`, `text-primary`, `gap-md`, `p-md`, `.text-heading-lg`, etc. are then available everywhere.
231
+
232
+
### Consuming in a Tailwind v4 project
156
233
157
234
```css
158
-
.btn {
159
-
background: var(--primary);
160
-
color: var(--primary-contrast);
161
-
padding: var(--spacing-2) var(--spacing-4);
162
-
border-radius: var(--radius-md);
163
-
font-size: var(--font-size-sm);
164
-
}
165
-
.btn:hover { background: var(--primary-hover); }
235
+
/* main.css */
236
+
@import'@aziontech/theme/v4/globals.css';
166
237
```
167
238
168
-
### As CSS strings (Node / SSR / build step)
239
+
No `tailwind.config.js` needed — v4 reads `@theme { … }` directly from the imported CSS.
2. Rebuild. `build-tokens.mjs` emits the base var in `:root`, per-breakpoint `@media` overrides, **and** a matching `.gap-2xl { gap: var(--gap-2xl) }` utility.
312
+
238
313
---
239
314
240
315
## 🔗 Token references (`tokenRef`)
241
316
242
-
`tokenRef(path)` returns a marker object `{ __ref: path }` that the compiler resolves at build time.
243
-
244
-
Supported path prefixes (handled by `scripts/compile-theme.js`):
317
+
`tokenRef(path)` returns a marker object `{ __ref: path }` that the compiler resolves at build time. Supported path prefixes (see `scripts/resolve.js`):
245
318
246
319
| Prefix | Looks up |
247
320
|---|---|
248
321
|`primitives.X.Y.Z`|`tokens/primitives/colors/colors.js` tree (e.g., `primitives.gray.900`, `primitives.alpha.orange.100`) |
Refs of unknown prefixes are left as the raw path string in the output — flag for "this needs resolver support".
255
329
@@ -263,8 +337,9 @@ Local visual harnesses (require a static server because of ESM imports):
263
337
npx http-server packages/theme/src -p 8080
264
338
```
265
339
266
-
-`http://localhost:8080/tests/primitives.html` — all primitives rendered as swatches/scales (396 vars).
267
-
-`http://localhost:8080/tests/theme.html` — semantic tokens with a **light/dark toggle button** (59 + 59 vars). Body, buttons, alerts, surfaces, and swatches all react to the toggle.
340
+
-`http://localhost:8080/tests/primitives.html` — every primitive rendered as a swatch / scale.
341
+
-`http://localhost:8080/tests/theme.html` — semantic tokens with a **light/dark toggle**.
0 commit comments