@phcdevworks/spectre-tokens 3.4.0 → 4.0.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
@@ -22,8 +22,6 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  default: () => index_default,
24
24
  generateCssVariables: () => generateCssVariables,
25
- tailwindPreset: () => tailwindPreset,
26
- tailwindTheme: () => tailwindTheme,
27
25
  tokens: () => tokens
28
26
  });
29
27
  module.exports = __toCommonJS(index_exports);
@@ -795,7 +793,347 @@ var coreTokens = {
795
793
  "info": "{colors.info.600}"
796
794
  },
797
795
  "white": "#ffffff",
798
- "black": "#000000"
796
+ "black": "#000000",
797
+ "palette": {
798
+ "red": {
799
+ "50": "#fef2f2",
800
+ "100": "#ffe2e2",
801
+ "200": "#ffc9c9",
802
+ "300": "#ffa2a2",
803
+ "400": "#ff6467",
804
+ "500": "#fb2c36",
805
+ "600": "#e7000b",
806
+ "700": "#c10007",
807
+ "800": "#9f0712",
808
+ "900": "#82181a",
809
+ "950": "#460809"
810
+ },
811
+ "orange": {
812
+ "50": "#fff7ed",
813
+ "100": "#ffedd4",
814
+ "200": "#ffd6a7",
815
+ "300": "#ffb86a",
816
+ "400": "#ff8904",
817
+ "500": "#ff6900",
818
+ "600": "#f54900",
819
+ "700": "#ca3500",
820
+ "800": "#9f2d00",
821
+ "900": "#7e2a0c",
822
+ "950": "#441306"
823
+ },
824
+ "amber": {
825
+ "50": "#fffbeb",
826
+ "100": "#fef3c6",
827
+ "200": "#fee685",
828
+ "300": "#ffd230",
829
+ "400": "#ffb900",
830
+ "500": "#fe9a00",
831
+ "600": "#e17100",
832
+ "700": "#bb4d00",
833
+ "800": "#973c00",
834
+ "900": "#7b3306",
835
+ "950": "#461901"
836
+ },
837
+ "yellow": {
838
+ "50": "#fefce8",
839
+ "100": "#fef9c2",
840
+ "200": "#fff085",
841
+ "300": "#ffdf20",
842
+ "400": "#fdc700",
843
+ "500": "#f0b100",
844
+ "600": "#d08700",
845
+ "700": "#a65f00",
846
+ "800": "#894b00",
847
+ "900": "#733e0a",
848
+ "950": "#432004"
849
+ },
850
+ "lime": {
851
+ "50": "#f7fee7",
852
+ "100": "#ecfcca",
853
+ "200": "#d8f999",
854
+ "300": "#bbf451",
855
+ "400": "#9ae600",
856
+ "500": "#7ccf00",
857
+ "600": "#5ea500",
858
+ "700": "#497d00",
859
+ "800": "#3c6300",
860
+ "900": "#35530e",
861
+ "950": "#192e03"
862
+ },
863
+ "green": {
864
+ "50": "#f0fdf4",
865
+ "100": "#dcfce7",
866
+ "200": "#b9f8cf",
867
+ "300": "#7bf1a8",
868
+ "400": "#05df72",
869
+ "500": "#00c950",
870
+ "600": "#00a63e",
871
+ "700": "#008236",
872
+ "800": "#016630",
873
+ "900": "#0d542b",
874
+ "950": "#032e15"
875
+ },
876
+ "emerald": {
877
+ "50": "#ecfdf5",
878
+ "100": "#d0fae5",
879
+ "200": "#a4f4cf",
880
+ "300": "#5ee9b5",
881
+ "400": "#00d492",
882
+ "500": "#00bc7d",
883
+ "600": "#009966",
884
+ "700": "#007a55",
885
+ "800": "#006045",
886
+ "900": "#004f3b",
887
+ "950": "#002c22"
888
+ },
889
+ "teal": {
890
+ "50": "#f0fdfa",
891
+ "100": "#cbfbf1",
892
+ "200": "#96f7e4",
893
+ "300": "#46ecd5",
894
+ "400": "#00d5be",
895
+ "500": "#00bba7",
896
+ "600": "#009689",
897
+ "700": "#00786f",
898
+ "800": "#005f5a",
899
+ "900": "#0b4f4a",
900
+ "950": "#022f2e"
901
+ },
902
+ "cyan": {
903
+ "50": "#ecfeff",
904
+ "100": "#cefafe",
905
+ "200": "#a2f4fd",
906
+ "300": "#53eafd",
907
+ "400": "#00d3f2",
908
+ "500": "#00b8db",
909
+ "600": "#0092b8",
910
+ "700": "#007595",
911
+ "800": "#005f78",
912
+ "900": "#104e64",
913
+ "950": "#053345"
914
+ },
915
+ "sky": {
916
+ "50": "#f0f9ff",
917
+ "100": "#dff2fe",
918
+ "200": "#b8e6fe",
919
+ "300": "#74d4ff",
920
+ "400": "#00bcff",
921
+ "500": "#00a6f4",
922
+ "600": "#0084d1",
923
+ "700": "#0069a8",
924
+ "800": "#00598a",
925
+ "900": "#024a70",
926
+ "950": "#052f4a"
927
+ },
928
+ "blue": {
929
+ "50": "#eff6ff",
930
+ "100": "#dbeafe",
931
+ "200": "#bedbff",
932
+ "300": "#8ec5ff",
933
+ "400": "#51a2ff",
934
+ "500": "#2b7fff",
935
+ "600": "#155dfc",
936
+ "700": "#1447e6",
937
+ "800": "#193cb8",
938
+ "900": "#1c398e",
939
+ "950": "#162456"
940
+ },
941
+ "indigo": {
942
+ "50": "#eef2ff",
943
+ "100": "#e0e7ff",
944
+ "200": "#c6d2ff",
945
+ "300": "#a3b3ff",
946
+ "400": "#7c86ff",
947
+ "500": "#615fff",
948
+ "600": "#4f39f6",
949
+ "700": "#432dd7",
950
+ "800": "#372aac",
951
+ "900": "#312c85",
952
+ "950": "#1e1a4d"
953
+ },
954
+ "violet": {
955
+ "50": "#f5f3ff",
956
+ "100": "#ede9fe",
957
+ "200": "#ddd6ff",
958
+ "300": "#c4b4ff",
959
+ "400": "#a684ff",
960
+ "500": "#8e51ff",
961
+ "600": "#7f22fe",
962
+ "700": "#7008e7",
963
+ "800": "#5d0ec0",
964
+ "900": "#4d179a",
965
+ "950": "#2f0d68"
966
+ },
967
+ "purple": {
968
+ "50": "#faf5ff",
969
+ "100": "#f3e8ff",
970
+ "200": "#e9d4ff",
971
+ "300": "#dab2ff",
972
+ "400": "#c27aff",
973
+ "500": "#ad46ff",
974
+ "600": "#9810fa",
975
+ "700": "#8200db",
976
+ "800": "#6e11b0",
977
+ "900": "#59168b",
978
+ "950": "#3c0366"
979
+ },
980
+ "fuchsia": {
981
+ "50": "#fdf4ff",
982
+ "100": "#fae8ff",
983
+ "200": "#f6cfff",
984
+ "300": "#f4a8ff",
985
+ "400": "#ed6aff",
986
+ "500": "#e12afb",
987
+ "600": "#c800de",
988
+ "700": "#a800b7",
989
+ "800": "#8a0194",
990
+ "900": "#721378",
991
+ "950": "#4b004f"
992
+ },
993
+ "pink": {
994
+ "50": "#fdf2f8",
995
+ "100": "#fce7f3",
996
+ "200": "#fccee8",
997
+ "300": "#fda5d5",
998
+ "400": "#fb64b6",
999
+ "500": "#f6339a",
1000
+ "600": "#e60076",
1001
+ "700": "#c6005c",
1002
+ "800": "#a3004c",
1003
+ "900": "#861043",
1004
+ "950": "#510424"
1005
+ },
1006
+ "rose": {
1007
+ "50": "#fff1f2",
1008
+ "100": "#ffe4e6",
1009
+ "200": "#ffccd3",
1010
+ "300": "#ffa1ad",
1011
+ "400": "#ff637e",
1012
+ "500": "#ff2056",
1013
+ "600": "#ec003f",
1014
+ "700": "#c70036",
1015
+ "800": "#a50036",
1016
+ "900": "#8b0836",
1017
+ "950": "#4d0218"
1018
+ },
1019
+ "slate": {
1020
+ "50": "#f8fafc",
1021
+ "100": "#f1f5f9",
1022
+ "200": "#e2e8f0",
1023
+ "300": "#cad5e2",
1024
+ "400": "#90a1b9",
1025
+ "500": "#62748e",
1026
+ "600": "#45556c",
1027
+ "700": "#314158",
1028
+ "800": "#1d293d",
1029
+ "900": "#0f172b",
1030
+ "950": "#020618"
1031
+ },
1032
+ "gray": {
1033
+ "50": "#f9fafb",
1034
+ "100": "#f3f4f6",
1035
+ "200": "#e5e7eb",
1036
+ "300": "#d1d5dc",
1037
+ "400": "#99a1af",
1038
+ "500": "#6a7282",
1039
+ "600": "#4a5565",
1040
+ "700": "#364153",
1041
+ "800": "#1e2939",
1042
+ "900": "#101828",
1043
+ "950": "#030712"
1044
+ },
1045
+ "zinc": {
1046
+ "50": "#fafafa",
1047
+ "100": "#f4f4f5",
1048
+ "200": "#e4e4e7",
1049
+ "300": "#d4d4d8",
1050
+ "400": "#9f9fa9",
1051
+ "500": "#71717b",
1052
+ "600": "#52525c",
1053
+ "700": "#3f3f46",
1054
+ "800": "#27272a",
1055
+ "900": "#18181b",
1056
+ "950": "#09090b"
1057
+ },
1058
+ "neutral": {
1059
+ "50": "#fafafa",
1060
+ "100": "#f5f5f5",
1061
+ "200": "#e5e5e5",
1062
+ "300": "#d4d4d4",
1063
+ "400": "#a1a1a1",
1064
+ "500": "#737373",
1065
+ "600": "#525252",
1066
+ "700": "#404040",
1067
+ "800": "#262626",
1068
+ "900": "#171717",
1069
+ "950": "#0a0a0a"
1070
+ },
1071
+ "stone": {
1072
+ "50": "#fafaf9",
1073
+ "100": "#f5f5f4",
1074
+ "200": "#e7e5e4",
1075
+ "300": "#d6d3d1",
1076
+ "400": "#a6a09b",
1077
+ "500": "#79716b",
1078
+ "600": "#57534d",
1079
+ "700": "#44403b",
1080
+ "800": "#292524",
1081
+ "900": "#1c1917",
1082
+ "950": "#0c0a09"
1083
+ },
1084
+ "mauve": {
1085
+ "50": "#fafafa",
1086
+ "100": "#f3f1f3",
1087
+ "200": "#e7e4e7",
1088
+ "300": "#d7d0d7",
1089
+ "400": "#a89ea9",
1090
+ "500": "#79697b",
1091
+ "600": "#594c5b",
1092
+ "700": "#463947",
1093
+ "800": "#2a212c",
1094
+ "900": "#1d161e",
1095
+ "950": "#0c090c"
1096
+ },
1097
+ "olive": {
1098
+ "50": "#fbfbf9",
1099
+ "100": "#f4f4f0",
1100
+ "200": "#e8e8e3",
1101
+ "300": "#d8d8d0",
1102
+ "400": "#abab9c",
1103
+ "500": "#7c7c67",
1104
+ "600": "#5b5b4b",
1105
+ "700": "#474739",
1106
+ "800": "#2b2b22",
1107
+ "900": "#1d1d16",
1108
+ "950": "#0c0c09"
1109
+ },
1110
+ "mist": {
1111
+ "50": "#f9fbfb",
1112
+ "100": "#f1f3f3",
1113
+ "200": "#e3e7e8",
1114
+ "300": "#d0d6d8",
1115
+ "400": "#9ca8ab",
1116
+ "500": "#67787c",
1117
+ "600": "#4b585b",
1118
+ "700": "#394447",
1119
+ "800": "#22292b",
1120
+ "900": "#161b1d",
1121
+ "950": "#090b0c"
1122
+ },
1123
+ "taupe": {
1124
+ "50": "#fbfaf9",
1125
+ "100": "#f3f1f1",
1126
+ "200": "#e8e4e3",
1127
+ "300": "#d8d2d0",
1128
+ "400": "#aba09c",
1129
+ "500": "#7c6d67",
1130
+ "600": "#5b4f4b",
1131
+ "700": "#473c39",
1132
+ "800": "#2b2422",
1133
+ "900": "#1d1816",
1134
+ "950": "#0c0a09"
1135
+ }
1136
+ }
799
1137
  },
800
1138
  "space": {
801
1139
  "0": "0rem",
@@ -1208,6 +1546,57 @@ var coreTokens = {
1208
1546
  "fontWeight": 900,
1209
1547
  "letterSpacing": "0em"
1210
1548
  }
1549
+ },
1550
+ "heading": {
1551
+ "h1": {
1552
+ "fontFamily": "{typography.families.sans}",
1553
+ "fontSize": "{typography.scale.5xl.fontSize}",
1554
+ "lineHeight": "{typography.scale.5xl.lineHeight}",
1555
+ "fontWeight": 800,
1556
+ "letterSpacing": "{typography.scale.5xl.letterSpacing}"
1557
+ },
1558
+ "h2": {
1559
+ "fontFamily": "{typography.families.sans}",
1560
+ "fontSize": "{typography.scale.4xl.fontSize}",
1561
+ "lineHeight": "{typography.scale.4xl.lineHeight}",
1562
+ "fontWeight": 700,
1563
+ "letterSpacing": "{typography.scale.4xl.letterSpacing}"
1564
+ },
1565
+ "h3": {
1566
+ "fontFamily": "{typography.families.sans}",
1567
+ "fontSize": "{typography.scale.3xl.fontSize}",
1568
+ "lineHeight": "{typography.scale.3xl.lineHeight}",
1569
+ "fontWeight": 700,
1570
+ "letterSpacing": "{typography.scale.3xl.letterSpacing}"
1571
+ },
1572
+ "h4": {
1573
+ "fontFamily": "{typography.families.sans}",
1574
+ "fontSize": "{typography.scale.2xl.fontSize}",
1575
+ "lineHeight": "{typography.scale.2xl.lineHeight}",
1576
+ "fontWeight": 600,
1577
+ "letterSpacing": "{typography.scale.2xl.letterSpacing}"
1578
+ },
1579
+ "h5": {
1580
+ "fontFamily": "{typography.families.sans}",
1581
+ "fontSize": "{typography.scale.xl.fontSize}",
1582
+ "lineHeight": "{typography.scale.xl.lineHeight}",
1583
+ "fontWeight": 600,
1584
+ "letterSpacing": "{typography.scale.xl.letterSpacing}"
1585
+ },
1586
+ "h6": {
1587
+ "fontFamily": "{typography.families.sans}",
1588
+ "fontSize": "{typography.scale.lg.fontSize}",
1589
+ "lineHeight": "{typography.scale.lg.lineHeight}",
1590
+ "fontWeight": 600,
1591
+ "letterSpacing": "{typography.scale.lg.letterSpacing}"
1592
+ }
1593
+ },
1594
+ "body": {
1595
+ "fontFamily": "{typography.families.sans}",
1596
+ "fontSize": "{typography.scale.md.fontSize}",
1597
+ "lineHeight": "{typography.scale.md.lineHeight}",
1598
+ "fontWeight": 400,
1599
+ "letterSpacing": "{typography.scale.md.letterSpacing}"
1211
1600
  }
1212
1601
  }
1213
1602
  };
@@ -1296,14 +1685,17 @@ var createCssVariableMap = (tokens2, options = {}) => {
1296
1685
  if (value === void 0) return;
1297
1686
  map[name] = resolveValue(tokens2, value);
1298
1687
  };
1299
- Object.entries(baseTokens.colors).forEach(([group, scale]) => {
1300
- if (typeof scale === "string" || typeof scale === "number") {
1301
- assign(toVariableName(prefix, "color", group), scale);
1688
+ const assignColorGroup = (parts, value) => {
1689
+ if (typeof value === "string" || typeof value === "number") {
1690
+ assign(toVariableName(prefix, "color", ...parts), value);
1302
1691
  return;
1303
1692
  }
1304
- Object.entries(scale).forEach(([step, value]) => {
1305
- assign(toVariableName(prefix, "color", group, step), value);
1693
+ Object.entries(value).forEach(([key, nested]) => {
1694
+ assignColorGroup([...parts, key], nested);
1306
1695
  });
1696
+ };
1697
+ Object.entries(baseTokens.colors).forEach(([group, scale]) => {
1698
+ assignColorGroup([group], scale);
1307
1699
  });
1308
1700
  if (baseTokens.space) {
1309
1701
  Object.entries(baseTokens.space).forEach(([key, value]) => {
@@ -1392,6 +1784,23 @@ var createCssVariableMap = (tokens2, options = {}) => {
1392
1784
  const scaleEntry = entry;
1393
1785
  assign(toVariableName(prefix, "font", key, "letter-spacing"), scaleEntry.letterSpacing);
1394
1786
  });
1787
+ const assignRole = (rolePrefixParts, entry) => {
1788
+ assign(toVariableName(prefix, ...rolePrefixParts, "family"), entry.fontFamily);
1789
+ assign(toVariableName(prefix, ...rolePrefixParts, "size"), entry.fontSize);
1790
+ assign(toVariableName(prefix, ...rolePrefixParts, "line-height"), entry.lineHeight);
1791
+ assign(toVariableName(prefix, ...rolePrefixParts, "weight"), entry.fontWeight);
1792
+ assign(toVariableName(prefix, ...rolePrefixParts, "letter-spacing"), entry.letterSpacing);
1793
+ };
1794
+ const heading = baseTokens.typography?.heading;
1795
+ if (heading) {
1796
+ Object.entries(heading).forEach(([level, entry]) => {
1797
+ assignRole(["heading", level], entry);
1798
+ });
1799
+ }
1800
+ const body = baseTokens.typography?.body;
1801
+ if (body) {
1802
+ assignRole(["body"], body);
1803
+ }
1395
1804
  Object.entries(baseTokens.shadows).forEach(([key, value]) => {
1396
1805
  assign(toVariableName(prefix, "shadow", key), value);
1397
1806
  });
@@ -1536,66 +1945,10 @@ ${darkBlock}
1536
1945
 
1537
1946
  // src/index.ts
1538
1947
  var tokens = coreTokens;
1539
- var sanitizeFontFamily = (value) => value.split(",").map((segment) => segment.trim().replace(/^['"]|['"]$/g, "")).filter(Boolean);
1540
- var createTailwindTheme = (source = tokens) => {
1541
- const colors = {};
1542
- Object.entries(source.colors).forEach(([group, value]) => {
1543
- if (typeof value === "object" && value !== null) {
1544
- colors[group] = { ...value };
1545
- } else {
1546
- colors[group] = value;
1547
- }
1548
- });
1549
- const fontFamily = Object.entries(source.typography.families).reduce((acc, [key, value]) => {
1550
- acc[key] = sanitizeFontFamily(value);
1551
- return acc;
1552
- }, {});
1553
- const fontSize = Object.entries(source.typography.scale).reduce((acc, [key, entry]) => {
1554
- acc[key] = [
1555
- entry.fontSize,
1556
- {
1557
- lineHeight: entry.lineHeight,
1558
- ...entry.fontWeight ? { fontWeight: entry.fontWeight } : {},
1559
- ..."letterSpacing" in entry ? { letterSpacing: entry.letterSpacing } : {}
1560
- }
1561
- ];
1562
- return acc;
1563
- }, {});
1564
- return {
1565
- colors,
1566
- spacing: { ...source.space ?? {} },
1567
- borderRadius: { ...source.radii ?? {} },
1568
- fontFamily,
1569
- fontSize,
1570
- boxShadow: { ...source.shadows },
1571
- screens: { ...source.breakpoints },
1572
- zIndex: { ...source.zIndex },
1573
- transitionDuration: { ...source.transitions.duration },
1574
- transitionTimingFunction: { ...source.transitions.easing },
1575
- opacity: { ...source.opacity },
1576
- maxWidth: {
1577
- container: source.layout?.container?.maxWidth,
1578
- prose: source.layout?.container?.maxWidthProse
1579
- },
1580
- width: {
1581
- sidebar: source.layout?.sidebar?.width
1582
- },
1583
- borderWidth: {
1584
- DEFAULT: source.border?.width.base,
1585
- ...source.border?.width ?? {}
1586
- }
1587
- };
1588
- };
1589
- var tailwindTheme = createTailwindTheme(tokens);
1590
- var tailwindPreset = {
1591
- theme: tailwindTheme
1592
- };
1593
1948
  var index_default = tokens;
1594
1949
  // Annotate the CommonJS export names for ESM import in node:
1595
1950
  0 && (module.exports = {
1596
1951
  generateCssVariables,
1597
- tailwindPreset,
1598
- tailwindTheme,
1599
1952
  tokens
1600
1953
  });
1601
1954
  //# sourceMappingURL=index.cjs.map