@phcdevworks/spectre-tokens 0.1.0 → 0.2.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
@@ -6,7 +6,7 @@ Design-token source of truth that powers Spectre UI, Spectre Blocks, Spectre Ast
6
6
 
7
7
  ## Overview
8
8
 
9
- `@phcdevworks/spectre-tokens` defines Spectre's visual language—colors, typography, spacing, radii, shadows, breakpoints, z-index scales, transitions, and CRO-focused interaction states. The package turns the raw JSON tokens in `tokens/` into multiple consumption modes (JS, TS, Tailwind, CSS variables) so that teams can stay in sync regardless of framework. One token system runs the entire Spectre Suite; every other package simply consumes these values.
9
+ `@phcdevworks/spectre-tokens` defines Spectre's visual language—colors, typography, space, radii, shadows, breakpoints, z-index scales, transitions, and CRO-focused interaction states. The package turns the raw JSON tokens in `tokens/` into multiple consumption modes (JS, TS, Tailwind, CSS variables) so that teams can stay in sync regardless of framework. One token system runs the entire Spectre Suite; every other package simply consumes these values.
10
10
 
11
11
  - ✅ Centralized token definitions and semantic naming
12
12
  - ✅ JS/TS objects, Tailwind theme + preset, and CSS variable outputs
@@ -34,7 +34,7 @@ import tokens, {
34
34
  console.log(tokens.colors.brand["500"]); // Brand palette swatches
35
35
  ```
36
36
 
37
- - `tokens`: Raw structured tokens (colors, spacing, radii, typography, shadows, z-index, transitions, buttons, forms, accessibility, animations, opacity).
37
+ - `tokens`: Raw structured tokens (colors, space, layout, radii, typography, shadows, z-index, transitions, buttons, forms, badges, accessibility, animations, opacity, fonts).
38
38
  - `tailwindTheme`: Ready-to-use Tailwind theme object.
39
39
  - `tailwindPreset`: Preset for Tailwind config (includes theme).
40
40
  - `generateCssVariables()`: Generate custom `--sp-*` CSS variable strings with scoped selectors or prefixes.
@@ -160,6 +160,78 @@ tokens.opacity.disabled; // 0.38
160
160
  tokens.opacity.overlay; // 0.5
161
161
  ```
162
162
 
163
+ ### Typography scale
164
+
165
+ ```ts
166
+ tokens.font.fontSize.xs; // 0.75rem
167
+ tokens.font.fontSize.sm; // 0.875rem
168
+ tokens.font.fontSize.base; // 1rem
169
+ tokens.font.fontSize.lg; // 1.25rem
170
+ tokens.font.fontSize.xl; // 1.5rem
171
+
172
+ tokens.font.lineHeight.xs; // 1rem
173
+ tokens.font.lineHeight.sm; // 1.25rem
174
+ tokens.font.lineHeight.base; // 1.5rem
175
+ tokens.font.lineHeight.lg; // 1.75rem
176
+ tokens.font.lineHeight.xl; // 2rem
177
+
178
+ tokens.font.weight.normal; // 400
179
+ tokens.font.weight.medium; // 500
180
+ tokens.font.weight.semibold; // 600
181
+ tokens.font.weight.bold; // 700
182
+ ```
183
+
184
+ ```css
185
+ .heading {
186
+ font-size: var(--sp-font-size-xl);
187
+ line-height: var(--sp-font-line-height-xl);
188
+ font-weight: var(--sp-font-weight-semibold);
189
+ }
190
+
191
+ .body-text {
192
+ font-size: var(--sp-font-size-base);
193
+ line-height: var(--sp-font-line-height-base);
194
+ font-weight: var(--sp-font-weight-normal);
195
+ }
196
+ ```
197
+
198
+ ### Badge tokens
199
+
200
+ ```ts
201
+ tokens.component.badge.bg; // Background color
202
+ tokens.component.badge.text; // Text color
203
+ tokens.component.badge.border; // Border color
204
+ ```
205
+
206
+ ```css
207
+ .badge {
208
+ background: var(--sp-component-badge-bg);
209
+ color: var(--sp-component-badge-text);
210
+ border: 1px solid var(--sp-component-badge-border);
211
+ padding: 0.25rem 0.5rem;
212
+ border-radius: var(--sp-radius-sm);
213
+ font-size: var(--sp-font-size-xs);
214
+ font-weight: var(--sp-font-weight-medium);
215
+ }
216
+ ```
217
+
218
+ ### Meta text
219
+
220
+ For secondary/metadata text styling:
221
+
222
+ ```ts
223
+ tokens.text.onPage.meta; // Metadata text on page backgrounds
224
+ tokens.text.onSurface.meta; // Metadata text on card/surface backgrounds
225
+ ```
226
+
227
+ ```css
228
+ .timestamp,
229
+ .byline {
230
+ color: var(--sp-text-on-page-meta);
231
+ font-size: var(--sp-font-size-sm);
232
+ }
233
+ ```
234
+
163
235
  ### WCAG targets
164
236
 
165
237
  - Brand 500 on white → ✅ AAA (4.8:1)
@@ -171,11 +243,21 @@ tokens.opacity.overlay; // 0.5
171
243
 
172
244
  Always re-run final UI implementations through tools like [WebAIM Contrast Checker](https://webaim.org/resources/contrastchecker/).
173
245
 
246
+ ## Spacing & Layout Tokens
247
+
248
+ - **8px grid**: `space.*` follows an 8px rhythm with a single 4px micro step for fine-grain alignment. Scale: 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 56, 64, 80, 96 (all in px, emitted as rem).
249
+ - **Semantic layout**: `layout.section.padding.{sm,md,lg}` → `space.24/32/48`; `layout.section.gap.{sm,md,lg}` → `space.16/24/32`; `layout.stack.gap.{sm,md,lg}` → `space.8/12/16`; `layout.container.paddingInline.{sm,md,lg}` → `space.16/24/32`.
250
+ - **Outputs**: CSS vars like `--sp-space-24` and `--sp-layout-section-padding-md`; Tailwind `theme.spacing` is sourced from `space.*`.
251
+ - **Usage**: Use `layout.*` for consistent gutters/padding rather than ad-hoc numbers. Example: `gap: var(--sp-layout-stack-gap-md);` or `padding-inline: var(--sp-layout-container-padding-inline-lg);`.
252
+ - **Responsiveness lives in Spectre UI**: apply breakpoint logic and component behavior in `@phcdevworks/spectre-ui` or consumers; keep tokens meaning-only.
253
+
174
254
  ## Surface & Typography Roles
175
255
 
176
256
  - `surface.page`, `surface.card`, `surface.input`, `surface.overlay`: semantic backgrounds for the app canvas, containers/tiles, form fields, and modal/dropdown layers.
177
257
  - `text.onPage.*` vs `text.onSurface.*`: use `onPage` for copy sitting directly on the page canvas; use `onSurface` for text inside cards, tiles, inputs, overlays, and other elevated surfaces.
178
- - `component.card.text`/`textMuted`, `component.input.text`/`placeholder`, and `component.button.textDefault`/`textOnPrimary` alias the underlying `text.onSurface` roles (with `textOnPrimary` pairing white against the primary button background) to keep component defaults aligned.
258
+ - `text.onPage.default`, `text.onPage.muted`, `text.onPage.subtle`, `text.onPage.meta`
259
+ - `text.onSurface.default`, `text.onSurface.muted`, `text.onSurface.subtle`, `text.onSurface.meta`
260
+ - `component.card.text`/`textMuted`, `component.input.text`/`placeholder`, `component.button.textDefault`/`textOnPrimary`, and `component.badge.*` alias the underlying semantic roles to keep component defaults aligned.
179
261
 
180
262
  ## Modes
181
263
 
@@ -195,15 +277,17 @@ Consumers can toggle themes by setting `data-spectre-theme="dark"` on `:root` or
195
277
 
196
278
  These variables are the contract consumed by `@phcdevworks/spectre-ui`; removing or renaming them will break downstream UI packages.
197
279
 
198
- - Surface: `--sp-surface-page`, `--sp-surface-card`, `--sp-surface-input`, `--sp-surface-overlay`
199
- - Text: `--sp-text-on-page-default`, `--sp-text-on-page-muted`, `--sp-text-on-surface-default`, `--sp-text-on-surface-muted`
200
- - Components/buttons: `--sp-component-card-text`, `--sp-component-card-text-muted`, `--sp-component-input-text`, `--sp-component-input-placeholder`, `--sp-button-primary-bg`, `--sp-button-primary-text`, `--sp-button-secondary-bg`, `--sp-button-secondary-text`, `--sp-button-ghost-bg`, `--sp-button-ghost-text`
280
+ - **Surface**: `--sp-surface-page`, `--sp-surface-card`, `--sp-surface-input`, `--sp-surface-overlay`
281
+ - **Text**: `--sp-text-on-page-default`, `--sp-text-on-page-muted`, `--sp-text-on-page-meta`, `--sp-text-on-surface-default`, `--sp-text-on-surface-muted`, `--sp-text-on-surface-meta`
282
+ - **Components**: `--sp-component-card-text`, `--sp-component-card-text-muted`, `--sp-component-input-text`, `--sp-component-input-placeholder`, `--sp-component-badge-bg`, `--sp-component-badge-text`, `--sp-component-badge-border`
283
+ - **Buttons**: `--sp-button-primary-bg`, `--sp-button-primary-text`, `--sp-button-secondary-bg`, `--sp-button-secondary-text`, `--sp-button-ghost-bg`, `--sp-button-ghost-text`
284
+ - **Typography**: `--sp-font-size-{xs,sm,base,lg,xl}`, `--sp-font-line-height-{xs,sm,base,lg,xl}`, `--sp-font-weight-{normal,medium,semibold,bold}`
201
285
 
202
286
  ## Repository Layout
203
287
 
204
288
  | Folder | Responsibility |
205
289
  | ---------- | ------------------------------------------------------------------------------------------------------------- |
206
- | `tokens/` | Raw JSON tokens owned by design. `core.json` holds colors, spacing, radii, typography scales, and shadows. |
290
+ | `tokens/` | Raw JSON tokens owned by design. `core.json` holds colors, space, radii, typography scales, shadows, and layout scales. |
207
291
  | `src/` | TypeScript source that turns JSON into reusable formats (JS/TS exports, Tailwind theme, CSS helpers). |
208
292
  | `scripts/` | Build utilities. `build-css.js` consumes the compiled library and writes `dist/index.css`. |
209
293
  | `dist/` | Generated artifacts: `index.js`, `index.cjs`, `index.d.ts`, and `index.css`. Regenerated via `npm run build`. |
package/dist/index.cjs CHANGED
@@ -167,22 +167,24 @@ var core_default = {
167
167
  textOnPrimary: "#ffffff"
168
168
  },
169
169
  badge: {
170
- primary: {
171
- bg: "#8652ff",
172
- text: "#0f172a"
173
- },
174
- success: {
175
- bg: "#22c55e",
176
- text: "#0f172a"
177
- },
178
- warning: {
179
- bg: "#f59e0b",
180
- text: "#0f172a"
181
- },
182
- danger: {
183
- bg: "#ef4444",
184
- text: "#0f172a"
185
- }
170
+ neutralBg: "#f1f5f9",
171
+ neutralText: "#334155",
172
+ infoBg: "#dbeafe",
173
+ infoText: "#1d4ed8",
174
+ successBg: "#dcfce7",
175
+ successText: "#15803d",
176
+ warningBg: "#fef3c7",
177
+ warningText: "#b45309",
178
+ dangerBg: "#fee2e2",
179
+ dangerText: "#b91c1c"
180
+ },
181
+ iconBox: {
182
+ bg: "#ffffff",
183
+ border: "#e2e8f0",
184
+ iconDefault: "#6c32e6",
185
+ iconSuccess: "#16a34a",
186
+ iconWarning: "#d97706",
187
+ iconDanger: "#dc2626"
186
188
  }
187
189
  },
188
190
  modes: {
@@ -257,37 +259,55 @@ var core_default = {
257
259
  }
258
260
  },
259
261
  badge: {
260
- primary: {
261
- bg: {
262
- value: "#8652ff"
263
- },
264
- text: {
265
- value: "#0f172a"
266
- }
262
+ neutralBg: {
263
+ value: "#f1f5f9"
264
+ },
265
+ neutralText: {
266
+ value: "#334155"
267
+ },
268
+ infoBg: {
269
+ value: "#dbeafe"
270
+ },
271
+ infoText: {
272
+ value: "#1d4ed8"
273
+ },
274
+ successBg: {
275
+ value: "#dcfce7"
276
+ },
277
+ successText: {
278
+ value: "#15803d"
267
279
  },
268
- success: {
269
- bg: {
270
- value: "#22c55e"
271
- },
272
- text: {
273
- value: "#0f172a"
274
- }
280
+ warningBg: {
281
+ value: "#fef3c7"
275
282
  },
276
- warning: {
277
- bg: {
278
- value: "#f59e0b"
279
- },
280
- text: {
281
- value: "#0f172a"
282
- }
283
+ warningText: {
284
+ value: "#b45309"
283
285
  },
284
- danger: {
285
- bg: {
286
- value: "#ef4444"
287
- },
288
- text: {
289
- value: "#0f172a"
290
- }
286
+ dangerBg: {
287
+ value: "#fee2e2"
288
+ },
289
+ dangerText: {
290
+ value: "#b91c1c"
291
+ }
292
+ },
293
+ iconBox: {
294
+ bg: {
295
+ value: "#ffffff"
296
+ },
297
+ border: {
298
+ value: "#e2e8f0"
299
+ },
300
+ iconDefault: {
301
+ value: "#6c32e6"
302
+ },
303
+ iconSuccess: {
304
+ value: "#16a34a"
305
+ },
306
+ iconWarning: {
307
+ value: "#d97706"
308
+ },
309
+ iconDanger: {
310
+ value: "#dc2626"
291
311
  }
292
312
  }
293
313
  }
@@ -363,37 +383,55 @@ var core_default = {
363
383
  }
364
384
  },
365
385
  badge: {
366
- primary: {
367
- bg: {
368
- value: "#8652ff"
369
- },
370
- text: {
371
- value: "#f1f5f9"
372
- }
386
+ neutralBg: {
387
+ value: "#334155"
388
+ },
389
+ neutralText: {
390
+ value: "#f1f5f9"
391
+ },
392
+ infoBg: {
393
+ value: "#1e40af"
373
394
  },
374
- success: {
375
- bg: {
376
- value: "#22c55e"
377
- },
378
- text: {
379
- value: "#f1f5f9"
380
- }
395
+ infoText: {
396
+ value: "#dbeafe"
381
397
  },
382
- warning: {
383
- bg: {
384
- value: "#f59e0b"
385
- },
386
- text: {
387
- value: "#f1f5f9"
388
- }
398
+ successBg: {
399
+ value: "#166534"
389
400
  },
390
- danger: {
391
- bg: {
392
- value: "#ef4444"
393
- },
394
- text: {
395
- value: "#f1f5f9"
396
- }
401
+ successText: {
402
+ value: "#dcfce7"
403
+ },
404
+ warningBg: {
405
+ value: "#92400e"
406
+ },
407
+ warningText: {
408
+ value: "#fef3c7"
409
+ },
410
+ dangerBg: {
411
+ value: "#991b1b"
412
+ },
413
+ dangerText: {
414
+ value: "#fee2e2"
415
+ }
416
+ },
417
+ iconBox: {
418
+ bg: {
419
+ value: "#1e293b"
420
+ },
421
+ border: {
422
+ value: "#334155"
423
+ },
424
+ iconDefault: {
425
+ value: "#a37aff"
426
+ },
427
+ iconSuccess: {
428
+ value: "#4ade80"
429
+ },
430
+ iconWarning: {
431
+ value: "#fbbf24"
432
+ },
433
+ iconDanger: {
434
+ value: "#f87171"
397
435
  }
398
436
  }
399
437
  }
@@ -490,17 +528,49 @@ var core_default = {
490
528
  text: "#94a3b8"
491
529
  }
492
530
  },
493
- spacing: {
494
- none: "0rem",
495
- "3xs": "0.125rem",
496
- "2xs": "0.25rem",
497
- xs: "0.5rem",
498
- sm: "0.75rem",
499
- md: "1rem",
500
- lg: "1.5rem",
501
- xl: "2rem",
502
- "2xl": "3rem",
503
- "3xl": "4rem"
531
+ layout: {
532
+ section: {
533
+ padding: {
534
+ sm: "1.5rem",
535
+ md: "2rem",
536
+ lg: "3rem"
537
+ },
538
+ gap: {
539
+ sm: "1rem",
540
+ md: "1.5rem",
541
+ lg: "2rem"
542
+ }
543
+ },
544
+ stack: {
545
+ gap: {
546
+ sm: "0.5rem",
547
+ md: "0.75rem",
548
+ lg: "1rem"
549
+ }
550
+ },
551
+ container: {
552
+ paddingInline: {
553
+ sm: "1rem",
554
+ md: "1.5rem",
555
+ lg: "2rem"
556
+ }
557
+ }
558
+ },
559
+ space: {
560
+ "0": "0rem",
561
+ "4": "0.25rem",
562
+ "8": "0.5rem",
563
+ "12": "0.75rem",
564
+ "16": "1rem",
565
+ "20": "1.25rem",
566
+ "24": "1.5rem",
567
+ "32": "2rem",
568
+ "40": "2.5rem",
569
+ "48": "3rem",
570
+ "56": "3.5rem",
571
+ "64": "4rem",
572
+ "80": "5rem",
573
+ "96": "6rem"
504
574
  },
505
575
  radii: {
506
576
  none: "0",
@@ -682,11 +752,31 @@ var toVariableName = (prefix, ...parts) => {
682
752
  const filtered = parts.filter(Boolean).map(formatKey);
683
753
  return `--${prefix}-${filtered.join("-")}`;
684
754
  };
755
+ var BADGE_VARIANTS = [
756
+ { variant: "neutral", bgKey: "neutralBg", textKey: "neutralText" },
757
+ { variant: "info", bgKey: "infoBg", textKey: "infoText" },
758
+ { variant: "success", bgKey: "successBg", textKey: "successText" },
759
+ { variant: "warning", bgKey: "warningBg", textKey: "warningText" },
760
+ { variant: "danger", bgKey: "dangerBg", textKey: "dangerText" }
761
+ ];
762
+ var ICON_BOX_FIELDS = [
763
+ { name: "bg", tokenKey: "bg" },
764
+ { name: "border", tokenKey: "border" },
765
+ { name: "icon-default", tokenKey: "iconDefault" },
766
+ { name: "icon-success", tokenKey: "iconSuccess" },
767
+ { name: "icon-warning", tokenKey: "iconWarning" },
768
+ { name: "icon-danger", tokenKey: "iconDanger" }
769
+ ];
685
770
  var createCssVariableMap = (tokens2, options = {}) => {
686
771
  const prefix = options.prefix ?? DEFAULT_PREFIX;
687
772
  const map = {};
688
773
  const baseTokens = tokens2;
689
774
  const assign = (name, value) => {
775
+ const resolved = resolveSemanticValue(value);
776
+ if (resolved !== void 0) {
777
+ map[name] = resolved;
778
+ return;
779
+ }
690
780
  if (value === void 0) return;
691
781
  map[name] = String(value);
692
782
  };
@@ -695,9 +785,34 @@ var createCssVariableMap = (tokens2, options = {}) => {
695
785
  assign(toVariableName(prefix, "color", group, step), value);
696
786
  });
697
787
  });
698
- Object.entries(baseTokens.spacing).forEach(([key, value]) => {
699
- assign(toVariableName(prefix, "space", key), value);
700
- });
788
+ if (baseTokens.space) {
789
+ Object.entries(baseTokens.space).forEach(([key, value]) => {
790
+ assign(toVariableName(prefix, "space", key), value);
791
+ });
792
+ }
793
+ if (baseTokens.layout) {
794
+ const { section, stack, container } = baseTokens.layout;
795
+ if (section?.padding) {
796
+ Object.entries(section.padding).forEach(([key, value]) => {
797
+ assign(toVariableName(prefix, "layout", "section", "padding", key), value);
798
+ });
799
+ }
800
+ if (section?.gap) {
801
+ Object.entries(section.gap).forEach(([key, value]) => {
802
+ assign(toVariableName(prefix, "layout", "section", "gap", key), value);
803
+ });
804
+ }
805
+ if (stack?.gap) {
806
+ Object.entries(stack.gap).forEach(([key, value]) => {
807
+ assign(toVariableName(prefix, "layout", "stack", "gap", key), value);
808
+ });
809
+ }
810
+ if (container?.paddingInline) {
811
+ Object.entries(container.paddingInline).forEach(([key, value]) => {
812
+ assign(toVariableName(prefix, "layout", "container", "padding-inline", key), value);
813
+ });
814
+ }
815
+ }
701
816
  Object.entries(baseTokens.radii).forEach(([key, value]) => {
702
817
  assign(toVariableName(prefix, "radius", key), value);
703
818
  });
@@ -729,14 +844,16 @@ var createCssVariableMap = (tokens2, options = {}) => {
729
844
  assign(toVariableName(prefix, "text", "on", "surface", "meta"), tokens2.text.onSurface.meta);
730
845
  const badge = tokens2.component?.badge;
731
846
  if (badge) {
732
- assign(toVariableName(prefix, "badge", "primary", "bg"), badge.primary.bg);
733
- assign(toVariableName(prefix, "badge", "primary", "text"), badge.primary.text);
734
- assign(toVariableName(prefix, "badge", "success", "bg"), badge.success.bg);
735
- assign(toVariableName(prefix, "badge", "success", "text"), badge.success.text);
736
- assign(toVariableName(prefix, "badge", "warning", "bg"), badge.warning.bg);
737
- assign(toVariableName(prefix, "badge", "warning", "text"), badge.warning.text);
738
- assign(toVariableName(prefix, "badge", "danger", "bg"), badge.danger.bg);
739
- assign(toVariableName(prefix, "badge", "danger", "text"), badge.danger.text);
847
+ BADGE_VARIANTS.forEach(({ variant, bgKey, textKey }) => {
848
+ assign(toVariableName(prefix, "badge", variant, "bg"), badge[bgKey]);
849
+ assign(toVariableName(prefix, "badge", variant, "text"), badge[textKey]);
850
+ });
851
+ }
852
+ const iconBox = tokens2.component?.iconBox;
853
+ if (iconBox) {
854
+ ICON_BOX_FIELDS.forEach(({ name, tokenKey }) => {
855
+ assign(toVariableName(prefix, "icon-box", name), iconBox[tokenKey]);
856
+ });
740
857
  }
741
858
  Object.entries(baseTokens.shadows).forEach(([key, value]) => {
742
859
  assign(toVariableName(prefix, "shadow", key), value);
@@ -823,38 +940,22 @@ var generateCssVariables = (tokens2, options = {}) => {
823
940
  addBase(toVariableName(prefix, "component", "input", "placeholder"), pickSemantic(getPath(defaultMode, ["component", "input", "placeholder"]), getPath(componentAliases, ["input", "placeholder"])));
824
941
  addBase(toVariableName(prefix, "button", "text", "default"), pickSemantic(getPath(defaultMode, ["component", "button", "textDefault"]), getPath(componentAliases, ["button", "textDefault"])));
825
942
  addBase(toVariableName(prefix, "button", "text", "on", "primary"), pickSemantic(getPath(defaultMode, ["component", "button", "textOnPrimary"]), getPath(componentAliases, ["button", "textOnPrimary"])));
826
- addBase(
827
- toVariableName(prefix, "badge", "primary", "bg"),
828
- pickSemantic(getPath(defaultMode, ["component", "badge", "primary", "bg"]), getPath(componentAliases, ["badge", "primary", "bg"]))
829
- );
830
- addBase(
831
- toVariableName(prefix, "badge", "primary", "text"),
832
- pickSemantic(getPath(defaultMode, ["component", "badge", "primary", "text"]), getPath(componentAliases, ["badge", "primary", "text"]))
833
- );
834
- addBase(
835
- toVariableName(prefix, "badge", "success", "bg"),
836
- pickSemantic(getPath(defaultMode, ["component", "badge", "success", "bg"]), getPath(componentAliases, ["badge", "success", "bg"]))
837
- );
838
- addBase(
839
- toVariableName(prefix, "badge", "success", "text"),
840
- pickSemantic(getPath(defaultMode, ["component", "badge", "success", "text"]), getPath(componentAliases, ["badge", "success", "text"]))
841
- );
842
- addBase(
843
- toVariableName(prefix, "badge", "warning", "bg"),
844
- pickSemantic(getPath(defaultMode, ["component", "badge", "warning", "bg"]), getPath(componentAliases, ["badge", "warning", "bg"]))
845
- );
846
- addBase(
847
- toVariableName(prefix, "badge", "warning", "text"),
848
- pickSemantic(getPath(defaultMode, ["component", "badge", "warning", "text"]), getPath(componentAliases, ["badge", "warning", "text"]))
849
- );
850
- addBase(
851
- toVariableName(prefix, "badge", "danger", "bg"),
852
- pickSemantic(getPath(defaultMode, ["component", "badge", "danger", "bg"]), getPath(componentAliases, ["badge", "danger", "bg"]))
853
- );
854
- addBase(
855
- toVariableName(prefix, "badge", "danger", "text"),
856
- pickSemantic(getPath(defaultMode, ["component", "badge", "danger", "text"]), getPath(componentAliases, ["badge", "danger", "text"]))
857
- );
943
+ BADGE_VARIANTS.forEach(({ variant, bgKey, textKey }) => {
944
+ addBase(
945
+ toVariableName(prefix, "badge", variant, "bg"),
946
+ pickSemantic(getPath(defaultMode, ["component", "badge", bgKey]), getPath(componentAliases, ["badge", bgKey]))
947
+ );
948
+ addBase(
949
+ toVariableName(prefix, "badge", variant, "text"),
950
+ pickSemantic(getPath(defaultMode, ["component", "badge", textKey]), getPath(componentAliases, ["badge", textKey]))
951
+ );
952
+ });
953
+ ICON_BOX_FIELDS.forEach(({ name, tokenKey }) => {
954
+ addBase(
955
+ toVariableName(prefix, "icon-box", name),
956
+ pickSemantic(getPath(defaultMode, ["component", "iconBox", tokenKey]), getPath(componentAliases, ["iconBox", tokenKey]))
957
+ );
958
+ });
858
959
  const rootLines = [...baseLines, ...mapLines];
859
960
  const darkLines = [];
860
961
  const addDark = (name, value) => {
@@ -972,70 +1073,34 @@ var generateCssVariables = (tokens2, options = {}) => {
972
1073
  getPath(componentAliases, ["button", "textOnPrimary"])
973
1074
  )
974
1075
  );
975
- addDark(
976
- toVariableName(prefix, "badge", "primary", "bg"),
977
- pickSemantic(
978
- getPath(darkMode, ["component", "badge", "primary", "bg"]),
979
- getPath(defaultMode, ["component", "badge", "primary", "bg"]),
980
- getPath(componentAliases, ["badge", "primary", "bg"])
981
- )
982
- );
983
- addDark(
984
- toVariableName(prefix, "badge", "primary", "text"),
985
- pickSemantic(
986
- getPath(darkMode, ["component", "badge", "primary", "text"]),
987
- getPath(defaultMode, ["component", "badge", "primary", "text"]),
988
- getPath(componentAliases, ["badge", "primary", "text"])
989
- )
990
- );
991
- addDark(
992
- toVariableName(prefix, "badge", "success", "bg"),
993
- pickSemantic(
994
- getPath(darkMode, ["component", "badge", "success", "bg"]),
995
- getPath(defaultMode, ["component", "badge", "success", "bg"]),
996
- getPath(componentAliases, ["badge", "success", "bg"])
997
- )
998
- );
999
- addDark(
1000
- toVariableName(prefix, "badge", "success", "text"),
1001
- pickSemantic(
1002
- getPath(darkMode, ["component", "badge", "success", "text"]),
1003
- getPath(defaultMode, ["component", "badge", "success", "text"]),
1004
- getPath(componentAliases, ["badge", "success", "text"])
1005
- )
1006
- );
1007
- addDark(
1008
- toVariableName(prefix, "badge", "warning", "bg"),
1009
- pickSemantic(
1010
- getPath(darkMode, ["component", "badge", "warning", "bg"]),
1011
- getPath(defaultMode, ["component", "badge", "warning", "bg"]),
1012
- getPath(componentAliases, ["badge", "warning", "bg"])
1013
- )
1014
- );
1015
- addDark(
1016
- toVariableName(prefix, "badge", "warning", "text"),
1017
- pickSemantic(
1018
- getPath(darkMode, ["component", "badge", "warning", "text"]),
1019
- getPath(defaultMode, ["component", "badge", "warning", "text"]),
1020
- getPath(componentAliases, ["badge", "warning", "text"])
1021
- )
1022
- );
1023
- addDark(
1024
- toVariableName(prefix, "badge", "danger", "bg"),
1025
- pickSemantic(
1026
- getPath(darkMode, ["component", "badge", "danger", "bg"]),
1027
- getPath(defaultMode, ["component", "badge", "danger", "bg"]),
1028
- getPath(componentAliases, ["badge", "danger", "bg"])
1029
- )
1030
- );
1031
- addDark(
1032
- toVariableName(prefix, "badge", "danger", "text"),
1033
- pickSemantic(
1034
- getPath(darkMode, ["component", "badge", "danger", "text"]),
1035
- getPath(defaultMode, ["component", "badge", "danger", "text"]),
1036
- getPath(componentAliases, ["badge", "danger", "text"])
1037
- )
1038
- );
1076
+ BADGE_VARIANTS.forEach(({ variant, bgKey, textKey }) => {
1077
+ addDark(
1078
+ toVariableName(prefix, "badge", variant, "bg"),
1079
+ pickSemantic(
1080
+ getPath(darkMode, ["component", "badge", bgKey]),
1081
+ getPath(defaultMode, ["component", "badge", bgKey]),
1082
+ getPath(componentAliases, ["badge", bgKey])
1083
+ )
1084
+ );
1085
+ addDark(
1086
+ toVariableName(prefix, "badge", variant, "text"),
1087
+ pickSemantic(
1088
+ getPath(darkMode, ["component", "badge", textKey]),
1089
+ getPath(defaultMode, ["component", "badge", textKey]),
1090
+ getPath(componentAliases, ["badge", textKey])
1091
+ )
1092
+ );
1093
+ });
1094
+ ICON_BOX_FIELDS.forEach(({ name, tokenKey }) => {
1095
+ addDark(
1096
+ toVariableName(prefix, "icon-box", name),
1097
+ pickSemantic(
1098
+ getPath(darkMode, ["component", "iconBox", tokenKey]),
1099
+ getPath(defaultMode, ["component", "iconBox", tokenKey]),
1100
+ getPath(componentAliases, ["iconBox", tokenKey])
1101
+ )
1102
+ );
1103
+ });
1039
1104
  const rootBlock = `${selector} {
1040
1105
  ${rootLines.join("\n")}
1041
1106
  }`;
@@ -1072,7 +1137,7 @@ var createTailwindTheme = (source = tokens) => {
1072
1137
  }, {});
1073
1138
  return {
1074
1139
  colors,
1075
- spacing: { ...source.spacing },
1140
+ spacing: { ...source.space ?? {} },
1076
1141
  borderRadius: { ...source.radii },
1077
1142
  fontFamily,
1078
1143
  fontSize,