@phcdevworks/spectre-tokens 0.0.4 → 0.1.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/dist/index.cjs CHANGED
@@ -143,12 +143,14 @@ var core_default = {
143
143
  onPage: {
144
144
  default: "#0f172a",
145
145
  muted: "#475569",
146
- subtle: "#94a3b8"
146
+ subtle: "#94a3b8",
147
+ meta: "#94a3b8"
147
148
  },
148
149
  onSurface: {
149
150
  default: "#0f172a",
150
151
  muted: "#6b7280",
151
- subtle: "#94a3b8"
152
+ subtle: "#94a3b8",
153
+ meta: "#94a3b8"
152
154
  }
153
155
  },
154
156
  component: {
@@ -163,6 +165,24 @@ var core_default = {
163
165
  button: {
164
166
  textDefault: "#0f172a",
165
167
  textOnPrimary: "#ffffff"
168
+ },
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
+ }
166
186
  }
167
187
  },
168
188
  modes: {
@@ -191,6 +211,9 @@ var core_default = {
191
211
  },
192
212
  subtle: {
193
213
  value: "#94a3b8"
214
+ },
215
+ meta: {
216
+ value: "#94a3b8"
194
217
  }
195
218
  },
196
219
  onSurface: {
@@ -202,6 +225,9 @@ var core_default = {
202
225
  },
203
226
  subtle: {
204
227
  value: "#94a3b8"
228
+ },
229
+ meta: {
230
+ value: "#94a3b8"
205
231
  }
206
232
  }
207
233
  },
@@ -229,6 +255,40 @@ var core_default = {
229
255
  textOnPrimary: {
230
256
  value: "#ffffff"
231
257
  }
258
+ },
259
+ badge: {
260
+ primary: {
261
+ bg: {
262
+ value: "#8652ff"
263
+ },
264
+ text: {
265
+ value: "#0f172a"
266
+ }
267
+ },
268
+ success: {
269
+ bg: {
270
+ value: "#22c55e"
271
+ },
272
+ text: {
273
+ value: "#0f172a"
274
+ }
275
+ },
276
+ warning: {
277
+ bg: {
278
+ value: "#f59e0b"
279
+ },
280
+ text: {
281
+ value: "#0f172a"
282
+ }
283
+ },
284
+ danger: {
285
+ bg: {
286
+ value: "#ef4444"
287
+ },
288
+ text: {
289
+ value: "#0f172a"
290
+ }
291
+ }
232
292
  }
233
293
  }
234
294
  },
@@ -257,6 +317,9 @@ var core_default = {
257
317
  },
258
318
  subtle: {
259
319
  value: "#94a3b8"
320
+ },
321
+ meta: {
322
+ value: "#94a3b8"
260
323
  }
261
324
  },
262
325
  onSurface: {
@@ -268,6 +331,9 @@ var core_default = {
268
331
  },
269
332
  subtle: {
270
333
  value: "#94a3b8"
334
+ },
335
+ meta: {
336
+ value: "#94a3b8"
271
337
  }
272
338
  }
273
339
  },
@@ -295,6 +361,40 @@ var core_default = {
295
361
  textOnPrimary: {
296
362
  value: "#ffffff"
297
363
  }
364
+ },
365
+ badge: {
366
+ primary: {
367
+ bg: {
368
+ value: "#8652ff"
369
+ },
370
+ text: {
371
+ value: "#f1f5f9"
372
+ }
373
+ },
374
+ success: {
375
+ bg: {
376
+ value: "#22c55e"
377
+ },
378
+ text: {
379
+ value: "#f1f5f9"
380
+ }
381
+ },
382
+ warning: {
383
+ bg: {
384
+ value: "#f59e0b"
385
+ },
386
+ text: {
387
+ value: "#f1f5f9"
388
+ }
389
+ },
390
+ danger: {
391
+ bg: {
392
+ value: "#ef4444"
393
+ },
394
+ text: {
395
+ value: "#f1f5f9"
396
+ }
397
+ }
298
398
  }
299
399
  }
300
400
  }
@@ -413,6 +513,38 @@ var core_default = {
413
513
  card: "#334155",
414
514
  input: "#cbd5f5"
415
515
  },
516
+ font: {
517
+ xs: {
518
+ size: "0.75rem",
519
+ lineHeight: "1.25rem",
520
+ weight: 400
521
+ },
522
+ sm: {
523
+ size: "0.875rem",
524
+ lineHeight: "1.5rem",
525
+ weight: 400
526
+ },
527
+ md: {
528
+ size: "1rem",
529
+ lineHeight: "1.75rem",
530
+ weight: 500
531
+ },
532
+ lg: {
533
+ size: "1.25rem",
534
+ lineHeight: "2rem",
535
+ weight: 500
536
+ },
537
+ xl: {
538
+ size: "1.5rem",
539
+ lineHeight: "2.125rem",
540
+ weight: 600
541
+ },
542
+ "2xl": {
543
+ size: "1.875rem",
544
+ lineHeight: "2.5rem",
545
+ weight: 600
546
+ }
547
+ },
416
548
  typography: {
417
549
  families: {
418
550
  sans: "'Inter', 'Helvetica Neue', Arial, sans-serif",
@@ -553,64 +685,93 @@ var toVariableName = (prefix, ...parts) => {
553
685
  var createCssVariableMap = (tokens2, options = {}) => {
554
686
  const prefix = options.prefix ?? DEFAULT_PREFIX;
555
687
  const map = {};
688
+ const baseTokens = tokens2;
556
689
  const assign = (name, value) => {
557
690
  if (value === void 0) return;
558
691
  map[name] = String(value);
559
692
  };
560
- Object.entries(tokens2.colors).forEach(([group, scale]) => {
693
+ Object.entries(baseTokens.colors).forEach(([group, scale]) => {
561
694
  Object.entries(scale).forEach(([step, value]) => {
562
695
  assign(toVariableName(prefix, "color", group, step), value);
563
696
  });
564
697
  });
565
- Object.entries(tokens2.spacing).forEach(([key, value]) => {
698
+ Object.entries(baseTokens.spacing).forEach(([key, value]) => {
566
699
  assign(toVariableName(prefix, "space", key), value);
567
700
  });
568
- Object.entries(tokens2.radii).forEach(([key, value]) => {
701
+ Object.entries(baseTokens.radii).forEach(([key, value]) => {
569
702
  assign(toVariableName(prefix, "radius", key), value);
570
703
  });
571
- Object.entries(tokens2.typography.families).forEach(([key, value]) => {
704
+ Object.entries(baseTokens.typography.families).forEach(([key, value]) => {
572
705
  assign(toVariableName(prefix, "font-family", key), value);
573
706
  });
574
- Object.entries(tokens2.typography.scale).forEach(([key, entry]) => {
575
- assign(toVariableName(prefix, "font", key, "size"), entry.fontSize);
576
- assign(toVariableName(prefix, "font", key, "line-height"), entry.lineHeight);
577
- assign(toVariableName(prefix, "font", key, "weight"), entry.fontWeight);
707
+ const typographyScale = baseTokens.typography?.scale ?? {};
708
+ const fontScale = baseTokens.font;
709
+ if (fontScale && Object.keys(fontScale).length > 0) {
710
+ Object.entries(fontScale).forEach(([key, entry]) => {
711
+ assign(toVariableName(prefix, "font", key, "size"), entry.size);
712
+ assign(toVariableName(prefix, "font", key, "line-height"), entry.lineHeight);
713
+ assign(toVariableName(prefix, "font", key, "weight"), entry.weight);
714
+ });
715
+ } else {
716
+ Object.entries(typographyScale).forEach(([key, entry]) => {
717
+ assign(toVariableName(prefix, "font", key, "size"), entry.fontSize);
718
+ assign(toVariableName(prefix, "font", key, "line-height"), entry.lineHeight);
719
+ assign(toVariableName(prefix, "font", key, "weight"), entry.fontWeight);
720
+ });
721
+ }
722
+ Object.entries(typographyScale).forEach(([key, entry]) => {
578
723
  assign(toVariableName(prefix, "font", key, "letter-spacing"), entry.letterSpacing);
579
724
  });
580
- Object.entries(tokens2.shadows).forEach(([key, value]) => {
725
+ assign(toVariableName(prefix, "text", "on", "page", "default"), tokens2.text.onPage.default);
726
+ assign(toVariableName(prefix, "text", "on", "page", "muted"), tokens2.text.onPage.muted);
727
+ assign(toVariableName(prefix, "text", "on", "surface", "default"), tokens2.text.onSurface.default);
728
+ assign(toVariableName(prefix, "text", "on", "surface", "muted"), tokens2.text.onSurface.muted);
729
+ assign(toVariableName(prefix, "text", "on", "surface", "meta"), tokens2.text.onSurface.meta);
730
+ const badge = tokens2.component?.badge;
731
+ 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);
740
+ }
741
+ Object.entries(baseTokens.shadows).forEach(([key, value]) => {
581
742
  assign(toVariableName(prefix, "shadow", key), value);
582
743
  });
583
- Object.entries(tokens2.breakpoints).forEach(([key, value]) => {
744
+ Object.entries(baseTokens.breakpoints).forEach(([key, value]) => {
584
745
  assign(toVariableName(prefix, "breakpoint", key), value);
585
746
  });
586
- Object.entries(tokens2.zIndex).forEach(([key, value]) => {
747
+ Object.entries(baseTokens.zIndex).forEach(([key, value]) => {
587
748
  assign(toVariableName(prefix, "z-index", key), value);
588
749
  });
589
- Object.entries(tokens2.transitions.duration).forEach(([key, value]) => {
750
+ Object.entries(baseTokens.transitions.duration).forEach(([key, value]) => {
590
751
  assign(toVariableName(prefix, "duration", key), value);
591
752
  });
592
- Object.entries(tokens2.transitions.easing).forEach(([key, value]) => {
753
+ Object.entries(baseTokens.transitions.easing).forEach(([key, value]) => {
593
754
  assign(toVariableName(prefix, "easing", key), value);
594
755
  });
595
- Object.entries(tokens2.opacity).forEach(([key, value]) => {
756
+ Object.entries(baseTokens.opacity).forEach(([key, value]) => {
596
757
  assign(toVariableName(prefix, "opacity", key), value);
597
758
  });
598
- assign(toVariableName(prefix, "focus-ring-width"), tokens2.accessibility.focusRing.width);
599
- assign(toVariableName(prefix, "focus-ring-offset"), tokens2.accessibility.focusRing.offset);
600
- assign(toVariableName(prefix, "focus-ring-style"), tokens2.accessibility.focusRing.style);
601
- assign(toVariableName(prefix, "min-touch-target"), tokens2.accessibility.minTouchTarget);
602
- assign(toVariableName(prefix, "min-text-size"), tokens2.accessibility.minTextSize);
603
- Object.entries(tokens2.buttons).forEach(([variant, states]) => {
759
+ assign(toVariableName(prefix, "focus-ring-width"), baseTokens.accessibility.focusRing.width);
760
+ assign(toVariableName(prefix, "focus-ring-offset"), baseTokens.accessibility.focusRing.offset);
761
+ assign(toVariableName(prefix, "focus-ring-style"), baseTokens.accessibility.focusRing.style);
762
+ assign(toVariableName(prefix, "min-touch-target"), baseTokens.accessibility.minTouchTarget);
763
+ assign(toVariableName(prefix, "min-text-size"), baseTokens.accessibility.minTextSize);
764
+ Object.entries(baseTokens.buttons).forEach(([variant, states]) => {
604
765
  Object.entries(states).forEach(([state, value]) => {
605
766
  assign(toVariableName(prefix, "button", variant, state), value);
606
767
  });
607
768
  });
608
- Object.entries(tokens2.forms).forEach(([state, properties]) => {
769
+ Object.entries(baseTokens.forms).forEach(([state, properties]) => {
609
770
  Object.entries(properties).forEach(([prop, value]) => {
610
771
  if (value) assign(toVariableName(prefix, "form", state, prop), value);
611
772
  });
612
773
  });
613
- Object.entries(tokens2.animations).forEach(([name, animation]) => {
774
+ Object.entries(baseTokens.animations).forEach(([name, animation]) => {
614
775
  assign(toVariableName(prefix, "animation", name, "duration"), animation.duration);
615
776
  assign(toVariableName(prefix, "animation", name, "easing"), animation.easing);
616
777
  assign(toVariableName(prefix, "animation", name, "keyframes"), animation.keyframes);
@@ -652,14 +813,48 @@ var generateCssVariables = (tokens2, options = {}) => {
652
813
  addBase(toVariableName(prefix, "surface", "overlay"), pickSemantic(getPath(defaultMode, ["surface", "overlay"]), getPath(surfaceAliases, ["overlay"])));
653
814
  addBase(toVariableName(prefix, "text", "on", "page", "default"), pickSemantic(getPath(defaultMode, ["text", "onPage", "default"]), getPath(textAliases, ["onPage", "default"])));
654
815
  addBase(toVariableName(prefix, "text", "on", "page", "muted"), pickSemantic(getPath(defaultMode, ["text", "onPage", "muted"]), getPath(textAliases, ["onPage", "muted"])));
816
+ addBase(toVariableName(prefix, "text", "on", "page", "meta"), pickSemantic(getPath(defaultMode, ["text", "onPage", "meta"]), getPath(textAliases, ["onPage", "meta"])));
655
817
  addBase(toVariableName(prefix, "text", "on", "surface", "default"), pickSemantic(getPath(defaultMode, ["text", "onSurface", "default"]), getPath(textAliases, ["onSurface", "default"])));
656
818
  addBase(toVariableName(prefix, "text", "on", "surface", "muted"), pickSemantic(getPath(defaultMode, ["text", "onSurface", "muted"]), getPath(textAliases, ["onSurface", "muted"])));
819
+ addBase(toVariableName(prefix, "text", "on", "surface", "meta"), pickSemantic(getPath(defaultMode, ["text", "onSurface", "meta"]), getPath(textAliases, ["onSurface", "meta"])));
657
820
  addBase(toVariableName(prefix, "component", "card", "text"), pickSemantic(getPath(defaultMode, ["component", "card", "text"]), getPath(componentAliases, ["card", "text"])));
658
821
  addBase(toVariableName(prefix, "component", "card", "text-muted"), pickSemantic(getPath(defaultMode, ["component", "card", "textMuted"]), getPath(componentAliases, ["card", "textMuted"])));
659
822
  addBase(toVariableName(prefix, "component", "input", "text"), pickSemantic(getPath(defaultMode, ["component", "input", "text"]), getPath(componentAliases, ["input", "text"])));
660
823
  addBase(toVariableName(prefix, "component", "input", "placeholder"), pickSemantic(getPath(defaultMode, ["component", "input", "placeholder"]), getPath(componentAliases, ["input", "placeholder"])));
661
824
  addBase(toVariableName(prefix, "button", "text", "default"), pickSemantic(getPath(defaultMode, ["component", "button", "textDefault"]), getPath(componentAliases, ["button", "textDefault"])));
662
825
  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
+ );
663
858
  const rootLines = [...baseLines, ...mapLines];
664
859
  const darkLines = [];
665
860
  const addDark = (name, value) => {
@@ -697,6 +892,14 @@ var generateCssVariables = (tokens2, options = {}) => {
697
892
  getPath(textAliases, ["onPage", "muted"])
698
893
  )
699
894
  );
895
+ addDark(
896
+ toVariableName(prefix, "text", "on", "page", "meta"),
897
+ pickSemantic(
898
+ getPath(darkMode, ["text", "onPage", "meta"]),
899
+ getPath(defaultMode, ["text", "onPage", "meta"]),
900
+ getPath(textAliases, ["onPage", "meta"])
901
+ )
902
+ );
700
903
  addDark(
701
904
  toVariableName(prefix, "text", "on", "surface", "default"),
702
905
  pickSemantic(
@@ -713,6 +916,14 @@ var generateCssVariables = (tokens2, options = {}) => {
713
916
  getPath(textAliases, ["onSurface", "muted"])
714
917
  )
715
918
  );
919
+ addDark(
920
+ toVariableName(prefix, "text", "on", "surface", "meta"),
921
+ pickSemantic(
922
+ getPath(darkMode, ["text", "onSurface", "meta"]),
923
+ getPath(defaultMode, ["text", "onSurface", "meta"]),
924
+ getPath(textAliases, ["onSurface", "meta"])
925
+ )
926
+ );
716
927
  addDark(
717
928
  toVariableName(prefix, "component", "card", "text"),
718
929
  pickSemantic(
@@ -761,6 +972,70 @@ var generateCssVariables = (tokens2, options = {}) => {
761
972
  getPath(componentAliases, ["button", "textOnPrimary"])
762
973
  )
763
974
  );
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
+ );
764
1039
  const rootBlock = `${selector} {
765
1040
  ${rootLines.join("\n")}
766
1041
  }`;