@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.js CHANGED
@@ -113,12 +113,14 @@ var core_default = {
113
113
  onPage: {
114
114
  default: "#0f172a",
115
115
  muted: "#475569",
116
- subtle: "#94a3b8"
116
+ subtle: "#94a3b8",
117
+ meta: "#94a3b8"
117
118
  },
118
119
  onSurface: {
119
120
  default: "#0f172a",
120
121
  muted: "#6b7280",
121
- subtle: "#94a3b8"
122
+ subtle: "#94a3b8",
123
+ meta: "#94a3b8"
122
124
  }
123
125
  },
124
126
  component: {
@@ -133,6 +135,24 @@ var core_default = {
133
135
  button: {
134
136
  textDefault: "#0f172a",
135
137
  textOnPrimary: "#ffffff"
138
+ },
139
+ badge: {
140
+ primary: {
141
+ bg: "#8652ff",
142
+ text: "#0f172a"
143
+ },
144
+ success: {
145
+ bg: "#22c55e",
146
+ text: "#0f172a"
147
+ },
148
+ warning: {
149
+ bg: "#f59e0b",
150
+ text: "#0f172a"
151
+ },
152
+ danger: {
153
+ bg: "#ef4444",
154
+ text: "#0f172a"
155
+ }
136
156
  }
137
157
  },
138
158
  modes: {
@@ -161,6 +181,9 @@ var core_default = {
161
181
  },
162
182
  subtle: {
163
183
  value: "#94a3b8"
184
+ },
185
+ meta: {
186
+ value: "#94a3b8"
164
187
  }
165
188
  },
166
189
  onSurface: {
@@ -172,6 +195,9 @@ var core_default = {
172
195
  },
173
196
  subtle: {
174
197
  value: "#94a3b8"
198
+ },
199
+ meta: {
200
+ value: "#94a3b8"
175
201
  }
176
202
  }
177
203
  },
@@ -199,6 +225,40 @@ var core_default = {
199
225
  textOnPrimary: {
200
226
  value: "#ffffff"
201
227
  }
228
+ },
229
+ badge: {
230
+ primary: {
231
+ bg: {
232
+ value: "#8652ff"
233
+ },
234
+ text: {
235
+ value: "#0f172a"
236
+ }
237
+ },
238
+ success: {
239
+ bg: {
240
+ value: "#22c55e"
241
+ },
242
+ text: {
243
+ value: "#0f172a"
244
+ }
245
+ },
246
+ warning: {
247
+ bg: {
248
+ value: "#f59e0b"
249
+ },
250
+ text: {
251
+ value: "#0f172a"
252
+ }
253
+ },
254
+ danger: {
255
+ bg: {
256
+ value: "#ef4444"
257
+ },
258
+ text: {
259
+ value: "#0f172a"
260
+ }
261
+ }
202
262
  }
203
263
  }
204
264
  },
@@ -227,6 +287,9 @@ var core_default = {
227
287
  },
228
288
  subtle: {
229
289
  value: "#94a3b8"
290
+ },
291
+ meta: {
292
+ value: "#94a3b8"
230
293
  }
231
294
  },
232
295
  onSurface: {
@@ -238,6 +301,9 @@ var core_default = {
238
301
  },
239
302
  subtle: {
240
303
  value: "#94a3b8"
304
+ },
305
+ meta: {
306
+ value: "#94a3b8"
241
307
  }
242
308
  }
243
309
  },
@@ -265,6 +331,40 @@ var core_default = {
265
331
  textOnPrimary: {
266
332
  value: "#ffffff"
267
333
  }
334
+ },
335
+ badge: {
336
+ primary: {
337
+ bg: {
338
+ value: "#8652ff"
339
+ },
340
+ text: {
341
+ value: "#f1f5f9"
342
+ }
343
+ },
344
+ success: {
345
+ bg: {
346
+ value: "#22c55e"
347
+ },
348
+ text: {
349
+ value: "#f1f5f9"
350
+ }
351
+ },
352
+ warning: {
353
+ bg: {
354
+ value: "#f59e0b"
355
+ },
356
+ text: {
357
+ value: "#f1f5f9"
358
+ }
359
+ },
360
+ danger: {
361
+ bg: {
362
+ value: "#ef4444"
363
+ },
364
+ text: {
365
+ value: "#f1f5f9"
366
+ }
367
+ }
268
368
  }
269
369
  }
270
370
  }
@@ -383,6 +483,38 @@ var core_default = {
383
483
  card: "#334155",
384
484
  input: "#cbd5f5"
385
485
  },
486
+ font: {
487
+ xs: {
488
+ size: "0.75rem",
489
+ lineHeight: "1.25rem",
490
+ weight: 400
491
+ },
492
+ sm: {
493
+ size: "0.875rem",
494
+ lineHeight: "1.5rem",
495
+ weight: 400
496
+ },
497
+ md: {
498
+ size: "1rem",
499
+ lineHeight: "1.75rem",
500
+ weight: 500
501
+ },
502
+ lg: {
503
+ size: "1.25rem",
504
+ lineHeight: "2rem",
505
+ weight: 500
506
+ },
507
+ xl: {
508
+ size: "1.5rem",
509
+ lineHeight: "2.125rem",
510
+ weight: 600
511
+ },
512
+ "2xl": {
513
+ size: "1.875rem",
514
+ lineHeight: "2.5rem",
515
+ weight: 600
516
+ }
517
+ },
386
518
  typography: {
387
519
  families: {
388
520
  sans: "'Inter', 'Helvetica Neue', Arial, sans-serif",
@@ -523,64 +655,93 @@ var toVariableName = (prefix, ...parts) => {
523
655
  var createCssVariableMap = (tokens2, options = {}) => {
524
656
  const prefix = options.prefix ?? DEFAULT_PREFIX;
525
657
  const map = {};
658
+ const baseTokens = tokens2;
526
659
  const assign = (name, value) => {
527
660
  if (value === void 0) return;
528
661
  map[name] = String(value);
529
662
  };
530
- Object.entries(tokens2.colors).forEach(([group, scale]) => {
663
+ Object.entries(baseTokens.colors).forEach(([group, scale]) => {
531
664
  Object.entries(scale).forEach(([step, value]) => {
532
665
  assign(toVariableName(prefix, "color", group, step), value);
533
666
  });
534
667
  });
535
- Object.entries(tokens2.spacing).forEach(([key, value]) => {
668
+ Object.entries(baseTokens.spacing).forEach(([key, value]) => {
536
669
  assign(toVariableName(prefix, "space", key), value);
537
670
  });
538
- Object.entries(tokens2.radii).forEach(([key, value]) => {
671
+ Object.entries(baseTokens.radii).forEach(([key, value]) => {
539
672
  assign(toVariableName(prefix, "radius", key), value);
540
673
  });
541
- Object.entries(tokens2.typography.families).forEach(([key, value]) => {
674
+ Object.entries(baseTokens.typography.families).forEach(([key, value]) => {
542
675
  assign(toVariableName(prefix, "font-family", key), value);
543
676
  });
544
- Object.entries(tokens2.typography.scale).forEach(([key, entry]) => {
545
- assign(toVariableName(prefix, "font", key, "size"), entry.fontSize);
546
- assign(toVariableName(prefix, "font", key, "line-height"), entry.lineHeight);
547
- assign(toVariableName(prefix, "font", key, "weight"), entry.fontWeight);
677
+ const typographyScale = baseTokens.typography?.scale ?? {};
678
+ const fontScale = baseTokens.font;
679
+ if (fontScale && Object.keys(fontScale).length > 0) {
680
+ Object.entries(fontScale).forEach(([key, entry]) => {
681
+ assign(toVariableName(prefix, "font", key, "size"), entry.size);
682
+ assign(toVariableName(prefix, "font", key, "line-height"), entry.lineHeight);
683
+ assign(toVariableName(prefix, "font", key, "weight"), entry.weight);
684
+ });
685
+ } else {
686
+ Object.entries(typographyScale).forEach(([key, entry]) => {
687
+ assign(toVariableName(prefix, "font", key, "size"), entry.fontSize);
688
+ assign(toVariableName(prefix, "font", key, "line-height"), entry.lineHeight);
689
+ assign(toVariableName(prefix, "font", key, "weight"), entry.fontWeight);
690
+ });
691
+ }
692
+ Object.entries(typographyScale).forEach(([key, entry]) => {
548
693
  assign(toVariableName(prefix, "font", key, "letter-spacing"), entry.letterSpacing);
549
694
  });
550
- Object.entries(tokens2.shadows).forEach(([key, value]) => {
695
+ assign(toVariableName(prefix, "text", "on", "page", "default"), tokens2.text.onPage.default);
696
+ assign(toVariableName(prefix, "text", "on", "page", "muted"), tokens2.text.onPage.muted);
697
+ assign(toVariableName(prefix, "text", "on", "surface", "default"), tokens2.text.onSurface.default);
698
+ assign(toVariableName(prefix, "text", "on", "surface", "muted"), tokens2.text.onSurface.muted);
699
+ assign(toVariableName(prefix, "text", "on", "surface", "meta"), tokens2.text.onSurface.meta);
700
+ const badge = tokens2.component?.badge;
701
+ if (badge) {
702
+ assign(toVariableName(prefix, "badge", "primary", "bg"), badge.primary.bg);
703
+ assign(toVariableName(prefix, "badge", "primary", "text"), badge.primary.text);
704
+ assign(toVariableName(prefix, "badge", "success", "bg"), badge.success.bg);
705
+ assign(toVariableName(prefix, "badge", "success", "text"), badge.success.text);
706
+ assign(toVariableName(prefix, "badge", "warning", "bg"), badge.warning.bg);
707
+ assign(toVariableName(prefix, "badge", "warning", "text"), badge.warning.text);
708
+ assign(toVariableName(prefix, "badge", "danger", "bg"), badge.danger.bg);
709
+ assign(toVariableName(prefix, "badge", "danger", "text"), badge.danger.text);
710
+ }
711
+ Object.entries(baseTokens.shadows).forEach(([key, value]) => {
551
712
  assign(toVariableName(prefix, "shadow", key), value);
552
713
  });
553
- Object.entries(tokens2.breakpoints).forEach(([key, value]) => {
714
+ Object.entries(baseTokens.breakpoints).forEach(([key, value]) => {
554
715
  assign(toVariableName(prefix, "breakpoint", key), value);
555
716
  });
556
- Object.entries(tokens2.zIndex).forEach(([key, value]) => {
717
+ Object.entries(baseTokens.zIndex).forEach(([key, value]) => {
557
718
  assign(toVariableName(prefix, "z-index", key), value);
558
719
  });
559
- Object.entries(tokens2.transitions.duration).forEach(([key, value]) => {
720
+ Object.entries(baseTokens.transitions.duration).forEach(([key, value]) => {
560
721
  assign(toVariableName(prefix, "duration", key), value);
561
722
  });
562
- Object.entries(tokens2.transitions.easing).forEach(([key, value]) => {
723
+ Object.entries(baseTokens.transitions.easing).forEach(([key, value]) => {
563
724
  assign(toVariableName(prefix, "easing", key), value);
564
725
  });
565
- Object.entries(tokens2.opacity).forEach(([key, value]) => {
726
+ Object.entries(baseTokens.opacity).forEach(([key, value]) => {
566
727
  assign(toVariableName(prefix, "opacity", key), value);
567
728
  });
568
- assign(toVariableName(prefix, "focus-ring-width"), tokens2.accessibility.focusRing.width);
569
- assign(toVariableName(prefix, "focus-ring-offset"), tokens2.accessibility.focusRing.offset);
570
- assign(toVariableName(prefix, "focus-ring-style"), tokens2.accessibility.focusRing.style);
571
- assign(toVariableName(prefix, "min-touch-target"), tokens2.accessibility.minTouchTarget);
572
- assign(toVariableName(prefix, "min-text-size"), tokens2.accessibility.minTextSize);
573
- Object.entries(tokens2.buttons).forEach(([variant, states]) => {
729
+ assign(toVariableName(prefix, "focus-ring-width"), baseTokens.accessibility.focusRing.width);
730
+ assign(toVariableName(prefix, "focus-ring-offset"), baseTokens.accessibility.focusRing.offset);
731
+ assign(toVariableName(prefix, "focus-ring-style"), baseTokens.accessibility.focusRing.style);
732
+ assign(toVariableName(prefix, "min-touch-target"), baseTokens.accessibility.minTouchTarget);
733
+ assign(toVariableName(prefix, "min-text-size"), baseTokens.accessibility.minTextSize);
734
+ Object.entries(baseTokens.buttons).forEach(([variant, states]) => {
574
735
  Object.entries(states).forEach(([state, value]) => {
575
736
  assign(toVariableName(prefix, "button", variant, state), value);
576
737
  });
577
738
  });
578
- Object.entries(tokens2.forms).forEach(([state, properties]) => {
739
+ Object.entries(baseTokens.forms).forEach(([state, properties]) => {
579
740
  Object.entries(properties).forEach(([prop, value]) => {
580
741
  if (value) assign(toVariableName(prefix, "form", state, prop), value);
581
742
  });
582
743
  });
583
- Object.entries(tokens2.animations).forEach(([name, animation]) => {
744
+ Object.entries(baseTokens.animations).forEach(([name, animation]) => {
584
745
  assign(toVariableName(prefix, "animation", name, "duration"), animation.duration);
585
746
  assign(toVariableName(prefix, "animation", name, "easing"), animation.easing);
586
747
  assign(toVariableName(prefix, "animation", name, "keyframes"), animation.keyframes);
@@ -622,14 +783,48 @@ var generateCssVariables = (tokens2, options = {}) => {
622
783
  addBase(toVariableName(prefix, "surface", "overlay"), pickSemantic(getPath(defaultMode, ["surface", "overlay"]), getPath(surfaceAliases, ["overlay"])));
623
784
  addBase(toVariableName(prefix, "text", "on", "page", "default"), pickSemantic(getPath(defaultMode, ["text", "onPage", "default"]), getPath(textAliases, ["onPage", "default"])));
624
785
  addBase(toVariableName(prefix, "text", "on", "page", "muted"), pickSemantic(getPath(defaultMode, ["text", "onPage", "muted"]), getPath(textAliases, ["onPage", "muted"])));
786
+ addBase(toVariableName(prefix, "text", "on", "page", "meta"), pickSemantic(getPath(defaultMode, ["text", "onPage", "meta"]), getPath(textAliases, ["onPage", "meta"])));
625
787
  addBase(toVariableName(prefix, "text", "on", "surface", "default"), pickSemantic(getPath(defaultMode, ["text", "onSurface", "default"]), getPath(textAliases, ["onSurface", "default"])));
626
788
  addBase(toVariableName(prefix, "text", "on", "surface", "muted"), pickSemantic(getPath(defaultMode, ["text", "onSurface", "muted"]), getPath(textAliases, ["onSurface", "muted"])));
789
+ addBase(toVariableName(prefix, "text", "on", "surface", "meta"), pickSemantic(getPath(defaultMode, ["text", "onSurface", "meta"]), getPath(textAliases, ["onSurface", "meta"])));
627
790
  addBase(toVariableName(prefix, "component", "card", "text"), pickSemantic(getPath(defaultMode, ["component", "card", "text"]), getPath(componentAliases, ["card", "text"])));
628
791
  addBase(toVariableName(prefix, "component", "card", "text-muted"), pickSemantic(getPath(defaultMode, ["component", "card", "textMuted"]), getPath(componentAliases, ["card", "textMuted"])));
629
792
  addBase(toVariableName(prefix, "component", "input", "text"), pickSemantic(getPath(defaultMode, ["component", "input", "text"]), getPath(componentAliases, ["input", "text"])));
630
793
  addBase(toVariableName(prefix, "component", "input", "placeholder"), pickSemantic(getPath(defaultMode, ["component", "input", "placeholder"]), getPath(componentAliases, ["input", "placeholder"])));
631
794
  addBase(toVariableName(prefix, "button", "text", "default"), pickSemantic(getPath(defaultMode, ["component", "button", "textDefault"]), getPath(componentAliases, ["button", "textDefault"])));
632
795
  addBase(toVariableName(prefix, "button", "text", "on", "primary"), pickSemantic(getPath(defaultMode, ["component", "button", "textOnPrimary"]), getPath(componentAliases, ["button", "textOnPrimary"])));
796
+ addBase(
797
+ toVariableName(prefix, "badge", "primary", "bg"),
798
+ pickSemantic(getPath(defaultMode, ["component", "badge", "primary", "bg"]), getPath(componentAliases, ["badge", "primary", "bg"]))
799
+ );
800
+ addBase(
801
+ toVariableName(prefix, "badge", "primary", "text"),
802
+ pickSemantic(getPath(defaultMode, ["component", "badge", "primary", "text"]), getPath(componentAliases, ["badge", "primary", "text"]))
803
+ );
804
+ addBase(
805
+ toVariableName(prefix, "badge", "success", "bg"),
806
+ pickSemantic(getPath(defaultMode, ["component", "badge", "success", "bg"]), getPath(componentAliases, ["badge", "success", "bg"]))
807
+ );
808
+ addBase(
809
+ toVariableName(prefix, "badge", "success", "text"),
810
+ pickSemantic(getPath(defaultMode, ["component", "badge", "success", "text"]), getPath(componentAliases, ["badge", "success", "text"]))
811
+ );
812
+ addBase(
813
+ toVariableName(prefix, "badge", "warning", "bg"),
814
+ pickSemantic(getPath(defaultMode, ["component", "badge", "warning", "bg"]), getPath(componentAliases, ["badge", "warning", "bg"]))
815
+ );
816
+ addBase(
817
+ toVariableName(prefix, "badge", "warning", "text"),
818
+ pickSemantic(getPath(defaultMode, ["component", "badge", "warning", "text"]), getPath(componentAliases, ["badge", "warning", "text"]))
819
+ );
820
+ addBase(
821
+ toVariableName(prefix, "badge", "danger", "bg"),
822
+ pickSemantic(getPath(defaultMode, ["component", "badge", "danger", "bg"]), getPath(componentAliases, ["badge", "danger", "bg"]))
823
+ );
824
+ addBase(
825
+ toVariableName(prefix, "badge", "danger", "text"),
826
+ pickSemantic(getPath(defaultMode, ["component", "badge", "danger", "text"]), getPath(componentAliases, ["badge", "danger", "text"]))
827
+ );
633
828
  const rootLines = [...baseLines, ...mapLines];
634
829
  const darkLines = [];
635
830
  const addDark = (name, value) => {
@@ -667,6 +862,14 @@ var generateCssVariables = (tokens2, options = {}) => {
667
862
  getPath(textAliases, ["onPage", "muted"])
668
863
  )
669
864
  );
865
+ addDark(
866
+ toVariableName(prefix, "text", "on", "page", "meta"),
867
+ pickSemantic(
868
+ getPath(darkMode, ["text", "onPage", "meta"]),
869
+ getPath(defaultMode, ["text", "onPage", "meta"]),
870
+ getPath(textAliases, ["onPage", "meta"])
871
+ )
872
+ );
670
873
  addDark(
671
874
  toVariableName(prefix, "text", "on", "surface", "default"),
672
875
  pickSemantic(
@@ -683,6 +886,14 @@ var generateCssVariables = (tokens2, options = {}) => {
683
886
  getPath(textAliases, ["onSurface", "muted"])
684
887
  )
685
888
  );
889
+ addDark(
890
+ toVariableName(prefix, "text", "on", "surface", "meta"),
891
+ pickSemantic(
892
+ getPath(darkMode, ["text", "onSurface", "meta"]),
893
+ getPath(defaultMode, ["text", "onSurface", "meta"]),
894
+ getPath(textAliases, ["onSurface", "meta"])
895
+ )
896
+ );
686
897
  addDark(
687
898
  toVariableName(prefix, "component", "card", "text"),
688
899
  pickSemantic(
@@ -731,6 +942,70 @@ var generateCssVariables = (tokens2, options = {}) => {
731
942
  getPath(componentAliases, ["button", "textOnPrimary"])
732
943
  )
733
944
  );
945
+ addDark(
946
+ toVariableName(prefix, "badge", "primary", "bg"),
947
+ pickSemantic(
948
+ getPath(darkMode, ["component", "badge", "primary", "bg"]),
949
+ getPath(defaultMode, ["component", "badge", "primary", "bg"]),
950
+ getPath(componentAliases, ["badge", "primary", "bg"])
951
+ )
952
+ );
953
+ addDark(
954
+ toVariableName(prefix, "badge", "primary", "text"),
955
+ pickSemantic(
956
+ getPath(darkMode, ["component", "badge", "primary", "text"]),
957
+ getPath(defaultMode, ["component", "badge", "primary", "text"]),
958
+ getPath(componentAliases, ["badge", "primary", "text"])
959
+ )
960
+ );
961
+ addDark(
962
+ toVariableName(prefix, "badge", "success", "bg"),
963
+ pickSemantic(
964
+ getPath(darkMode, ["component", "badge", "success", "bg"]),
965
+ getPath(defaultMode, ["component", "badge", "success", "bg"]),
966
+ getPath(componentAliases, ["badge", "success", "bg"])
967
+ )
968
+ );
969
+ addDark(
970
+ toVariableName(prefix, "badge", "success", "text"),
971
+ pickSemantic(
972
+ getPath(darkMode, ["component", "badge", "success", "text"]),
973
+ getPath(defaultMode, ["component", "badge", "success", "text"]),
974
+ getPath(componentAliases, ["badge", "success", "text"])
975
+ )
976
+ );
977
+ addDark(
978
+ toVariableName(prefix, "badge", "warning", "bg"),
979
+ pickSemantic(
980
+ getPath(darkMode, ["component", "badge", "warning", "bg"]),
981
+ getPath(defaultMode, ["component", "badge", "warning", "bg"]),
982
+ getPath(componentAliases, ["badge", "warning", "bg"])
983
+ )
984
+ );
985
+ addDark(
986
+ toVariableName(prefix, "badge", "warning", "text"),
987
+ pickSemantic(
988
+ getPath(darkMode, ["component", "badge", "warning", "text"]),
989
+ getPath(defaultMode, ["component", "badge", "warning", "text"]),
990
+ getPath(componentAliases, ["badge", "warning", "text"])
991
+ )
992
+ );
993
+ addDark(
994
+ toVariableName(prefix, "badge", "danger", "bg"),
995
+ pickSemantic(
996
+ getPath(darkMode, ["component", "badge", "danger", "bg"]),
997
+ getPath(defaultMode, ["component", "badge", "danger", "bg"]),
998
+ getPath(componentAliases, ["badge", "danger", "bg"])
999
+ )
1000
+ );
1001
+ addDark(
1002
+ toVariableName(prefix, "badge", "danger", "text"),
1003
+ pickSemantic(
1004
+ getPath(darkMode, ["component", "badge", "danger", "text"]),
1005
+ getPath(defaultMode, ["component", "badge", "danger", "text"]),
1006
+ getPath(componentAliases, ["badge", "danger", "text"])
1007
+ )
1008
+ );
734
1009
  const rootBlock = `${selector} {
735
1010
  ${rootLines.join("\n")}
736
1011
  }`;