@digdir/designsystemet 1.13.2 → 1.14.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/bin/config.js +50 -658
- package/dist/bin/designsystemet.d.ts.map +1 -1
- package/dist/bin/designsystemet.js +136 -4623
- package/dist/bin/options.js +22 -14
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js +9 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js +8 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js +13 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js +10 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js +10 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js +53 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js +14 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js +9 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js +32 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js +15 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/types/index.js +11 -0
- package/dist/package.js +5 -0
- package/dist/src/colors/colorMetadata.js +255 -261
- package/dist/src/colors/index.js +5 -522
- package/dist/src/colors/theme.js +104 -343
- package/dist/src/colors/types.js +22 -25
- package/dist/src/colors/utils.js +241 -154
- package/dist/src/config.js +103 -444
- package/dist/src/index.js +10 -3588
- package/dist/src/migrations/beta-to-v1.js +339 -537
- package/dist/src/migrations/codemods/css/plugins.js +31 -42
- package/dist/src/migrations/codemods/css/run.js +20 -151
- package/dist/src/migrations/color-rename-next49.js +44 -220
- package/dist/src/migrations/index.js +7 -577
- package/dist/src/scripts/update-preview-tokens.d.ts.map +1 -1
- package/dist/src/tokens/build.js +39 -1816
- package/dist/src/tokens/create/files.d.ts +10 -5
- package/dist/src/tokens/create/files.d.ts.map +1 -1
- package/dist/src/tokens/create/files.js +44 -601
- package/dist/src/tokens/create/generators/$designsystemet.js +8 -97
- package/dist/src/tokens/create/generators/$metadata.d.ts +7 -3
- package/dist/src/tokens/create/generators/$metadata.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/$metadata.js +24 -21
- package/dist/src/tokens/create/generators/$themes.d.ts +2 -4
- package/dist/src/tokens/create/generators/$themes.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/$themes.js +139 -312
- package/dist/src/tokens/create/generators/primitives/color-scheme.js +68 -443
- package/dist/src/tokens/create/generators/primitives/globals.js +141 -147
- package/dist/src/tokens/create/generators/primitives/size.js +146 -156
- package/dist/src/tokens/create/generators/primitives/typography.js +213 -217
- package/dist/src/tokens/create/generators/semantic/color-modes.js +24 -59
- package/dist/src/tokens/create/generators/semantic/color.js +42 -326
- package/dist/src/tokens/create/generators/semantic/style.js +379 -382
- package/dist/src/tokens/create/generators/themes/theme.js +108 -392
- package/dist/src/tokens/create.d.ts +2 -1
- package/dist/src/tokens/create.d.ts.map +1 -1
- package/dist/src/tokens/create.js +50 -1591
- package/dist/src/tokens/format.d.ts.map +1 -1
- package/dist/src/tokens/format.js +35 -3324
- package/dist/src/tokens/generate-config.js +155 -298
- package/dist/src/tokens/index.js +3 -3344
- package/dist/src/tokens/process/configs/color.js +50 -1085
- package/dist/src/tokens/process/configs/semantic.js +45 -1083
- package/dist/src/tokens/process/configs/shared.js +18 -109
- package/dist/src/tokens/process/configs/size-mode.js +27 -1082
- package/dist/src/tokens/process/configs/size.js +32 -1083
- package/dist/src/tokens/process/configs/type-scale.js +49 -1083
- package/dist/src/tokens/process/configs/typography.js +63 -1084
- package/dist/src/tokens/process/configs.js +91 -1224
- package/dist/src/tokens/process/formats/css/color.js +58 -1079
- package/dist/src/tokens/process/formats/css/semantic.js +27 -1081
- package/dist/src/tokens/process/formats/css/size-mode.js +43 -1077
- package/dist/src/tokens/process/formats/css/size.js +86 -1079
- package/dist/src/tokens/process/formats/css/type-scale.js +53 -1083
- package/dist/src/tokens/process/formats/css/typography.js +27 -1081
- package/dist/src/tokens/process/formats/css.js +18 -1081
- package/dist/src/tokens/process/output/declarations.js +18 -1201
- package/dist/src/tokens/process/output/tailwind.js +26 -40
- package/dist/src/tokens/process/output/theme.js +73 -206
- package/dist/src/tokens/process/platform.js +165 -1355
- package/dist/src/tokens/process/transformers.js +49 -89
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +100 -1183
- package/dist/src/tokens/process/utils/kebab-case.js +7 -5
- package/dist/src/tokens/types.d.ts +6 -0
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/types.js +6 -7
- package/dist/src/tokens/utils.d.ts +2 -1
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +107 -93
- package/dist/src/types.js +1 -5
- package/dist/src/utils/filesystem.js +112 -124
- package/package.json +12 -15
- package/configs/test-tokens.config.json +0 -82
- package/dist/src/scripts/createJsonSchema.js +0 -409
- package/dist/src/scripts/update-preview-tokens.js +0 -3353
|
@@ -1,3327 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
|
|
8
|
-
BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
|
|
9
|
-
})(BoxShadowTypes || (BoxShadowTypes = {}));
|
|
10
|
-
|
|
11
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
|
|
12
|
-
var ColorModifierTypes;
|
|
13
|
-
(function(ColorModifierTypes2) {
|
|
14
|
-
ColorModifierTypes2["LIGHTEN"] = "lighten";
|
|
15
|
-
ColorModifierTypes2["DARKEN"] = "darken";
|
|
16
|
-
ColorModifierTypes2["MIX"] = "mix";
|
|
17
|
-
ColorModifierTypes2["ALPHA"] = "alpha";
|
|
18
|
-
})(ColorModifierTypes || (ColorModifierTypes = {}));
|
|
19
|
-
|
|
20
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
|
|
21
|
-
var ColorSpaceTypes;
|
|
22
|
-
(function(ColorSpaceTypes2) {
|
|
23
|
-
ColorSpaceTypes2["LCH"] = "lch";
|
|
24
|
-
ColorSpaceTypes2["SRGB"] = "srgb";
|
|
25
|
-
ColorSpaceTypes2["P3"] = "p3";
|
|
26
|
-
ColorSpaceTypes2["HSL"] = "hsl";
|
|
27
|
-
})(ColorSpaceTypes || (ColorSpaceTypes = {}));
|
|
28
|
-
|
|
29
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js
|
|
30
|
-
var Properties;
|
|
31
|
-
(function(Properties2) {
|
|
32
|
-
Properties2["sizing"] = "sizing";
|
|
33
|
-
Properties2["height"] = "height";
|
|
34
|
-
Properties2["width"] = "width";
|
|
35
|
-
Properties2["spacing"] = "spacing";
|
|
36
|
-
Properties2["verticalPadding"] = "verticalPadding";
|
|
37
|
-
Properties2["horizontalPadding"] = "horizontalPadding";
|
|
38
|
-
Properties2["paddingTop"] = "paddingTop";
|
|
39
|
-
Properties2["paddingRight"] = "paddingRight";
|
|
40
|
-
Properties2["paddingBottom"] = "paddingBottom";
|
|
41
|
-
Properties2["paddingLeft"] = "paddingLeft";
|
|
42
|
-
Properties2["itemSpacing"] = "itemSpacing";
|
|
43
|
-
Properties2["fill"] = "fill";
|
|
44
|
-
Properties2["backgroundBlur"] = "backgroundBlur";
|
|
45
|
-
Properties2["border"] = "border";
|
|
46
|
-
Properties2["borderTop"] = "borderTop";
|
|
47
|
-
Properties2["borderRight"] = "borderRight";
|
|
48
|
-
Properties2["borderBottom"] = "borderBottom";
|
|
49
|
-
Properties2["borderLeft"] = "borderLeft";
|
|
50
|
-
Properties2["borderColor"] = "borderColor";
|
|
51
|
-
Properties2["borderRadius"] = "borderRadius";
|
|
52
|
-
Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
|
|
53
|
-
Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
|
|
54
|
-
Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
|
|
55
|
-
Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
|
|
56
|
-
Properties2["borderWidth"] = "borderWidth";
|
|
57
|
-
Properties2["borderWidthTop"] = "borderWidthTop";
|
|
58
|
-
Properties2["borderWidthRight"] = "borderWidthRight";
|
|
59
|
-
Properties2["borderWidthBottom"] = "borderWidthBottom";
|
|
60
|
-
Properties2["borderWidthLeft"] = "borderWidthLeft";
|
|
61
|
-
Properties2["boxShadow"] = "boxShadow";
|
|
62
|
-
Properties2["opacity"] = "opacity";
|
|
63
|
-
Properties2["fontFamilies"] = "fontFamilies";
|
|
64
|
-
Properties2["fontWeights"] = "fontWeights";
|
|
65
|
-
Properties2["fontSizes"] = "fontSizes";
|
|
66
|
-
Properties2["lineHeights"] = "lineHeights";
|
|
67
|
-
Properties2["typography"] = "typography";
|
|
68
|
-
Properties2["composition"] = "composition";
|
|
69
|
-
Properties2["letterSpacing"] = "letterSpacing";
|
|
70
|
-
Properties2["paragraphSpacing"] = "paragraphSpacing";
|
|
71
|
-
Properties2["textCase"] = "textCase";
|
|
72
|
-
Properties2["dimension"] = "dimension";
|
|
73
|
-
Properties2["textDecoration"] = "textDecoration";
|
|
74
|
-
Properties2["asset"] = "asset";
|
|
75
|
-
Properties2["tokenValue"] = "tokenValue";
|
|
76
|
-
Properties2["value"] = "value";
|
|
77
|
-
Properties2["tokenName"] = "tokenName";
|
|
78
|
-
Properties2["description"] = "description";
|
|
79
|
-
})(Properties || (Properties = {}));
|
|
80
|
-
|
|
81
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
|
|
82
|
-
var TokenSetStatus;
|
|
83
|
-
(function(TokenSetStatus2) {
|
|
84
|
-
TokenSetStatus2["DISABLED"] = "disabled";
|
|
85
|
-
TokenSetStatus2["SOURCE"] = "source";
|
|
86
|
-
TokenSetStatus2["ENABLED"] = "enabled";
|
|
87
|
-
})(TokenSetStatus || (TokenSetStatus = {}));
|
|
88
|
-
|
|
89
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
|
|
90
|
-
var TokenTypes;
|
|
91
|
-
(function(TokenTypes2) {
|
|
92
|
-
TokenTypes2["OTHER"] = "other";
|
|
93
|
-
TokenTypes2["COLOR"] = "color";
|
|
94
|
-
TokenTypes2["BORDER_RADIUS"] = "borderRadius";
|
|
95
|
-
TokenTypes2["SIZING"] = "sizing";
|
|
96
|
-
TokenTypes2["SPACING"] = "spacing";
|
|
97
|
-
TokenTypes2["TEXT"] = "text";
|
|
98
|
-
TokenTypes2["TYPOGRAPHY"] = "typography";
|
|
99
|
-
TokenTypes2["OPACITY"] = "opacity";
|
|
100
|
-
TokenTypes2["BORDER_WIDTH"] = "borderWidth";
|
|
101
|
-
TokenTypes2["STROKE_STYLE"] = "strokeStyle";
|
|
102
|
-
TokenTypes2["BOX_SHADOW"] = "boxShadow";
|
|
103
|
-
TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
|
|
104
|
-
TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
|
|
105
|
-
TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
|
|
106
|
-
TokenTypes2["FONT_SIZES"] = "fontSizes";
|
|
107
|
-
TokenTypes2["LETTER_SPACING"] = "letterSpacing";
|
|
108
|
-
TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
109
|
-
TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
110
|
-
TokenTypes2["TEXT_DECORATION"] = "textDecoration";
|
|
111
|
-
TokenTypes2["TEXT_CASE"] = "textCase";
|
|
112
|
-
TokenTypes2["COMPOSITION"] = "composition";
|
|
113
|
-
TokenTypes2["DIMENSION"] = "dimension";
|
|
114
|
-
TokenTypes2["BORDER"] = "border";
|
|
115
|
-
TokenTypes2["ASSET"] = "asset";
|
|
116
|
-
TokenTypes2["BOOLEAN"] = "boolean";
|
|
117
|
-
TokenTypes2["NUMBER"] = "number";
|
|
118
|
-
})(TokenTypes || (TokenTypes = {}));
|
|
119
|
-
|
|
120
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js
|
|
121
|
-
var BorderValues;
|
|
122
|
-
(function(BorderValues2) {
|
|
123
|
-
BorderValues2["BORDER_COLOR"] = "color";
|
|
124
|
-
BorderValues2["BORDER_WIDTH"] = "width";
|
|
125
|
-
BorderValues2["BORDER_STYLE"] = "style";
|
|
126
|
-
})(BorderValues || (BorderValues = {}));
|
|
127
|
-
|
|
128
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
|
|
129
|
-
var StrokeStyleValues;
|
|
130
|
-
(function(StrokeStyleValues2) {
|
|
131
|
-
StrokeStyleValues2["SOLID"] = "solid";
|
|
132
|
-
StrokeStyleValues2["DASHED"] = "dashed";
|
|
133
|
-
StrokeStyleValues2["DOTTED"] = "dotted";
|
|
134
|
-
StrokeStyleValues2["DOUBLE"] = "double";
|
|
135
|
-
StrokeStyleValues2["GROOVE"] = "groove";
|
|
136
|
-
StrokeStyleValues2["RIDGE"] = "ridge";
|
|
137
|
-
StrokeStyleValues2["OUTSET"] = "outset";
|
|
138
|
-
StrokeStyleValues2["INSET"] = "inset";
|
|
139
|
-
})(StrokeStyleValues || (StrokeStyleValues = {}));
|
|
140
|
-
|
|
141
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
|
|
142
|
-
var BoxShadowValues;
|
|
143
|
-
(function(BoxShadowValues2) {
|
|
144
|
-
BoxShadowValues2["TYPE"] = "type";
|
|
145
|
-
BoxShadowValues2["COLOR"] = "color";
|
|
146
|
-
BoxShadowValues2["X"] = "x";
|
|
147
|
-
BoxShadowValues2["Y"] = "y";
|
|
148
|
-
BoxShadowValues2["BLUR"] = "blur";
|
|
149
|
-
BoxShadowValues2["SPREAD"] = "spread";
|
|
150
|
-
BoxShadowValues2["BLEND_MODE"] = "blendMode";
|
|
151
|
-
})(BoxShadowValues || (BoxShadowValues = {}));
|
|
152
|
-
|
|
153
|
-
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
|
|
154
|
-
var TypographyValues;
|
|
155
|
-
(function(TypographyValues2) {
|
|
156
|
-
TypographyValues2["FONT_FAMILY"] = "fontFamily";
|
|
157
|
-
TypographyValues2["FONT_WEIGHT"] = "fontWeight";
|
|
158
|
-
TypographyValues2["LINE_HEIGHT"] = "lineHeight";
|
|
159
|
-
TypographyValues2["FONT_SIZE"] = "fontSize";
|
|
160
|
-
TypographyValues2["LETTER_SPACING"] = "letterSpacing";
|
|
161
|
-
TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
162
|
-
TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
163
|
-
TypographyValues2["TEXT_DECORATION"] = "textDecoration";
|
|
164
|
-
TypographyValues2["TEXT_CASE"] = "textCase";
|
|
165
|
-
})(TypographyValues || (TypographyValues = {}));
|
|
166
|
-
|
|
167
|
-
// src/tokens/create/generators/$themes.ts
|
|
168
|
-
var capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
|
|
169
|
-
async function createHash(text, algo = "SHA-1") {
|
|
170
|
-
const crypto = globalThis.crypto;
|
|
171
|
-
return Array.from(
|
|
172
|
-
new Uint8Array(await crypto.subtle.digest(algo, new TextEncoder().encode(text))),
|
|
173
|
-
(byte) => byte.toString(16).padStart(2, "0")
|
|
174
|
-
).join("");
|
|
175
|
-
}
|
|
176
|
-
async function generate$Themes(colorSchemes, themes, colors, sizeModes2) {
|
|
177
|
-
return [
|
|
178
|
-
...generateSizeGroup(sizeModes2),
|
|
179
|
-
...await generateThemesGroup(themes),
|
|
180
|
-
...generateTypographyGroup(themes),
|
|
181
|
-
...generateColorSchemesGroup(colorSchemes, themes),
|
|
182
|
-
generateSemanticGroup(),
|
|
183
|
-
...await generateColorGroup("main", colors),
|
|
184
|
-
...await generateColorGroup("support", colors)
|
|
185
|
-
];
|
|
186
|
-
}
|
|
187
|
-
function generateSizeGroup(_sizes) {
|
|
188
|
-
return [
|
|
189
|
-
{
|
|
190
|
-
id: "8b2c8cc86611a34b135cb22948666779361fd729",
|
|
191
|
-
name: "medium",
|
|
192
|
-
$figmaStyleReferences: {},
|
|
193
|
-
selectedTokenSets: {
|
|
194
|
-
"primitives/modes/size/medium": TokenSetStatus.SOURCE,
|
|
195
|
-
"primitives/modes/size/global": TokenSetStatus.ENABLED,
|
|
196
|
-
"primitives/modes/typography/size/medium": TokenSetStatus.ENABLED
|
|
197
|
-
},
|
|
198
|
-
$figmaCollectionId: "VariableCollectionId:36248:20757",
|
|
199
|
-
$figmaModeId: "41630:1",
|
|
200
|
-
group: "Size"
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
id: "d49b9eebeb48a4f165a74b7261733d0a73370f0e",
|
|
204
|
-
name: "large",
|
|
205
|
-
$figmaStyleReferences: {},
|
|
206
|
-
selectedTokenSets: {
|
|
207
|
-
"primitives/modes/size/large": TokenSetStatus.SOURCE,
|
|
208
|
-
"primitives/modes/size/global": TokenSetStatus.ENABLED,
|
|
209
|
-
"primitives/modes/typography/size/large": TokenSetStatus.ENABLED
|
|
210
|
-
},
|
|
211
|
-
$figmaCollectionId: "VariableCollectionId:36248:20757",
|
|
212
|
-
$figmaModeId: "41630:2",
|
|
213
|
-
group: "Size"
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
id: "fb11567729c298ca37c9da4e3a27716a23480824",
|
|
217
|
-
name: "small",
|
|
218
|
-
$figmaStyleReferences: {},
|
|
219
|
-
selectedTokenSets: {
|
|
220
|
-
"primitives/modes/size/small": TokenSetStatus.SOURCE,
|
|
221
|
-
"primitives/modes/size/global": TokenSetStatus.ENABLED,
|
|
222
|
-
"primitives/modes/typography/size/small": TokenSetStatus.ENABLED
|
|
223
|
-
},
|
|
224
|
-
$figmaCollectionId: "VariableCollectionId:36248:20757",
|
|
225
|
-
$figmaModeId: "41630:3",
|
|
226
|
-
group: "Size"
|
|
227
|
-
}
|
|
228
|
-
];
|
|
229
|
-
}
|
|
230
|
-
var colorSchemeDefaults = {
|
|
231
|
-
light: {
|
|
232
|
-
name: "Light",
|
|
233
|
-
selectedTokenSets: {},
|
|
234
|
-
id: "0daa3ca0b427b9349da7e7dc00101b5668972926",
|
|
235
|
-
$figmaCollectionId: "VariableCollectionId:34811:5472",
|
|
236
|
-
$figmaModeId: "34811:0"
|
|
237
|
-
},
|
|
238
|
-
dark: {
|
|
239
|
-
name: "Dark",
|
|
240
|
-
selectedTokenSets: {},
|
|
241
|
-
id: "9ebd8aed52afbffc17e2666e8b4653a53498b257",
|
|
242
|
-
$figmaCollectionId: "VariableCollectionId:34811:5472",
|
|
243
|
-
$figmaModeId: "34811:1"
|
|
244
|
-
},
|
|
245
|
-
contrast: {
|
|
246
|
-
name: "Contrast",
|
|
247
|
-
selectedTokenSets: {},
|
|
248
|
-
id: "9ebd8aed52afbffc17e2666e8b4653a53498b123",
|
|
249
|
-
$figmaCollectionId: "VariableCollectionId:34811:5472",
|
|
250
|
-
$figmaModeId: "34811:2"
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
function generateColorSchemesGroup(colorSchemes, themes) {
|
|
254
|
-
return colorSchemes.map(
|
|
255
|
-
(scheme) => ({
|
|
256
|
-
...colorSchemeDefaults[scheme],
|
|
257
|
-
selectedTokenSets: Object.fromEntries([
|
|
258
|
-
...themes.map((theme) => [`primitives/modes/color-scheme/${scheme}/${theme}`, TokenSetStatus.ENABLED])
|
|
259
|
-
]),
|
|
260
|
-
group: "Color scheme"
|
|
261
|
-
})
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
async function generateThemesGroup(themes) {
|
|
265
|
-
return Promise.all(
|
|
266
|
-
themes.map(
|
|
267
|
-
async (theme, index) => ({
|
|
268
|
-
id: await createHash(theme),
|
|
269
|
-
$figmaCollectionId: "VariableCollectionId:36528:61712",
|
|
270
|
-
$figmaModeId: `40960:${index + 6}`,
|
|
271
|
-
// Start on 6 in Token Studio and Community file for some reason
|
|
272
|
-
name: theme,
|
|
273
|
-
selectedTokenSets: {
|
|
274
|
-
[`themes/${theme}`]: TokenSetStatus.ENABLED
|
|
275
|
-
},
|
|
276
|
-
group: "Theme"
|
|
277
|
-
})
|
|
278
|
-
)
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
function generateSemanticGroup() {
|
|
282
|
-
return {
|
|
283
|
-
id: "541629445ef90ad5363f9e88f52a1ccb617e6f84",
|
|
284
|
-
name: "Semantic",
|
|
285
|
-
selectedTokenSets: {
|
|
286
|
-
"semantic/style": TokenSetStatus.ENABLED,
|
|
287
|
-
"semantic/color": TokenSetStatus.ENABLED,
|
|
288
|
-
"primitives/globals": TokenSetStatus.SOURCE
|
|
289
|
-
},
|
|
290
|
-
$figmaCollectionId: "VariableCollectionId:34811:5976",
|
|
291
|
-
$figmaModeId: "34811:5",
|
|
292
|
-
group: "Semantic"
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
async function generateColorGroup(group, colors) {
|
|
296
|
-
return Promise.all(
|
|
297
|
-
Object.entries(colors[group]).map(
|
|
298
|
-
async ([color]) => ({
|
|
299
|
-
id: await createHash(`${group}-${color}`),
|
|
300
|
-
name: color,
|
|
301
|
-
selectedTokenSets: {
|
|
302
|
-
[`semantic/modes/${group}-color/${color}`]: TokenSetStatus.ENABLED
|
|
303
|
-
},
|
|
304
|
-
group: `${capitalize(group)} color`
|
|
305
|
-
})
|
|
306
|
-
)
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
function generateTypographyGroup(themes) {
|
|
310
|
-
return [
|
|
311
|
-
{
|
|
312
|
-
id: "368d753fcac4455f289500eaa42e70dc0a03522f",
|
|
313
|
-
$figmaCollectionId: "VariableCollectionId:36248:20769",
|
|
314
|
-
$figmaModeId: "36248:2",
|
|
315
|
-
name: "Primary",
|
|
316
|
-
selectedTokenSets: Object.fromEntries(
|
|
317
|
-
themes.map((theme) => [`primitives/modes/typography/primary/${theme}`, TokenSetStatus.ENABLED])
|
|
318
|
-
),
|
|
319
|
-
group: "Typography"
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
id: "264b8bd1d40b364e1ea3acf09e49795ddd4c513c",
|
|
323
|
-
$figmaCollectionId: "VariableCollectionId:36248:20769",
|
|
324
|
-
$figmaModeId: "36248:3",
|
|
325
|
-
name: "Secondary",
|
|
326
|
-
selectedTokenSets: Object.fromEntries(
|
|
327
|
-
themes.map((theme) => [`primitives/modes/typography/secondary/${theme}`, TokenSetStatus.ENABLED])
|
|
328
|
-
),
|
|
329
|
-
group: "Typography"
|
|
330
|
-
}
|
|
331
|
-
];
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// src/tokens/create/generators/primitives/color-scheme.ts
|
|
335
|
-
import * as R4 from "ramda";
|
|
336
|
-
|
|
337
|
-
// src/colors/colorMetadata.ts
|
|
1
|
+
import { createTokens, tokenSetDimensions } from "./create.js";
|
|
2
|
+
import { colorNamesByCategory } from "./utils.js";
|
|
3
|
+
import { processThemeObject } from "./process/utils/getMultidimensionalThemes.js";
|
|
4
|
+
import { processPlatform } from "./process/platform.js";
|
|
5
|
+
import { createThemeCSSFiles } from "./process/output/theme.js";
|
|
6
|
+
import { generate$Themes } from "./create/generators/$themes.js";
|
|
338
7
|
import * as R from "ramda";
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
number: 2,
|
|
364
|
-
name: "background-tinted",
|
|
365
|
-
group: "background",
|
|
366
|
-
displayName: "Background Tinted",
|
|
367
|
-
description: {
|
|
368
|
-
long: "Background Tinted er en bakgrunnsfarge som har et hint av farge i seg.",
|
|
369
|
-
short: "Bakgrunn med et hint av farge i seg."
|
|
370
|
-
},
|
|
371
|
-
luminance: {
|
|
372
|
-
light: 0.9,
|
|
373
|
-
dark: 0.014,
|
|
374
|
-
contrast: 65e-4
|
|
375
|
-
}
|
|
376
|
-
},
|
|
377
|
-
"surface-default": {
|
|
378
|
-
number: 3,
|
|
379
|
-
name: "surface-default",
|
|
380
|
-
group: "surface",
|
|
381
|
-
displayName: "Surface Default",
|
|
382
|
-
description: {
|
|
383
|
-
long: "Surface Default brukes p\xE5 flater som ligger opp\xE5 bakgrunnsfargene. Dette er den mest n\xF8ytrale surface fargen.",
|
|
384
|
-
short: "Standardfarge for overflater / komponenter."
|
|
385
|
-
},
|
|
386
|
-
luminance: {
|
|
387
|
-
light: 1,
|
|
388
|
-
dark: 0.021,
|
|
389
|
-
contrast: 0.015
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
"surface-tinted": {
|
|
393
|
-
number: 4,
|
|
394
|
-
name: "surface-tinted",
|
|
395
|
-
group: "surface",
|
|
396
|
-
displayName: "Surface Tinted",
|
|
397
|
-
description: {
|
|
398
|
-
long: "Surface Tinted brukes p\xE5 flater som ligger opp\xE5 bakgrunnsfargene. Denne har et hint av farge i seg.",
|
|
399
|
-
short: "Overflater / komponenter med et hint av farge i seg."
|
|
400
|
-
},
|
|
401
|
-
luminance: {
|
|
402
|
-
light: 0.81,
|
|
403
|
-
dark: 0.027,
|
|
404
|
-
contrast: 0.015
|
|
405
|
-
}
|
|
406
|
-
},
|
|
407
|
-
"surface-hover": {
|
|
408
|
-
number: 5,
|
|
409
|
-
name: "surface-hover",
|
|
410
|
-
group: "surface",
|
|
411
|
-
displayName: "Surface Hover",
|
|
412
|
-
description: {
|
|
413
|
-
long: "Surface Hover brukes p\xE5 interaktive flater som ligger opp\xE5 bakgrunnsfargene i en hover state.",
|
|
414
|
-
short: "Hover-farge til overflater / komponenter."
|
|
415
|
-
},
|
|
416
|
-
luminance: {
|
|
417
|
-
light: 0.7,
|
|
418
|
-
dark: 0.036,
|
|
419
|
-
contrast: 0.028
|
|
420
|
-
}
|
|
421
|
-
},
|
|
422
|
-
"surface-active": {
|
|
423
|
-
number: 6,
|
|
424
|
-
name: "surface-active",
|
|
425
|
-
group: "surface",
|
|
426
|
-
displayName: "Surface Active",
|
|
427
|
-
description: {
|
|
428
|
-
long: "Surface Active brukes p\xE5 interaktive flater som ligger opp\xE5 bakgrunnsfargene i en active state.",
|
|
429
|
-
short: "Active-farge til overflater / komponenter."
|
|
430
|
-
},
|
|
431
|
-
luminance: {
|
|
432
|
-
light: 0.59,
|
|
433
|
-
dark: 0.056,
|
|
434
|
-
contrast: 0.045
|
|
435
|
-
}
|
|
436
|
-
},
|
|
437
|
-
"border-subtle": {
|
|
438
|
-
number: 7,
|
|
439
|
-
name: "border-subtle",
|
|
440
|
-
group: "border",
|
|
441
|
-
displayName: "Border Subtle",
|
|
442
|
-
description: {
|
|
443
|
-
long: "Border Subtle er den lyseste border-fargen og brukes for \xE5 skille elementer fra hverandre.",
|
|
444
|
-
short: "Border-farge med lav kontrast til dekorativ bruk (skillelinjer)."
|
|
445
|
-
},
|
|
446
|
-
luminance: {
|
|
447
|
-
light: 0.5,
|
|
448
|
-
dark: 0.08,
|
|
449
|
-
contrast: 0.26
|
|
450
|
-
}
|
|
451
|
-
},
|
|
452
|
-
"border-default": {
|
|
453
|
-
number: 8,
|
|
454
|
-
name: "border-default",
|
|
455
|
-
group: "border",
|
|
456
|
-
displayName: "Border Default",
|
|
457
|
-
description: {
|
|
458
|
-
long: "Border Default er en border-farge som brukes n\xE5r man \xF8nsker god kontrast mot bakgrunnsfargene.",
|
|
459
|
-
short: "Standard border-farge til skjemakomponenter og meningsb\xE6rende elementer."
|
|
460
|
-
},
|
|
461
|
-
luminance: {
|
|
462
|
-
light: 0.19,
|
|
463
|
-
dark: 0.22,
|
|
464
|
-
contrast: 0.4
|
|
465
|
-
}
|
|
466
|
-
},
|
|
467
|
-
"border-strong": {
|
|
468
|
-
number: 9,
|
|
469
|
-
name: "border-strong",
|
|
470
|
-
group: "border",
|
|
471
|
-
displayName: "Border Strong",
|
|
472
|
-
description: {
|
|
473
|
-
long: "Border Strong er den m\xF8rkeste border-fargen og brukes n\xE5r man \xF8nsker en veldig tydelig og sterk border.",
|
|
474
|
-
short: "Border-farge med h\xF8y kontrast for ekstra synlighet."
|
|
475
|
-
},
|
|
476
|
-
luminance: {
|
|
477
|
-
light: 0.11,
|
|
478
|
-
dark: 0.39,
|
|
479
|
-
contrast: 0.6
|
|
480
|
-
}
|
|
481
|
-
},
|
|
482
|
-
"text-subtle": {
|
|
483
|
-
number: 10,
|
|
484
|
-
name: "text-subtle",
|
|
485
|
-
group: "text",
|
|
486
|
-
displayName: "Text Subtle",
|
|
487
|
-
description: {
|
|
488
|
-
long: "Text Subtle er den lyseste tekstfargen og brukes p\xE5 tekst som skal v\xE6re litt mindre synlig eller for \xE5 skape variasjon i typografien.",
|
|
489
|
-
short: "Tekst- og ikonfarge med lavere kontrast."
|
|
490
|
-
},
|
|
491
|
-
luminance: {
|
|
492
|
-
light: 0.11,
|
|
493
|
-
dark: 0.39,
|
|
494
|
-
contrast: 0.57
|
|
495
|
-
}
|
|
496
|
-
},
|
|
497
|
-
"text-default": {
|
|
498
|
-
number: 11,
|
|
499
|
-
name: "text-default",
|
|
500
|
-
group: "text",
|
|
501
|
-
displayName: "Text Default",
|
|
502
|
-
description: {
|
|
503
|
-
long: "Text Default er den m\xF8rkeste tekstfargen og brukes p\xE5 tekst som skal v\xE6re mest synlig. Denne fargen b\xF8r brukes p\xE5 mesteparten av teksten p\xE5 en side.",
|
|
504
|
-
short: "Tekst- og ikonfarge med h\xF8y kontrast og god synlighet."
|
|
505
|
-
},
|
|
506
|
-
luminance: {
|
|
507
|
-
light: 0.0245,
|
|
508
|
-
dark: 0.84,
|
|
509
|
-
contrast: 0.86
|
|
510
|
-
}
|
|
511
|
-
},
|
|
512
|
-
"base-default": {
|
|
513
|
-
number: 12,
|
|
514
|
-
name: "base-default",
|
|
515
|
-
group: "base",
|
|
516
|
-
displayName: "Base Default",
|
|
517
|
-
description: {
|
|
518
|
-
long: "Base Default fargen f\xE5r den samme hex koden som fargen som er valgt i verkt\xF8yet. Brukes ofte som farge p\xE5 viktige elementer og p\xE5 flater som skal fange brukerens oppmerksomhet.",
|
|
519
|
-
short: "Standardfarge for solide bakgrunner."
|
|
520
|
-
},
|
|
521
|
-
luminance: {
|
|
522
|
-
light: 1,
|
|
523
|
-
dark: 1,
|
|
524
|
-
contrast: 1
|
|
525
|
-
}
|
|
526
|
-
},
|
|
527
|
-
"base-hover": {
|
|
528
|
-
number: 13,
|
|
529
|
-
name: "base-hover",
|
|
530
|
-
group: "base",
|
|
531
|
-
displayName: "Base Hover",
|
|
532
|
-
description: {
|
|
533
|
-
long: "Base Hover brukes som hover farge p\xE5 elementer som bruker Base Default fargen.",
|
|
534
|
-
short: "Hover-farge for solide bakgrunner."
|
|
535
|
-
},
|
|
536
|
-
luminance: {
|
|
537
|
-
light: 1,
|
|
538
|
-
dark: 1,
|
|
539
|
-
contrast: 1
|
|
540
|
-
}
|
|
541
|
-
},
|
|
542
|
-
"base-active": {
|
|
543
|
-
number: 14,
|
|
544
|
-
name: "base-active",
|
|
545
|
-
group: "base",
|
|
546
|
-
displayName: "Base Active",
|
|
547
|
-
description: {
|
|
548
|
-
long: "Base Active brukes som active farge p\xE5 elementer som bruker Base Default fargen.",
|
|
549
|
-
short: "Active-farge for solide bakgrunner."
|
|
550
|
-
},
|
|
551
|
-
luminance: {
|
|
552
|
-
light: 1,
|
|
553
|
-
dark: 1,
|
|
554
|
-
contrast: 1
|
|
555
|
-
}
|
|
556
|
-
},
|
|
557
|
-
"base-contrast-subtle": {
|
|
558
|
-
number: 15,
|
|
559
|
-
name: "base-contrast-subtle",
|
|
560
|
-
group: "base",
|
|
561
|
-
displayName: "Contrast Subtle",
|
|
562
|
-
description: {
|
|
563
|
-
long: "Contrast Subtle brukes som en viktig meningsb\xE6rende farge opp\xE5 Base Default fargen.",
|
|
564
|
-
short: "Farge med god kontrast mot Base-default."
|
|
565
|
-
},
|
|
566
|
-
luminance: {
|
|
567
|
-
light: 1,
|
|
568
|
-
dark: 1,
|
|
569
|
-
contrast: 1
|
|
570
|
-
}
|
|
571
|
-
},
|
|
572
|
-
"base-contrast-default": {
|
|
573
|
-
number: 16,
|
|
574
|
-
name: "base-contrast-default",
|
|
575
|
-
group: "base",
|
|
576
|
-
displayName: "Contrast Default",
|
|
577
|
-
description: {
|
|
578
|
-
long: "Contrast Default brukes som en viktig meningsb\xE6rende farge opp\xE5 alle Base fargane.",
|
|
579
|
-
short: "Farge med god kontrast mot Base-default og Base-hover."
|
|
580
|
-
},
|
|
581
|
-
luminance: {
|
|
582
|
-
light: 1,
|
|
583
|
-
dark: 1,
|
|
584
|
-
contrast: 1
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
};
|
|
588
|
-
var colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
|
|
589
|
-
var colorNames = Object.keys(colorMetadata);
|
|
590
|
-
var baseColorNames = Object.keys(baseColors);
|
|
591
|
-
|
|
592
|
-
// src/colors/theme.ts
|
|
593
|
-
import chroma2 from "chroma-js";
|
|
594
|
-
import * as R2 from "ramda";
|
|
595
|
-
|
|
596
|
-
// src/colors/utils.ts
|
|
597
|
-
import chroma from "chroma-js";
|
|
598
|
-
import Colorjs from "colorjs.io";
|
|
599
|
-
import { Hsluv } from "hsluv";
|
|
600
|
-
var getLuminanceFromLightness = (lightness) => {
|
|
601
|
-
const conv = new Hsluv();
|
|
602
|
-
conv.hsluv_l = lightness;
|
|
603
|
-
conv.hsluvToHex();
|
|
604
|
-
return chroma(conv.hex).luminance();
|
|
605
|
-
};
|
|
606
|
-
var getLightnessFromHex = (hex) => {
|
|
607
|
-
const conv = new Hsluv();
|
|
608
|
-
conv.hex = hex;
|
|
609
|
-
conv.hexToHsluv();
|
|
610
|
-
return conv.hsluv_l;
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
// src/colors/theme.ts
|
|
614
|
-
var generateColorScale = (color, colorScheme2) => {
|
|
615
|
-
let interpolationColor = color;
|
|
616
|
-
if (colorScheme2 === "dark") {
|
|
617
|
-
const [L, C, H] = chroma2(color).oklch();
|
|
618
|
-
const chromaModifier = 0.7;
|
|
619
|
-
interpolationColor = chroma2(L, C * chromaModifier, H, "oklch").hex();
|
|
620
|
-
}
|
|
621
|
-
const colors = R2.mapObjIndexed((colorData) => {
|
|
622
|
-
const luminance = colorData.luminance[colorScheme2];
|
|
623
|
-
return {
|
|
624
|
-
...colorData,
|
|
625
|
-
hex: chroma2(interpolationColor).luminance(luminance).hex()
|
|
626
|
-
};
|
|
627
|
-
}, colorMetadata);
|
|
628
|
-
const baseColors2 = generateBaseColors(color, colorScheme2);
|
|
629
|
-
colors["base-default"] = { ...colors["base-default"], hex: baseColors2.default };
|
|
630
|
-
colors["base-hover"] = { ...colors["base-hover"], hex: baseColors2.hover };
|
|
631
|
-
colors["base-active"] = { ...colors["base-active"], hex: baseColors2.active };
|
|
632
|
-
colors["base-contrast-subtle"] = {
|
|
633
|
-
...colors["base-contrast-subtle"],
|
|
634
|
-
hex: generateColorContrast(baseColors2.default, "subtle")
|
|
635
|
-
};
|
|
636
|
-
colors["base-contrast-default"] = {
|
|
637
|
-
...colors["base-contrast-default"],
|
|
638
|
-
hex: generateColorContrast(baseColors2.default, "default")
|
|
639
|
-
};
|
|
640
|
-
return Object.values(colors);
|
|
641
|
-
};
|
|
642
|
-
var generateBaseColors = (color, colorScheme2) => {
|
|
643
|
-
let colorLightness = getLightnessFromHex(color);
|
|
644
|
-
if (colorScheme2 !== "light") {
|
|
645
|
-
colorLightness = colorLightness <= 30 ? 70 : 100 - colorLightness;
|
|
646
|
-
}
|
|
647
|
-
const modifier = colorLightness <= 30 || colorLightness >= 49 && colorLightness <= 65 ? -8 : 8;
|
|
648
|
-
const calculateLightness = (base, mod) => base - mod;
|
|
649
|
-
return {
|
|
650
|
-
default: colorScheme2 === "light" ? color : chroma2(color).luminance(getLuminanceFromLightness(colorLightness)).hex(),
|
|
651
|
-
hover: chroma2(color).luminance(getLuminanceFromLightness(calculateLightness(colorLightness, modifier))).hex(),
|
|
652
|
-
active: chroma2(color).luminance(getLuminanceFromLightness(calculateLightness(colorLightness, modifier * 2))).hex()
|
|
653
|
-
};
|
|
654
|
-
};
|
|
655
|
-
var generateColorContrast = (color, type) => {
|
|
656
|
-
if (type === "default") {
|
|
657
|
-
return chroma2.contrast(color, "#ffffff") >= chroma2.contrast(color, "#000000") ? "#ffffff" : "#000000";
|
|
658
|
-
}
|
|
659
|
-
if (type === "subtle") {
|
|
660
|
-
const contrastWhite = chroma2.contrast(color, "#ffffff");
|
|
661
|
-
const contrastBlack = chroma2.contrast(color, "#000000");
|
|
662
|
-
const lightness = getLightnessFromHex(color);
|
|
663
|
-
const modifier = lightness <= 40 || lightness >= 60 ? 60 : 50;
|
|
664
|
-
const targetLightness = contrastWhite >= contrastBlack ? lightness + modifier : lightness - modifier;
|
|
665
|
-
return chroma2(color).luminance(getLuminanceFromLightness(targetLightness)).hex();
|
|
666
|
-
}
|
|
667
|
-
return color;
|
|
668
|
-
};
|
|
669
|
-
|
|
670
|
-
// src/colors/types.ts
|
|
671
|
-
import * as R3 from "ramda";
|
|
672
|
-
var semanticColorMap = {
|
|
673
|
-
"background-default": 1,
|
|
674
|
-
"background-tinted": 2,
|
|
675
|
-
"surface-default": 3,
|
|
676
|
-
"surface-tinted": 4,
|
|
677
|
-
"surface-hover": 5,
|
|
678
|
-
"surface-active": 6,
|
|
679
|
-
"border-subtle": 7,
|
|
680
|
-
"border-default": 8,
|
|
681
|
-
"border-strong": 9,
|
|
682
|
-
"text-subtle": 10,
|
|
683
|
-
"text-default": 11,
|
|
684
|
-
"base-default": 12,
|
|
685
|
-
"base-hover": 13,
|
|
686
|
-
"base-active": 14,
|
|
687
|
-
"base-contrast-subtle": 15,
|
|
688
|
-
"base-contrast-default": 16
|
|
689
|
-
};
|
|
690
|
-
var semanticColorNames = R3.keys(semanticColorMap);
|
|
691
|
-
var semanticColorNumbers = R3.values(semanticColorMap);
|
|
692
|
-
|
|
693
|
-
// src/tokens/create/generators/primitives/color-scheme.ts
|
|
694
|
-
var generateColor = (colorArray, overrides) => {
|
|
695
|
-
const obj = {};
|
|
696
|
-
const $type = "color";
|
|
697
|
-
for (const index in colorArray) {
|
|
698
|
-
const position = Number(index) + 1;
|
|
699
|
-
const overrideValue = overrides?.[position];
|
|
700
|
-
obj[position] = {
|
|
701
|
-
$type,
|
|
702
|
-
$value: overrideValue || colorArray[index].hex
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
return obj;
|
|
706
|
-
};
|
|
707
|
-
var generateColorScheme = (themeName, colorScheme2, colors, overrides) => {
|
|
708
|
-
const createColorOverrides = (colorName) => {
|
|
709
|
-
if (!overrides?.colors || !(colorName in overrides.colors)) {
|
|
710
|
-
return void 0;
|
|
711
|
-
}
|
|
712
|
-
const colorOverrides = overrides.colors[colorName];
|
|
713
|
-
const positionOverrides = {};
|
|
714
|
-
Object.entries(colorOverrides).forEach(([semanticTokenName, modeOverrides]) => {
|
|
715
|
-
const position = colorMetadata[semanticTokenName].number;
|
|
716
|
-
if (position) {
|
|
717
|
-
let overrideValue;
|
|
718
|
-
if (colorScheme2 === "light" && modeOverrides.light) {
|
|
719
|
-
overrideValue = modeOverrides.light;
|
|
720
|
-
} else if (colorScheme2 === "dark" && modeOverrides.dark) {
|
|
721
|
-
overrideValue = modeOverrides.dark;
|
|
722
|
-
}
|
|
723
|
-
if (overrideValue) {
|
|
724
|
-
positionOverrides[position] = overrideValue;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
});
|
|
728
|
-
return Object.keys(positionOverrides).length > 0 ? positionOverrides : void 0;
|
|
729
|
-
};
|
|
730
|
-
const main = R4.mapObjIndexed(
|
|
731
|
-
(color, colorName) => generateColor(generateColorScale(color, colorScheme2), createColorOverrides(colorName)),
|
|
732
|
-
colors.main
|
|
733
|
-
);
|
|
734
|
-
const support = R4.mapObjIndexed(
|
|
735
|
-
(color, colorName) => generateColor(generateColorScale(color, colorScheme2), createColorOverrides(colorName)),
|
|
736
|
-
colors.support
|
|
737
|
-
);
|
|
738
|
-
const neutralColorScale = generateColorScale(colors.neutral, colorScheme2);
|
|
739
|
-
const neutral = generateColor(neutralColorScale, createColorOverrides("neutral"));
|
|
740
|
-
const baseColorsWithOverrides = {
|
|
741
|
-
...baseColors,
|
|
742
|
-
...overrides?.severity
|
|
743
|
-
};
|
|
744
|
-
const globalColors = R4.mapObjIndexed(
|
|
745
|
-
(color, colorName) => generateColor(generateColorScale(color, colorScheme2), createColorOverrides(colorName)),
|
|
746
|
-
baseColorsWithOverrides
|
|
747
|
-
);
|
|
748
|
-
const linkColor = generateColor(generateColorScale(dsLinkColor, colorScheme2));
|
|
749
|
-
const defaultLinkVisited = linkColor[12];
|
|
750
|
-
const linkOverride = overrides?.linkVisited?.[colorScheme2] ? { $type: "color", $value: overrides.linkVisited[colorScheme2] } : void 0;
|
|
751
|
-
const defaultFocusInner = neutralColorScale[0].hex;
|
|
752
|
-
const defaultFocusOuter = neutralColorScale[10].hex;
|
|
753
|
-
const focusInnerOverride = overrides?.focus?.inner?.[colorScheme2];
|
|
754
|
-
const focusOuterOverride = overrides?.focus?.outer?.[colorScheme2];
|
|
755
|
-
return {
|
|
756
|
-
[themeName]: {
|
|
757
|
-
...main,
|
|
758
|
-
...support,
|
|
759
|
-
neutral,
|
|
760
|
-
...globalColors,
|
|
761
|
-
link: {
|
|
762
|
-
visited: linkOverride || defaultLinkVisited
|
|
763
|
-
},
|
|
764
|
-
focus: {
|
|
765
|
-
inner: {
|
|
766
|
-
$type: "color",
|
|
767
|
-
$value: focusInnerOverride || defaultFocusInner
|
|
768
|
-
},
|
|
769
|
-
outer: {
|
|
770
|
-
$type: "color",
|
|
771
|
-
$value: focusOuterOverride || defaultFocusOuter
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
};
|
|
776
|
-
};
|
|
777
|
-
|
|
778
|
-
// src/tokens/create/generators/primitives/globals.ts
|
|
779
|
-
var globals = {
|
|
780
|
-
"border-width": {
|
|
781
|
-
"1": {
|
|
782
|
-
$type: "borderWidth",
|
|
783
|
-
$value: "1px"
|
|
784
|
-
},
|
|
785
|
-
"3": {
|
|
786
|
-
$type: "borderWidth",
|
|
787
|
-
$value: "3px"
|
|
788
|
-
}
|
|
789
|
-
},
|
|
790
|
-
shadow: {
|
|
791
|
-
"100": {
|
|
792
|
-
$type: "boxShadow",
|
|
793
|
-
$value: [
|
|
794
|
-
{
|
|
795
|
-
color: "rgba(0,0,0,0.16)",
|
|
796
|
-
x: "0",
|
|
797
|
-
y: "0",
|
|
798
|
-
blur: "1",
|
|
799
|
-
spread: "0"
|
|
800
|
-
},
|
|
801
|
-
{
|
|
802
|
-
x: "0",
|
|
803
|
-
y: "1",
|
|
804
|
-
blur: "2",
|
|
805
|
-
spread: "0",
|
|
806
|
-
color: "rgba(0,0,0,0.12)"
|
|
807
|
-
}
|
|
808
|
-
]
|
|
809
|
-
},
|
|
810
|
-
"200": {
|
|
811
|
-
$type: "boxShadow",
|
|
812
|
-
$value: [
|
|
813
|
-
{
|
|
814
|
-
color: "rgba(0,0,0,0.15)",
|
|
815
|
-
x: "0",
|
|
816
|
-
y: "0",
|
|
817
|
-
blur: "1",
|
|
818
|
-
spread: "0"
|
|
819
|
-
},
|
|
820
|
-
{
|
|
821
|
-
color: "rgba(0,0,0,0.12)",
|
|
822
|
-
x: "0",
|
|
823
|
-
y: "1",
|
|
824
|
-
blur: "2",
|
|
825
|
-
spread: "0"
|
|
826
|
-
},
|
|
827
|
-
{
|
|
828
|
-
x: "0",
|
|
829
|
-
y: "2",
|
|
830
|
-
blur: "4",
|
|
831
|
-
spread: "0",
|
|
832
|
-
color: "rgba(0,0,0,0.1)"
|
|
833
|
-
}
|
|
834
|
-
]
|
|
835
|
-
},
|
|
836
|
-
"300": {
|
|
837
|
-
$type: "boxShadow",
|
|
838
|
-
$value: [
|
|
839
|
-
{
|
|
840
|
-
color: "rgba(0,0,0,0.14)",
|
|
841
|
-
x: "0",
|
|
842
|
-
y: "0",
|
|
843
|
-
blur: "1",
|
|
844
|
-
spread: "0"
|
|
845
|
-
},
|
|
846
|
-
{
|
|
847
|
-
color: "rgba(0,0,0,0.12)",
|
|
848
|
-
x: "0",
|
|
849
|
-
y: "2",
|
|
850
|
-
blur: "4",
|
|
851
|
-
spread: "0"
|
|
852
|
-
},
|
|
853
|
-
{
|
|
854
|
-
x: "0",
|
|
855
|
-
y: "4",
|
|
856
|
-
blur: "8",
|
|
857
|
-
spread: "0",
|
|
858
|
-
color: "rgba(0,0,0,0.12)"
|
|
859
|
-
}
|
|
860
|
-
]
|
|
861
|
-
},
|
|
862
|
-
"400": {
|
|
863
|
-
$type: "boxShadow",
|
|
864
|
-
$value: [
|
|
865
|
-
{
|
|
866
|
-
color: "rgba(0,0,0,0.13)",
|
|
867
|
-
x: "0",
|
|
868
|
-
y: "0",
|
|
869
|
-
blur: "1",
|
|
870
|
-
spread: "0"
|
|
871
|
-
},
|
|
872
|
-
{
|
|
873
|
-
color: "rgba(0,0,0,0.13)",
|
|
874
|
-
x: "0",
|
|
875
|
-
y: "3",
|
|
876
|
-
blur: "5",
|
|
877
|
-
spread: "0"
|
|
878
|
-
},
|
|
879
|
-
{
|
|
880
|
-
x: "0",
|
|
881
|
-
y: "6",
|
|
882
|
-
blur: "12",
|
|
883
|
-
spread: "0",
|
|
884
|
-
color: "rgba(0,0,0,0.14)"
|
|
885
|
-
}
|
|
886
|
-
]
|
|
887
|
-
},
|
|
888
|
-
"500": {
|
|
889
|
-
$type: "boxShadow",
|
|
890
|
-
$value: [
|
|
891
|
-
{
|
|
892
|
-
color: "rgba(0,0,0,0.12)",
|
|
893
|
-
x: "0",
|
|
894
|
-
y: "0",
|
|
895
|
-
blur: "1",
|
|
896
|
-
spread: "0"
|
|
897
|
-
},
|
|
898
|
-
{
|
|
899
|
-
color: "rgba(0,0,0,0.16)",
|
|
900
|
-
x: "0",
|
|
901
|
-
y: "4",
|
|
902
|
-
blur: "8",
|
|
903
|
-
spread: "0"
|
|
904
|
-
},
|
|
905
|
-
{
|
|
906
|
-
x: "0",
|
|
907
|
-
y: "12",
|
|
908
|
-
blur: "24",
|
|
909
|
-
spread: "0",
|
|
910
|
-
color: "rgba(0,0,0,0.16)"
|
|
911
|
-
}
|
|
912
|
-
]
|
|
913
|
-
}
|
|
914
|
-
},
|
|
915
|
-
opacity: {
|
|
916
|
-
"30": {
|
|
917
|
-
$type: "opacity",
|
|
918
|
-
$value: "30%"
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
};
|
|
922
|
-
var generateGlobals = () => globals;
|
|
923
|
-
|
|
924
|
-
// src/tokens/create/generators/primitives/size.ts
|
|
925
|
-
var global = {
|
|
926
|
-
_size: {
|
|
927
|
-
"0": {
|
|
928
|
-
$type: "dimension",
|
|
929
|
-
$value: "floor({_size.unit} * 0)"
|
|
930
|
-
},
|
|
931
|
-
"1": {
|
|
932
|
-
$type: "dimension",
|
|
933
|
-
$value: "floor({_size.unit} * 1)"
|
|
934
|
-
},
|
|
935
|
-
"2": {
|
|
936
|
-
$type: "dimension",
|
|
937
|
-
$value: "floor({_size.unit} * 2)"
|
|
938
|
-
},
|
|
939
|
-
"3": {
|
|
940
|
-
$type: "dimension",
|
|
941
|
-
$value: "floor({_size.unit} * 3)"
|
|
942
|
-
},
|
|
943
|
-
"4": {
|
|
944
|
-
$type: "dimension",
|
|
945
|
-
$value: "floor({_size.unit} * 4)"
|
|
946
|
-
},
|
|
947
|
-
"5": {
|
|
948
|
-
$type: "dimension",
|
|
949
|
-
$value: "floor({_size.unit} * 5)"
|
|
950
|
-
},
|
|
951
|
-
"6": {
|
|
952
|
-
$type: "dimension",
|
|
953
|
-
$value: "floor({_size.unit} * 6)"
|
|
954
|
-
},
|
|
955
|
-
"7": {
|
|
956
|
-
$type: "dimension",
|
|
957
|
-
$value: "floor({_size.unit} * 7)"
|
|
958
|
-
},
|
|
959
|
-
"8": {
|
|
960
|
-
$type: "dimension",
|
|
961
|
-
$value: "floor({_size.unit} * 8)"
|
|
962
|
-
},
|
|
963
|
-
"9": {
|
|
964
|
-
$type: "dimension",
|
|
965
|
-
$value: "floor({_size.unit} * 9)"
|
|
966
|
-
},
|
|
967
|
-
"10": {
|
|
968
|
-
$type: "dimension",
|
|
969
|
-
$value: "floor({_size.unit} * 10)"
|
|
970
|
-
},
|
|
971
|
-
"11": {
|
|
972
|
-
$type: "dimension",
|
|
973
|
-
$value: "floor({_size.unit} * 11)"
|
|
974
|
-
},
|
|
975
|
-
"12": {
|
|
976
|
-
$type: "dimension",
|
|
977
|
-
$value: "floor({_size.unit} * 12)"
|
|
978
|
-
},
|
|
979
|
-
"13": {
|
|
980
|
-
$type: "dimension",
|
|
981
|
-
$value: "floor({_size.unit} * 13)"
|
|
982
|
-
},
|
|
983
|
-
"14": {
|
|
984
|
-
$type: "dimension",
|
|
985
|
-
$value: "floor({_size.unit} * 14)"
|
|
986
|
-
},
|
|
987
|
-
"15": {
|
|
988
|
-
$type: "dimension",
|
|
989
|
-
$value: "floor({_size.unit} * 15)"
|
|
990
|
-
},
|
|
991
|
-
"18": {
|
|
992
|
-
$type: "dimension",
|
|
993
|
-
$value: "floor({_size.unit} * 18)"
|
|
994
|
-
},
|
|
995
|
-
"22": {
|
|
996
|
-
$type: "dimension",
|
|
997
|
-
$value: "floor({_size.unit} * 22)"
|
|
998
|
-
},
|
|
999
|
-
"26": {
|
|
1000
|
-
$type: "dimension",
|
|
1001
|
-
$value: "floor({_size.unit} * 26)"
|
|
1002
|
-
},
|
|
1003
|
-
"30": {
|
|
1004
|
-
$type: "dimension",
|
|
1005
|
-
$value: "floor({_size.unit} * 30)"
|
|
1006
|
-
},
|
|
1007
|
-
"mode-font-size": {
|
|
1008
|
-
$type: "number",
|
|
1009
|
-
$value: "{size._mode-font-size}"
|
|
1010
|
-
},
|
|
1011
|
-
base: {
|
|
1012
|
-
$type: "number",
|
|
1013
|
-
$value: "{size._base}"
|
|
1014
|
-
},
|
|
1015
|
-
step: {
|
|
1016
|
-
$type: "number",
|
|
1017
|
-
$value: "{size._step}"
|
|
1018
|
-
},
|
|
1019
|
-
unit: {
|
|
1020
|
-
$type: "number",
|
|
1021
|
-
$value: "{_size.step} / {_size.base} * {_size.mode-font-size}"
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
};
|
|
1025
|
-
var sizeModes = {
|
|
1026
|
-
large: {
|
|
1027
|
-
size: {
|
|
1028
|
-
"_mode-font-size": {
|
|
1029
|
-
$type: "dimension",
|
|
1030
|
-
$value: "21"
|
|
1031
|
-
},
|
|
1032
|
-
_base: {
|
|
1033
|
-
$type: "dimension",
|
|
1034
|
-
$value: "18"
|
|
1035
|
-
},
|
|
1036
|
-
_step: {
|
|
1037
|
-
$type: "dimension",
|
|
1038
|
-
$value: "4"
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
},
|
|
1042
|
-
medium: {
|
|
1043
|
-
size: {
|
|
1044
|
-
"_mode-font-size": {
|
|
1045
|
-
$type: "dimension",
|
|
1046
|
-
$value: "18"
|
|
1047
|
-
},
|
|
1048
|
-
_base: {
|
|
1049
|
-
$type: "dimension",
|
|
1050
|
-
$value: "18"
|
|
1051
|
-
},
|
|
1052
|
-
_step: {
|
|
1053
|
-
$type: "dimension",
|
|
1054
|
-
$value: "4"
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
},
|
|
1058
|
-
small: {
|
|
1059
|
-
size: {
|
|
1060
|
-
"_mode-font-size": {
|
|
1061
|
-
$type: "dimension",
|
|
1062
|
-
$value: "16"
|
|
1063
|
-
},
|
|
1064
|
-
_base: {
|
|
1065
|
-
$type: "dimension",
|
|
1066
|
-
$value: "18"
|
|
1067
|
-
},
|
|
1068
|
-
_step: {
|
|
1069
|
-
$type: "dimension",
|
|
1070
|
-
$value: "4"
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
};
|
|
1075
|
-
var generateSize = (size2) => sizeModes[size2];
|
|
1076
|
-
var generateSizeGlobal = () => global;
|
|
1077
|
-
|
|
1078
|
-
// src/tokens/create/generators/primitives/typography.ts
|
|
1079
|
-
var generateTypography = (themeName, { fontFamily }) => ({
|
|
1080
|
-
[themeName]: {
|
|
1081
|
-
"font-family": {
|
|
1082
|
-
$type: "fontFamilies",
|
|
1083
|
-
$value: fontFamily
|
|
1084
|
-
},
|
|
1085
|
-
"font-weight": {
|
|
1086
|
-
medium: {
|
|
1087
|
-
$type: "fontWeights",
|
|
1088
|
-
$value: "Medium"
|
|
1089
|
-
},
|
|
1090
|
-
semibold: {
|
|
1091
|
-
$type: "fontWeights",
|
|
1092
|
-
$value: "Semi bold"
|
|
1093
|
-
},
|
|
1094
|
-
regular: {
|
|
1095
|
-
$type: "fontWeights",
|
|
1096
|
-
$value: "Regular"
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
});
|
|
1101
|
-
var generateFontSizes = (size2) => fontSizes[size2];
|
|
1102
|
-
var lineHeights = {
|
|
1103
|
-
sm: {
|
|
1104
|
-
$type: "lineHeights",
|
|
1105
|
-
$value: "130%"
|
|
1106
|
-
},
|
|
1107
|
-
md: {
|
|
1108
|
-
$type: "lineHeights",
|
|
1109
|
-
$value: "150%"
|
|
1110
|
-
},
|
|
1111
|
-
lg: {
|
|
1112
|
-
$type: "lineHeights",
|
|
1113
|
-
$value: "170%"
|
|
1114
|
-
}
|
|
1115
|
-
};
|
|
1116
|
-
var letterSpacings = {
|
|
1117
|
-
"1": {
|
|
1118
|
-
$type: "letterSpacing",
|
|
1119
|
-
$value: "-1%"
|
|
1120
|
-
},
|
|
1121
|
-
"2": {
|
|
1122
|
-
$type: "letterSpacing",
|
|
1123
|
-
$value: "-0.5%"
|
|
1124
|
-
},
|
|
1125
|
-
"3": {
|
|
1126
|
-
$type: "letterSpacing",
|
|
1127
|
-
$value: "-0.25%"
|
|
1128
|
-
},
|
|
1129
|
-
"4": {
|
|
1130
|
-
$type: "letterSpacing",
|
|
1131
|
-
$value: "-0.15%"
|
|
1132
|
-
},
|
|
1133
|
-
"5": {
|
|
1134
|
-
$type: "letterSpacing",
|
|
1135
|
-
$value: "0%"
|
|
1136
|
-
},
|
|
1137
|
-
"6": {
|
|
1138
|
-
$type: "letterSpacing",
|
|
1139
|
-
$value: "0.15%"
|
|
1140
|
-
},
|
|
1141
|
-
"7": {
|
|
1142
|
-
$type: "letterSpacing",
|
|
1143
|
-
$value: "0.25%"
|
|
1144
|
-
},
|
|
1145
|
-
"8": {
|
|
1146
|
-
$type: "letterSpacing",
|
|
1147
|
-
$value: "0.5%"
|
|
1148
|
-
},
|
|
1149
|
-
"9": {
|
|
1150
|
-
$type: "letterSpacing",
|
|
1151
|
-
$value: "1.5%"
|
|
1152
|
-
}
|
|
1153
|
-
};
|
|
1154
|
-
var fontSizes = {
|
|
1155
|
-
large: {
|
|
1156
|
-
"line-height": lineHeights,
|
|
1157
|
-
"font-size": {
|
|
1158
|
-
"1": {
|
|
1159
|
-
$type: "fontSizes",
|
|
1160
|
-
$value: "13"
|
|
1161
|
-
},
|
|
1162
|
-
"2": {
|
|
1163
|
-
$type: "fontSizes",
|
|
1164
|
-
$value: "16"
|
|
1165
|
-
},
|
|
1166
|
-
"3": {
|
|
1167
|
-
$type: "fontSizes",
|
|
1168
|
-
$value: "18"
|
|
1169
|
-
},
|
|
1170
|
-
"4": {
|
|
1171
|
-
$type: "fontSizes",
|
|
1172
|
-
$value: "21"
|
|
1173
|
-
},
|
|
1174
|
-
"5": {
|
|
1175
|
-
$type: "fontSizes",
|
|
1176
|
-
$value: "24"
|
|
1177
|
-
},
|
|
1178
|
-
"6": {
|
|
1179
|
-
$type: "fontSizes",
|
|
1180
|
-
$value: "30"
|
|
1181
|
-
},
|
|
1182
|
-
"7": {
|
|
1183
|
-
$type: "fontSizes",
|
|
1184
|
-
$value: "36"
|
|
1185
|
-
},
|
|
1186
|
-
"8": {
|
|
1187
|
-
$type: "fontSizes",
|
|
1188
|
-
$value: "48"
|
|
1189
|
-
},
|
|
1190
|
-
"9": {
|
|
1191
|
-
$type: "fontSizes",
|
|
1192
|
-
$value: "60"
|
|
1193
|
-
},
|
|
1194
|
-
"10": {
|
|
1195
|
-
$type: "fontSizes",
|
|
1196
|
-
$value: "72"
|
|
1197
|
-
}
|
|
1198
|
-
},
|
|
1199
|
-
"letter-spacing": letterSpacings
|
|
1200
|
-
},
|
|
1201
|
-
medium: {
|
|
1202
|
-
"line-height": lineHeights,
|
|
1203
|
-
"font-size": {
|
|
1204
|
-
"1": {
|
|
1205
|
-
$type: "fontSizes",
|
|
1206
|
-
$value: "12"
|
|
1207
|
-
},
|
|
1208
|
-
"2": {
|
|
1209
|
-
$type: "fontSizes",
|
|
1210
|
-
$value: "14"
|
|
1211
|
-
},
|
|
1212
|
-
"3": {
|
|
1213
|
-
$type: "fontSizes",
|
|
1214
|
-
$value: "16"
|
|
1215
|
-
},
|
|
1216
|
-
"4": {
|
|
1217
|
-
$type: "fontSizes",
|
|
1218
|
-
$value: "18"
|
|
1219
|
-
},
|
|
1220
|
-
"5": {
|
|
1221
|
-
$type: "fontSizes",
|
|
1222
|
-
$value: "21"
|
|
1223
|
-
},
|
|
1224
|
-
"6": {
|
|
1225
|
-
$type: "fontSizes",
|
|
1226
|
-
$value: "24"
|
|
1227
|
-
},
|
|
1228
|
-
"7": {
|
|
1229
|
-
$type: "fontSizes",
|
|
1230
|
-
$value: "30"
|
|
1231
|
-
},
|
|
1232
|
-
"8": {
|
|
1233
|
-
$type: "fontSizes",
|
|
1234
|
-
$value: "36"
|
|
1235
|
-
},
|
|
1236
|
-
"9": {
|
|
1237
|
-
$type: "fontSizes",
|
|
1238
|
-
$value: "48"
|
|
1239
|
-
},
|
|
1240
|
-
"10": {
|
|
1241
|
-
$type: "fontSizes",
|
|
1242
|
-
$value: "60"
|
|
1243
|
-
}
|
|
1244
|
-
},
|
|
1245
|
-
"letter-spacing": letterSpacings
|
|
1246
|
-
},
|
|
1247
|
-
small: {
|
|
1248
|
-
"line-height": lineHeights,
|
|
1249
|
-
"font-size": {
|
|
1250
|
-
"1": {
|
|
1251
|
-
$type: "fontSizes",
|
|
1252
|
-
$value: "11"
|
|
1253
|
-
},
|
|
1254
|
-
"2": {
|
|
1255
|
-
$type: "fontSizes",
|
|
1256
|
-
$value: "13"
|
|
1257
|
-
},
|
|
1258
|
-
"3": {
|
|
1259
|
-
$type: "fontSizes",
|
|
1260
|
-
$value: "14"
|
|
1261
|
-
},
|
|
1262
|
-
"4": {
|
|
1263
|
-
$type: "fontSizes",
|
|
1264
|
-
$value: "16"
|
|
1265
|
-
},
|
|
1266
|
-
"5": {
|
|
1267
|
-
$type: "fontSizes",
|
|
1268
|
-
$value: "18"
|
|
1269
|
-
},
|
|
1270
|
-
"6": {
|
|
1271
|
-
$type: "fontSizes",
|
|
1272
|
-
$value: "21"
|
|
1273
|
-
},
|
|
1274
|
-
"7": {
|
|
1275
|
-
$type: "fontSizes",
|
|
1276
|
-
$value: "24"
|
|
1277
|
-
},
|
|
1278
|
-
"8": {
|
|
1279
|
-
$type: "fontSizes",
|
|
1280
|
-
$value: "30"
|
|
1281
|
-
},
|
|
1282
|
-
"9": {
|
|
1283
|
-
$type: "fontSizes",
|
|
1284
|
-
$value: "36"
|
|
1285
|
-
},
|
|
1286
|
-
"10": {
|
|
1287
|
-
$type: "fontSizes",
|
|
1288
|
-
$value: "48"
|
|
1289
|
-
}
|
|
1290
|
-
},
|
|
1291
|
-
"letter-spacing": letterSpacings
|
|
1292
|
-
}
|
|
1293
|
-
};
|
|
1294
|
-
|
|
1295
|
-
// src/tokens/create/generators/semantic/color.ts
|
|
1296
|
-
import * as R5 from "ramda";
|
|
1297
|
-
var generateSemanticColors = (colors, _themeName) => {
|
|
1298
|
-
const mainColorNames = Object.keys(colors.main);
|
|
1299
|
-
const supportColorNames = Object.keys(colors.support);
|
|
1300
|
-
const customColors = [...mainColorNames, "neutral", ...supportColorNames];
|
|
1301
|
-
const allColors = [...customColors, ...baseColorNames];
|
|
1302
|
-
const semanticColorTokens = allColors.map((colorName) => [colorName, generateColorScaleTokens(colorName)]);
|
|
1303
|
-
return {
|
|
1304
|
-
...baseColorTemplate,
|
|
1305
|
-
color: {
|
|
1306
|
-
...Object.fromEntries(semanticColorTokens),
|
|
1307
|
-
...baseColorTemplate.color
|
|
1308
|
-
}
|
|
1309
|
-
};
|
|
1310
|
-
};
|
|
1311
|
-
var baseColorTemplate = {
|
|
1312
|
-
color: {
|
|
1313
|
-
focus: {
|
|
1314
|
-
inner: {
|
|
1315
|
-
$type: "color",
|
|
1316
|
-
$value: "{color.focus.inner-color}"
|
|
1317
|
-
},
|
|
1318
|
-
outer: {
|
|
1319
|
-
$type: "color",
|
|
1320
|
-
$value: "{color.focus.outer-color}"
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
},
|
|
1324
|
-
link: {
|
|
1325
|
-
color: {
|
|
1326
|
-
visited: {
|
|
1327
|
-
$type: "color",
|
|
1328
|
-
$value: "{color.link.visited}"
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
};
|
|
1333
|
-
var generateColorScaleTokens = (colorName) => {
|
|
1334
|
-
const colorScale = {};
|
|
1335
|
-
for (const [colorSemantic, colorNumber] of R5.toPairs(semanticColorMap)) {
|
|
1336
|
-
colorScale[colorSemantic] = {
|
|
1337
|
-
$type: "color",
|
|
1338
|
-
$value: `{color.${colorName}.${colorNumber}}`
|
|
1339
|
-
};
|
|
1340
|
-
}
|
|
1341
|
-
return colorScale;
|
|
1342
|
-
};
|
|
1343
|
-
|
|
1344
|
-
// src/tokens/create/generators/semantic/color-modes.ts
|
|
1345
|
-
var generateColorModes = (colors, _themeName) => {
|
|
1346
|
-
const mainColorNames = Object.keys(colors.main);
|
|
1347
|
-
const supportColorNames = Object.keys(colors.support);
|
|
1348
|
-
const modes = {
|
|
1349
|
-
"main-color": {},
|
|
1350
|
-
"support-color": {}
|
|
1351
|
-
};
|
|
1352
|
-
const categories = [
|
|
1353
|
-
["main-color", mainColorNames],
|
|
1354
|
-
["support-color", supportColorNames]
|
|
1355
|
-
];
|
|
1356
|
-
for (const [colorCategory2, colorNames2] of categories) {
|
|
1357
|
-
for (const colorName of colorNames2) {
|
|
1358
|
-
const category = colorCategory2.replace("-color", "");
|
|
1359
|
-
const customColorTokens = {
|
|
1360
|
-
color: {
|
|
1361
|
-
[category]: generateColorScaleTokens2(colorName)
|
|
1362
|
-
}
|
|
1363
|
-
};
|
|
1364
|
-
modes[colorCategory2][colorName] = customColorTokens;
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
return modes;
|
|
1368
|
-
};
|
|
1369
|
-
var generateColorScaleTokens2 = (colorName) => {
|
|
1370
|
-
const colorScale = {};
|
|
1371
|
-
for (const colorSemantic of semanticColorNames) {
|
|
1372
|
-
colorScale[colorSemantic] = {
|
|
1373
|
-
$type: "color",
|
|
1374
|
-
$value: `{color.${colorName}.${colorSemantic}}`
|
|
1375
|
-
};
|
|
1376
|
-
}
|
|
1377
|
-
return colorScale;
|
|
1378
|
-
};
|
|
1379
|
-
|
|
1380
|
-
// src/tokens/create/generators/semantic/style.ts
|
|
1381
|
-
function generateSemanticStyle() {
|
|
1382
|
-
return {
|
|
1383
|
-
typography: {
|
|
1384
|
-
heading: {
|
|
1385
|
-
"2xl": {
|
|
1386
|
-
$type: "typography",
|
|
1387
|
-
$value: {
|
|
1388
|
-
fontFamily: "{font-family}",
|
|
1389
|
-
fontWeight: "{font-weight.medium}",
|
|
1390
|
-
lineHeight: "{line-height.sm}",
|
|
1391
|
-
fontSize: "{font-size.10}",
|
|
1392
|
-
letterSpacing: "{letter-spacing.1}"
|
|
1393
|
-
}
|
|
1394
|
-
},
|
|
1395
|
-
xl: {
|
|
1396
|
-
$type: "typography",
|
|
1397
|
-
$value: {
|
|
1398
|
-
fontFamily: "{font-family}",
|
|
1399
|
-
fontWeight: "{font-weight.medium}",
|
|
1400
|
-
lineHeight: "{line-height.sm}",
|
|
1401
|
-
fontSize: "{font-size.9}",
|
|
1402
|
-
letterSpacing: "{letter-spacing.1}"
|
|
1403
|
-
}
|
|
1404
|
-
},
|
|
1405
|
-
lg: {
|
|
1406
|
-
$type: "typography",
|
|
1407
|
-
$value: {
|
|
1408
|
-
fontFamily: "{font-family}",
|
|
1409
|
-
fontWeight: "{font-weight.medium}",
|
|
1410
|
-
lineHeight: "{line-height.sm}",
|
|
1411
|
-
fontSize: "{font-size.8}",
|
|
1412
|
-
letterSpacing: "{letter-spacing.2}"
|
|
1413
|
-
}
|
|
1414
|
-
},
|
|
1415
|
-
md: {
|
|
1416
|
-
$type: "typography",
|
|
1417
|
-
$value: {
|
|
1418
|
-
fontFamily: "{font-family}",
|
|
1419
|
-
fontWeight: "{font-weight.medium}",
|
|
1420
|
-
lineHeight: "{line-height.sm}",
|
|
1421
|
-
fontSize: "{font-size.7}",
|
|
1422
|
-
letterSpacing: "{letter-spacing.3}"
|
|
1423
|
-
}
|
|
1424
|
-
},
|
|
1425
|
-
sm: {
|
|
1426
|
-
$type: "typography",
|
|
1427
|
-
$value: {
|
|
1428
|
-
fontFamily: "{font-family}",
|
|
1429
|
-
fontWeight: "{font-weight.medium}",
|
|
1430
|
-
lineHeight: "{line-height.sm}",
|
|
1431
|
-
fontSize: "{font-size.6}",
|
|
1432
|
-
letterSpacing: "{letter-spacing.5}"
|
|
1433
|
-
}
|
|
1434
|
-
},
|
|
1435
|
-
xs: {
|
|
1436
|
-
$type: "typography",
|
|
1437
|
-
$value: {
|
|
1438
|
-
fontFamily: "{font-family}",
|
|
1439
|
-
fontWeight: "{font-weight.medium}",
|
|
1440
|
-
lineHeight: "{line-height.sm}",
|
|
1441
|
-
fontSize: "{font-size.5}",
|
|
1442
|
-
letterSpacing: "{letter-spacing.6}"
|
|
1443
|
-
}
|
|
1444
|
-
},
|
|
1445
|
-
"2xs": {
|
|
1446
|
-
$type: "typography",
|
|
1447
|
-
$value: {
|
|
1448
|
-
fontFamily: "{font-family}",
|
|
1449
|
-
fontWeight: "{font-weight.medium}",
|
|
1450
|
-
lineHeight: "{line-height.sm}",
|
|
1451
|
-
fontSize: "{font-size.4}",
|
|
1452
|
-
letterSpacing: "{letter-spacing.6}"
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
},
|
|
1456
|
-
body: {
|
|
1457
|
-
xl: {
|
|
1458
|
-
$type: "typography",
|
|
1459
|
-
$value: {
|
|
1460
|
-
fontFamily: "{font-family}",
|
|
1461
|
-
fontWeight: "{font-weight.regular}",
|
|
1462
|
-
lineHeight: "{line-height.md}",
|
|
1463
|
-
fontSize: "{font-size.6}",
|
|
1464
|
-
letterSpacing: "{letter-spacing.8}"
|
|
1465
|
-
}
|
|
1466
|
-
},
|
|
1467
|
-
lg: {
|
|
1468
|
-
$type: "typography",
|
|
1469
|
-
$value: {
|
|
1470
|
-
fontFamily: "{font-family}",
|
|
1471
|
-
fontWeight: "{font-weight.regular}",
|
|
1472
|
-
lineHeight: "{line-height.md}",
|
|
1473
|
-
fontSize: "{font-size.5}",
|
|
1474
|
-
letterSpacing: "{letter-spacing.8}"
|
|
1475
|
-
}
|
|
1476
|
-
},
|
|
1477
|
-
md: {
|
|
1478
|
-
$type: "typography",
|
|
1479
|
-
$value: {
|
|
1480
|
-
fontFamily: "{font-family}",
|
|
1481
|
-
fontWeight: "{font-weight.regular}",
|
|
1482
|
-
lineHeight: "{line-height.md}",
|
|
1483
|
-
fontSize: "{font-size.4}",
|
|
1484
|
-
letterSpacing: "{letter-spacing.8}"
|
|
1485
|
-
}
|
|
1486
|
-
},
|
|
1487
|
-
sm: {
|
|
1488
|
-
$type: "typography",
|
|
1489
|
-
$value: {
|
|
1490
|
-
fontFamily: "{font-family}",
|
|
1491
|
-
fontWeight: "{font-weight.regular}",
|
|
1492
|
-
lineHeight: "{line-height.md}",
|
|
1493
|
-
fontSize: "{font-size.3}",
|
|
1494
|
-
letterSpacing: "{letter-spacing.7}"
|
|
1495
|
-
}
|
|
1496
|
-
},
|
|
1497
|
-
xs: {
|
|
1498
|
-
$type: "typography",
|
|
1499
|
-
$value: {
|
|
1500
|
-
fontFamily: "{font-family}",
|
|
1501
|
-
fontWeight: "{font-weight.regular}",
|
|
1502
|
-
lineHeight: "{line-height.md}",
|
|
1503
|
-
fontSize: "{font-size.2}",
|
|
1504
|
-
letterSpacing: "{letter-spacing.6}"
|
|
1505
|
-
}
|
|
1506
|
-
},
|
|
1507
|
-
short: {
|
|
1508
|
-
xl: {
|
|
1509
|
-
$type: "typography",
|
|
1510
|
-
$value: {
|
|
1511
|
-
fontFamily: "{font-family}",
|
|
1512
|
-
fontWeight: "{font-weight.regular}",
|
|
1513
|
-
lineHeight: "{line-height.sm}",
|
|
1514
|
-
fontSize: "{font-size.6}",
|
|
1515
|
-
letterSpacing: "{letter-spacing.8}"
|
|
1516
|
-
}
|
|
1517
|
-
},
|
|
1518
|
-
lg: {
|
|
1519
|
-
$type: "typography",
|
|
1520
|
-
$value: {
|
|
1521
|
-
fontFamily: "{font-family}",
|
|
1522
|
-
fontWeight: "{font-weight.regular}",
|
|
1523
|
-
lineHeight: "{line-height.sm}",
|
|
1524
|
-
fontSize: "{font-size.5}",
|
|
1525
|
-
letterSpacing: "{letter-spacing.8}"
|
|
1526
|
-
}
|
|
1527
|
-
},
|
|
1528
|
-
md: {
|
|
1529
|
-
$type: "typography",
|
|
1530
|
-
$value: {
|
|
1531
|
-
fontFamily: "{font-family}",
|
|
1532
|
-
fontWeight: "{font-weight.regular}",
|
|
1533
|
-
lineHeight: "{line-height.sm}",
|
|
1534
|
-
fontSize: "{font-size.4}",
|
|
1535
|
-
letterSpacing: "{letter-spacing.8}"
|
|
1536
|
-
}
|
|
1537
|
-
},
|
|
1538
|
-
sm: {
|
|
1539
|
-
$type: "typography",
|
|
1540
|
-
$value: {
|
|
1541
|
-
fontFamily: "{font-family}",
|
|
1542
|
-
fontWeight: "{font-weight.regular}",
|
|
1543
|
-
lineHeight: "{line-height.sm}",
|
|
1544
|
-
fontSize: "{font-size.3}",
|
|
1545
|
-
letterSpacing: "{letter-spacing.7}"
|
|
1546
|
-
}
|
|
1547
|
-
},
|
|
1548
|
-
xs: {
|
|
1549
|
-
$type: "typography",
|
|
1550
|
-
$value: {
|
|
1551
|
-
fontFamily: "{font-family}",
|
|
1552
|
-
fontWeight: "{font-weight.regular}",
|
|
1553
|
-
lineHeight: "{line-height.sm}",
|
|
1554
|
-
fontSize: "{font-size.2}",
|
|
1555
|
-
letterSpacing: "{letter-spacing.6}"
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
},
|
|
1559
|
-
long: {
|
|
1560
|
-
xl: {
|
|
1561
|
-
$type: "typography",
|
|
1562
|
-
$value: {
|
|
1563
|
-
fontFamily: "{font-family}",
|
|
1564
|
-
fontWeight: "{font-weight.regular}",
|
|
1565
|
-
lineHeight: "{line-height.lg}",
|
|
1566
|
-
fontSize: "{font-size.6}",
|
|
1567
|
-
letterSpacing: "{letter-spacing.8}"
|
|
1568
|
-
}
|
|
1569
|
-
},
|
|
1570
|
-
lg: {
|
|
1571
|
-
$type: "typography",
|
|
1572
|
-
$value: {
|
|
1573
|
-
fontFamily: "{font-family}",
|
|
1574
|
-
fontWeight: "{font-weight.regular}",
|
|
1575
|
-
lineHeight: "{line-height.lg}",
|
|
1576
|
-
fontSize: "{font-size.5}",
|
|
1577
|
-
letterSpacing: "{letter-spacing.8}"
|
|
1578
|
-
}
|
|
1579
|
-
},
|
|
1580
|
-
md: {
|
|
1581
|
-
$type: "typography",
|
|
1582
|
-
$value: {
|
|
1583
|
-
fontFamily: "{font-family}",
|
|
1584
|
-
fontWeight: "{font-weight.regular}",
|
|
1585
|
-
lineHeight: "{line-height.lg}",
|
|
1586
|
-
fontSize: "{font-size.4}",
|
|
1587
|
-
letterSpacing: "{letter-spacing.8}"
|
|
1588
|
-
}
|
|
1589
|
-
},
|
|
1590
|
-
sm: {
|
|
1591
|
-
$type: "typography",
|
|
1592
|
-
$value: {
|
|
1593
|
-
fontFamily: "{font-family}",
|
|
1594
|
-
fontWeight: "{font-weight.regular}",
|
|
1595
|
-
lineHeight: "{line-height.lg}",
|
|
1596
|
-
fontSize: "{font-size.3}",
|
|
1597
|
-
letterSpacing: "{letter-spacing.7}"
|
|
1598
|
-
}
|
|
1599
|
-
},
|
|
1600
|
-
xs: {
|
|
1601
|
-
$type: "typography",
|
|
1602
|
-
$value: {
|
|
1603
|
-
fontFamily: "{font-family}",
|
|
1604
|
-
fontWeight: "{font-weight.regular}",
|
|
1605
|
-
lineHeight: "{line-height.lg}",
|
|
1606
|
-
fontSize: "{font-size.2}",
|
|
1607
|
-
letterSpacing: "{letter-spacing.6}"
|
|
1608
|
-
}
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
},
|
|
1613
|
-
opacity: {
|
|
1614
|
-
disabled: {
|
|
1615
|
-
$type: "opacity",
|
|
1616
|
-
$value: "{opacity.30}"
|
|
1617
|
-
}
|
|
1618
|
-
},
|
|
1619
|
-
"border-width": {
|
|
1620
|
-
default: {
|
|
1621
|
-
$type: "borderWidth",
|
|
1622
|
-
$value: "{border-width.1}"
|
|
1623
|
-
},
|
|
1624
|
-
focus: {
|
|
1625
|
-
$type: "borderWidth",
|
|
1626
|
-
$value: "{border-width.3}"
|
|
1627
|
-
}
|
|
1628
|
-
},
|
|
1629
|
-
shadow: {
|
|
1630
|
-
xs: {
|
|
1631
|
-
$type: "boxShadow",
|
|
1632
|
-
$value: "{shadow.100}"
|
|
1633
|
-
},
|
|
1634
|
-
sm: {
|
|
1635
|
-
$type: "boxShadow",
|
|
1636
|
-
$value: "{shadow.200}"
|
|
1637
|
-
},
|
|
1638
|
-
md: {
|
|
1639
|
-
$type: "boxShadow",
|
|
1640
|
-
$value: "{shadow.300}"
|
|
1641
|
-
},
|
|
1642
|
-
lg: {
|
|
1643
|
-
$type: "boxShadow",
|
|
1644
|
-
$value: "{shadow.400}"
|
|
1645
|
-
},
|
|
1646
|
-
xl: {
|
|
1647
|
-
$type: "boxShadow",
|
|
1648
|
-
$value: "{shadow.500}"
|
|
1649
|
-
}
|
|
1650
|
-
},
|
|
1651
|
-
"border-radius": {
|
|
1652
|
-
sm: {
|
|
1653
|
-
$type: "dimension",
|
|
1654
|
-
$value: "{border-radius.1}"
|
|
1655
|
-
},
|
|
1656
|
-
md: {
|
|
1657
|
-
$type: "dimension",
|
|
1658
|
-
$value: "{border-radius.2}"
|
|
1659
|
-
},
|
|
1660
|
-
lg: {
|
|
1661
|
-
$type: "dimension",
|
|
1662
|
-
$value: "{border-radius.3}"
|
|
1663
|
-
},
|
|
1664
|
-
xl: {
|
|
1665
|
-
$type: "dimension",
|
|
1666
|
-
$value: "{border-radius.4}"
|
|
1667
|
-
},
|
|
1668
|
-
default: {
|
|
1669
|
-
$type: "dimension",
|
|
1670
|
-
$value: "{border-radius.5}"
|
|
1671
|
-
},
|
|
1672
|
-
full: {
|
|
1673
|
-
$type: "dimension",
|
|
1674
|
-
$value: "{border-radius.6}"
|
|
1675
|
-
}
|
|
1676
|
-
},
|
|
1677
|
-
size: {
|
|
1678
|
-
"0": {
|
|
1679
|
-
$type: "dimension",
|
|
1680
|
-
$value: "{_size.0}"
|
|
1681
|
-
},
|
|
1682
|
-
"1": {
|
|
1683
|
-
$type: "dimension",
|
|
1684
|
-
$value: "{_size.1}"
|
|
1685
|
-
},
|
|
1686
|
-
"2": {
|
|
1687
|
-
$type: "dimension",
|
|
1688
|
-
$value: "{_size.2}"
|
|
1689
|
-
},
|
|
1690
|
-
"3": {
|
|
1691
|
-
$type: "dimension",
|
|
1692
|
-
$value: "{_size.3}"
|
|
1693
|
-
},
|
|
1694
|
-
"4": {
|
|
1695
|
-
$type: "dimension",
|
|
1696
|
-
$value: "{_size.4}"
|
|
1697
|
-
},
|
|
1698
|
-
"5": {
|
|
1699
|
-
$type: "dimension",
|
|
1700
|
-
$value: "{_size.5}"
|
|
1701
|
-
},
|
|
1702
|
-
"6": {
|
|
1703
|
-
$type: "dimension",
|
|
1704
|
-
$value: "{_size.6}"
|
|
1705
|
-
},
|
|
1706
|
-
"7": {
|
|
1707
|
-
$type: "dimension",
|
|
1708
|
-
$value: "{_size.7}"
|
|
1709
|
-
},
|
|
1710
|
-
"8": {
|
|
1711
|
-
$type: "dimension",
|
|
1712
|
-
$value: "{_size.8}"
|
|
1713
|
-
},
|
|
1714
|
-
"9": {
|
|
1715
|
-
$type: "dimension",
|
|
1716
|
-
$value: "{_size.9}"
|
|
1717
|
-
},
|
|
1718
|
-
"10": {
|
|
1719
|
-
$type: "dimension",
|
|
1720
|
-
$value: "{_size.10}"
|
|
1721
|
-
},
|
|
1722
|
-
"11": {
|
|
1723
|
-
$type: "dimension",
|
|
1724
|
-
$value: "{_size.11}"
|
|
1725
|
-
},
|
|
1726
|
-
"12": {
|
|
1727
|
-
$type: "dimension",
|
|
1728
|
-
$value: "{_size.12}"
|
|
1729
|
-
},
|
|
1730
|
-
"13": {
|
|
1731
|
-
$type: "dimension",
|
|
1732
|
-
$value: "{_size.13}"
|
|
1733
|
-
},
|
|
1734
|
-
"14": {
|
|
1735
|
-
$type: "dimension",
|
|
1736
|
-
$value: "{_size.14}"
|
|
1737
|
-
},
|
|
1738
|
-
"15": {
|
|
1739
|
-
$type: "dimension",
|
|
1740
|
-
$value: "{_size.15}"
|
|
1741
|
-
},
|
|
1742
|
-
"18": {
|
|
1743
|
-
$type: "dimension",
|
|
1744
|
-
$value: "{_size.18}"
|
|
1745
|
-
},
|
|
1746
|
-
"22": {
|
|
1747
|
-
$type: "dimension",
|
|
1748
|
-
$value: "{_size.22}"
|
|
1749
|
-
},
|
|
1750
|
-
"26": {
|
|
1751
|
-
$type: "dimension",
|
|
1752
|
-
$value: "{_size.26}"
|
|
1753
|
-
},
|
|
1754
|
-
"30": {
|
|
1755
|
-
$type: "dimension",
|
|
1756
|
-
$value: "{_size.30}"
|
|
1757
|
-
}
|
|
1758
|
-
}
|
|
1759
|
-
};
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
// src/tokens/create/generators/themes/theme.ts
|
|
1763
|
-
import * as R6 from "ramda";
|
|
1764
|
-
var generateTheme = (colors, themeName, borderRadius) => {
|
|
1765
|
-
const mainColorNames = Object.keys(colors.main);
|
|
1766
|
-
const supportColorNames = Object.keys(colors.support);
|
|
1767
|
-
const customColors = [...mainColorNames, "neutral", ...supportColorNames, ...baseColorNames];
|
|
1768
|
-
const themeColorTokens = Object.fromEntries(
|
|
1769
|
-
customColors.map((colorName) => [colorName, generateColorScaleTokens3(colorName, themeName)])
|
|
1770
|
-
);
|
|
1771
|
-
const { color: themeBaseFileColor, ...remainingThemeFile } = generateBase(themeName);
|
|
1772
|
-
const themeFile = {
|
|
1773
|
-
color: {
|
|
1774
|
-
...themeColorTokens,
|
|
1775
|
-
...themeBaseFileColor,
|
|
1776
|
-
link: {
|
|
1777
|
-
visited: {
|
|
1778
|
-
$type: "color",
|
|
1779
|
-
$value: `{${themeName}.link.visited}`
|
|
1780
|
-
}
|
|
1781
|
-
},
|
|
1782
|
-
focus: {
|
|
1783
|
-
"inner-color": {
|
|
1784
|
-
$type: "color",
|
|
1785
|
-
$value: `{${themeName}.focus.inner}`
|
|
1786
|
-
},
|
|
1787
|
-
"outer-color": {
|
|
1788
|
-
$type: "color",
|
|
1789
|
-
$value: `{${themeName}.focus.outer}`
|
|
1790
|
-
}
|
|
1791
|
-
}
|
|
1792
|
-
},
|
|
1793
|
-
...remainingThemeFile
|
|
1794
|
-
};
|
|
1795
|
-
const baseBorderRadius = R6.lensPath(["border-radius", "base", "$value"]);
|
|
1796
|
-
const updatedThemeFile = R6.set(baseBorderRadius, String(borderRadius), themeFile);
|
|
1797
|
-
const token = JSON.parse(
|
|
1798
|
-
JSON.stringify(
|
|
1799
|
-
updatedThemeFile,
|
|
1800
|
-
(key, value) => {
|
|
1801
|
-
if (key === "$value") {
|
|
1802
|
-
return value.replace("<theme>", themeName);
|
|
1803
|
-
}
|
|
1804
|
-
return value;
|
|
1805
|
-
},
|
|
1806
|
-
2
|
|
1807
|
-
)
|
|
1808
|
-
);
|
|
1809
|
-
return token;
|
|
1810
|
-
};
|
|
1811
|
-
var generateBase = (themeName) => ({
|
|
1812
|
-
color: {},
|
|
1813
|
-
"font-family": {
|
|
1814
|
-
$type: "fontFamilies",
|
|
1815
|
-
$value: `{${themeName}.font-family}`
|
|
1816
|
-
},
|
|
1817
|
-
"font-weight": {
|
|
1818
|
-
medium: {
|
|
1819
|
-
$type: "fontWeights",
|
|
1820
|
-
$value: `{${themeName}.font-weight.medium}`
|
|
1821
|
-
},
|
|
1822
|
-
semibold: {
|
|
1823
|
-
$type: "fontWeights",
|
|
1824
|
-
$value: `{${themeName}.font-weight.semibold}`
|
|
1825
|
-
},
|
|
1826
|
-
regular: {
|
|
1827
|
-
$type: "fontWeights",
|
|
1828
|
-
$value: `{${themeName}.font-weight.regular}`
|
|
1829
|
-
}
|
|
1830
|
-
},
|
|
1831
|
-
"border-radius": {
|
|
1832
|
-
"1": {
|
|
1833
|
-
$type: "dimension",
|
|
1834
|
-
$value: "min({border-radius.base}*0.5,{border-radius.scale})"
|
|
1835
|
-
},
|
|
1836
|
-
"2": {
|
|
1837
|
-
$type: "dimension",
|
|
1838
|
-
$value: "min({border-radius.base},{border-radius.scale}*2)"
|
|
1839
|
-
},
|
|
1840
|
-
"3": {
|
|
1841
|
-
$type: "dimension",
|
|
1842
|
-
$value: "min({border-radius.base}*2,{border-radius.scale}*5)"
|
|
1843
|
-
},
|
|
1844
|
-
"4": {
|
|
1845
|
-
$type: "dimension",
|
|
1846
|
-
$value: "min({border-radius.base}*3,{border-radius.scale}*7)"
|
|
1847
|
-
},
|
|
1848
|
-
"5": {
|
|
1849
|
-
$type: "dimension",
|
|
1850
|
-
$value: "{border-radius.base}"
|
|
1851
|
-
},
|
|
1852
|
-
"6": {
|
|
1853
|
-
$type: "dimension",
|
|
1854
|
-
$value: "9999"
|
|
1855
|
-
},
|
|
1856
|
-
base: {
|
|
1857
|
-
$type: "dimension",
|
|
1858
|
-
$value: "4"
|
|
1859
|
-
},
|
|
1860
|
-
scale: {
|
|
1861
|
-
$type: "dimension",
|
|
1862
|
-
$value: "4"
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1865
|
-
});
|
|
1866
|
-
var generateColorScaleTokens3 = (colorName, themeName) => {
|
|
1867
|
-
const colorScale = {};
|
|
1868
|
-
for (const [_, colorNumber] of R6.toPairs(semanticColorMap)) {
|
|
1869
|
-
colorScale[colorNumber] = {
|
|
1870
|
-
$type: "color",
|
|
1871
|
-
$value: `{${themeName}.${colorName}.${colorNumber}}`
|
|
1872
|
-
};
|
|
1873
|
-
}
|
|
1874
|
-
return colorScale;
|
|
1875
|
-
};
|
|
1876
|
-
|
|
1877
|
-
// src/tokens/create.ts
|
|
1878
|
-
var createTokens = async (theme) => {
|
|
1879
|
-
const { colors, typography: typography2, name, borderRadius, overrides } = theme;
|
|
1880
|
-
const colorSchemes = ["light", "dark"];
|
|
1881
|
-
const sizeModes2 = ["small", "medium", "large"];
|
|
1882
|
-
const tokenSets = new Map([
|
|
1883
|
-
["primitives/globals", generateGlobals()],
|
|
1884
|
-
...sizeModes2.map((size2) => [`primitives/modes/size/${size2}`, generateSize(size2)]),
|
|
1885
|
-
["primitives/modes/size/global", generateSizeGlobal()],
|
|
1886
|
-
...sizeModes2.map((size2) => [
|
|
1887
|
-
`primitives/modes/typography/size/${size2}`,
|
|
1888
|
-
generateFontSizes(size2)
|
|
1889
|
-
]),
|
|
1890
|
-
[`primitives/modes/typography/primary/${name}`, generateTypography(name, typography2)],
|
|
1891
|
-
[`primitives/modes/typography/secondary/${name}`, generateTypography(name, typography2)],
|
|
1892
|
-
...colorSchemes.flatMap((scheme) => [
|
|
1893
|
-
[`primitives/modes/color-scheme/${scheme}/${name}`, generateColorScheme(name, scheme, colors, overrides)]
|
|
1894
|
-
]),
|
|
1895
|
-
[`themes/${name}`, generateTheme(colors, name, borderRadius)],
|
|
1896
|
-
["semantic/color", generateSemanticColors(colors, name)],
|
|
1897
|
-
// maps out semantic modes, ieg 'semantic/modes/main-color/accent', and 'semantic/modes/support-color/brand1'
|
|
1898
|
-
...Object.entries(generateColorModes(colors, name)).flatMap(
|
|
1899
|
-
([mode, colors2]) => Object.entries(colors2).map(([key, colorSet]) => [`semantic/modes/${mode}/${key}`, colorSet])
|
|
1900
|
-
),
|
|
1901
|
-
[`semantic/style`, generateSemanticStyle()]
|
|
1902
|
-
]);
|
|
1903
|
-
return { tokenSets };
|
|
1904
|
-
};
|
|
1905
|
-
|
|
1906
|
-
// src/tokens/process/output/theme.ts
|
|
1907
|
-
import pc from "picocolors";
|
|
1908
|
-
import * as R8 from "ramda";
|
|
1909
|
-
|
|
1910
|
-
// package.json
|
|
1911
|
-
var package_default = {
|
|
1912
|
-
name: "@digdir/designsystemet",
|
|
1913
|
-
version: "1.13.2",
|
|
1914
|
-
description: "CLI for Designsystemet",
|
|
1915
|
-
author: "Designsystemet team",
|
|
1916
|
-
engines: {
|
|
1917
|
-
node: ">=20.20.2"
|
|
1918
|
-
},
|
|
1919
|
-
repository: {
|
|
1920
|
-
type: "git",
|
|
1921
|
-
url: "git+https://github.com/digdir/designsystemet.git"
|
|
1922
|
-
},
|
|
1923
|
-
homepage: "https://github.com/digdir/designsystemet/tree/main/packages/cli",
|
|
1924
|
-
license: "MIT",
|
|
1925
|
-
type: "module",
|
|
1926
|
-
main: "./dist/src/index.js",
|
|
1927
|
-
files: [
|
|
1928
|
-
"./dist/**",
|
|
1929
|
-
"./configs/**"
|
|
1930
|
-
],
|
|
1931
|
-
bin: "dist/bin/designsystemet.js",
|
|
1932
|
-
exports: {
|
|
1933
|
-
".": {
|
|
1934
|
-
import: "./dist/src/index.js"
|
|
1935
|
-
},
|
|
1936
|
-
"./color": {
|
|
1937
|
-
import: "./dist/src/colors/index.js"
|
|
1938
|
-
},
|
|
1939
|
-
"./tokens": {
|
|
1940
|
-
import: "./dist/src/tokens/index.js"
|
|
1941
|
-
},
|
|
1942
|
-
"./types": {
|
|
1943
|
-
import: "./dist/src/types.js"
|
|
1944
|
-
}
|
|
1945
|
-
},
|
|
1946
|
-
publishConfig: {
|
|
1947
|
-
access: "public"
|
|
1948
|
-
},
|
|
1949
|
-
scripts: {
|
|
1950
|
-
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
1951
|
-
"designsystemet:inspect": "tsx --inspect-brk ./bin/designsystemet.ts",
|
|
1952
|
-
build: "tsup && pnpm build:types && pnpm build:json-schema",
|
|
1953
|
-
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
1954
|
-
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
1955
|
-
types: "tsc --noEmit",
|
|
1956
|
-
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
|
|
1957
|
-
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
|
|
1958
|
-
"test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
|
|
1959
|
-
"test:tokens-build-tailwind": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean --experimental-tailwind",
|
|
1960
|
-
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
1961
|
-
"test:tokens-build-config:inspect": "pnpm run designsystemet:inspect tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
1962
|
-
"test:tokens-build-config-tailwind": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean --experimental-tailwind",
|
|
1963
|
-
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
1964
|
-
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
1965
|
-
"test:generate-config-from-tokens": "pnpm run designsystemet generate-config-from-tokens -d ../../design-tokens --dry",
|
|
1966
|
-
test: "node -v && pnpm test:tokens-create-and-build-options && pnpm test:generate-config-from-tokens && pnpm test:tokens-create-and-build-config",
|
|
1967
|
-
"update:preview-tokens": "tsx ./src/scripts/update-preview-tokens.ts",
|
|
1968
|
-
verify: "pnpm test && pnpm update:template && pnpm --filter @internal/digdir update:theme-digdir"
|
|
1969
|
-
},
|
|
1970
|
-
dependencies: {
|
|
1971
|
-
"@commander-js/extra-typings": "^14.0.0",
|
|
1972
|
-
"@digdir/designsystemet-types": "workspace:",
|
|
1973
|
-
"@tokens-studio/sd-transforms": "2.0.3",
|
|
1974
|
-
"chroma-js": "^3.2.0",
|
|
1975
|
-
"colorjs.io": "^0.6.1",
|
|
1976
|
-
commander: "^14.0.3",
|
|
1977
|
-
"fast-glob": "^3.3.3",
|
|
1978
|
-
hsluv: "^1.0.1",
|
|
1979
|
-
"object-hash": "^3.0.0",
|
|
1980
|
-
picocolors: "^1.1.1",
|
|
1981
|
-
postcss: "^8.5.8",
|
|
1982
|
-
ramda: "^0.32.0",
|
|
1983
|
-
"style-dictionary": "^5.4.0",
|
|
1984
|
-
zod: "^4.3.6",
|
|
1985
|
-
"zod-validation-error": "^5.0.0"
|
|
1986
|
-
},
|
|
1987
|
-
devDependencies: {
|
|
1988
|
-
"@tokens-studio/types": "0.5.2",
|
|
1989
|
-
"@types/chroma-js": "3.1.2",
|
|
1990
|
-
"@types/node": "24.12.2",
|
|
1991
|
-
"@types/object-hash": "3.0.6",
|
|
1992
|
-
"@types/ramda": "0.31.1",
|
|
1993
|
-
tsup: "8.5.1",
|
|
1994
|
-
tsx: "4.21.0",
|
|
1995
|
-
typescript: "5.9.3"
|
|
1996
|
-
}
|
|
1997
|
-
};
|
|
1998
|
-
|
|
1999
|
-
// src/tokens/utils.ts
|
|
2000
|
-
import * as R7 from "ramda";
|
|
2001
|
-
|
|
2002
|
-
// src/tokens/types.ts
|
|
2003
|
-
var colorCategories = {
|
|
2004
|
-
main: "main",
|
|
2005
|
-
support: "support"
|
|
2006
|
-
};
|
|
2007
|
-
|
|
2008
|
-
// src/tokens/utils.ts
|
|
2009
|
-
var mapToLowerCase = R7.map(R7.toLower);
|
|
2010
|
-
var hasAnyTruth = R7.any(R7.equals(true));
|
|
2011
|
-
var getType = (token) => (token.$type ?? token.type) || "";
|
|
2012
|
-
var getValue = (token) => token.$value ?? token.value;
|
|
2013
|
-
var typeEquals = R7.curry(
|
|
2014
|
-
(types, token) => {
|
|
2015
|
-
if (R7.isNil(token)) {
|
|
2016
|
-
return false;
|
|
2017
|
-
}
|
|
2018
|
-
return R7.includes(R7.toLower(getType(token)), R7.map(R7.toLower, Array.isArray(types) ? types : [types]));
|
|
2019
|
-
}
|
|
2020
|
-
);
|
|
2021
|
-
var pathStartsWithOneOf = R7.curry(
|
|
2022
|
-
(paths, token) => {
|
|
2023
|
-
if (R7.isNil(token)) {
|
|
2024
|
-
return false;
|
|
2025
|
-
}
|
|
2026
|
-
const tokenPath = mapToLowerCase(token.path);
|
|
2027
|
-
const matchPathsStartingWith = R7.map((pathOrString) => {
|
|
2028
|
-
const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
|
|
2029
|
-
return R7.startsWith(mapToLowerCase(path), tokenPath);
|
|
2030
|
-
}, paths);
|
|
2031
|
-
return hasAnyTruth(matchPathsStartingWith);
|
|
2032
|
-
}
|
|
2033
|
-
);
|
|
2034
|
-
function isSemanticToken(token) {
|
|
2035
|
-
return token.filePath.includes("semantic/");
|
|
2036
|
-
}
|
|
2037
|
-
function isSemanticColorToken(token, color) {
|
|
2038
|
-
return token.filePath.includes("semantic/") && R7.startsWith(["color", color], token.path);
|
|
2039
|
-
}
|
|
2040
|
-
function isGlobalColorToken(token) {
|
|
2041
|
-
return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
|
|
2042
|
-
}
|
|
2043
|
-
function isColorCategoryToken(token, category) {
|
|
2044
|
-
if (!category) {
|
|
2045
|
-
return Object.keys(colorCategories).some(
|
|
2046
|
-
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
2047
|
-
);
|
|
2048
|
-
}
|
|
2049
|
-
return R7.startsWith(["color", category], token.path);
|
|
2050
|
-
}
|
|
2051
|
-
var isDigit = (s) => /^\d+$/.test(s);
|
|
2052
|
-
function traverseObj(obj, fn) {
|
|
2053
|
-
for (const key in obj) {
|
|
2054
|
-
const prop3 = obj[key];
|
|
2055
|
-
if (prop3 != null) {
|
|
2056
|
-
fn.apply(null, [obj, key, prop3]);
|
|
2057
|
-
if (typeof prop3 === "object") {
|
|
2058
|
-
traverseObj(prop3, fn);
|
|
2059
|
-
}
|
|
2060
|
-
}
|
|
2061
|
-
}
|
|
2062
|
-
return obj;
|
|
2063
|
-
}
|
|
2064
|
-
function inlineTokens(shouldInline, tokens) {
|
|
2065
|
-
const [inlineableTokens, otherTokens] = R7.partition(shouldInline, tokens);
|
|
2066
|
-
return otherTokens.map((token) => {
|
|
2067
|
-
let transformed = getValue(token.original);
|
|
2068
|
-
for (const ref of inlineableTokens) {
|
|
2069
|
-
const refName = ref.path.join(".");
|
|
2070
|
-
if (typeof transformed === "string") {
|
|
2071
|
-
transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
|
-
const tokenWithInlinedRefs = R7.set(R7.lensPath(["original", "$value"]), transformed, token);
|
|
2075
|
-
return tokenWithInlinedRefs;
|
|
2076
|
-
});
|
|
2077
|
-
}
|
|
2078
|
-
var sizeMap = {
|
|
2079
|
-
xsmall: "xs",
|
|
2080
|
-
small: "sm",
|
|
2081
|
-
medium: "md",
|
|
2082
|
-
large: "lg",
|
|
2083
|
-
xlarge: "xl"
|
|
2084
|
-
};
|
|
2085
|
-
function shortSizeName(size2) {
|
|
2086
|
-
return sizeMap[size2] ?? size2;
|
|
2087
|
-
}
|
|
2088
|
-
var sizeComparator = (size2) => {
|
|
2089
|
-
const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
|
|
2090
|
-
return sortIndex ?? 0;
|
|
2091
|
-
};
|
|
2092
|
-
function orderBySize(sizes) {
|
|
2093
|
-
return R7.sortBy(sizeComparator, sizes);
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
// src/tokens/process/output/theme.ts
|
|
2097
|
-
var defaultFileHeader = `build: v${package_default.version}`;
|
|
2098
|
-
var getFileNameWithoutExtension = (path) => {
|
|
2099
|
-
const pathSegments = path.split("/");
|
|
2100
|
-
return pathSegments[pathSegments.length - 1].split(".").slice(0, -1).join(".");
|
|
2101
|
-
};
|
|
2102
|
-
var createThemeCSSFiles = ({
|
|
2103
|
-
processedBuilds,
|
|
2104
|
-
fileHeader = defaultFileHeader
|
|
2105
|
-
}) => {
|
|
2106
|
-
const groupedByTheme = {};
|
|
2107
|
-
for (const [_, buildResults] of Object.entries(processedBuilds)) {
|
|
2108
|
-
for (const buildResult of buildResults) {
|
|
2109
|
-
const themeName = buildResult.permutation.theme;
|
|
2110
|
-
const newOutputs = buildResult.formatted;
|
|
2111
|
-
if (R8.isNotEmpty(newOutputs)) {
|
|
2112
|
-
const currentOutputs = groupedByTheme[themeName] ?? [];
|
|
2113
|
-
groupedByTheme[themeName] = R8.concat(currentOutputs, newOutputs);
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
const sortOrder = [
|
|
2118
|
-
"size-mode/",
|
|
2119
|
-
"type-scale",
|
|
2120
|
-
"color-scheme/light",
|
|
2121
|
-
"typography/secondary",
|
|
2122
|
-
"size",
|
|
2123
|
-
"semantic",
|
|
2124
|
-
"color-scheme/dark",
|
|
2125
|
-
"color-scheme/contrast",
|
|
2126
|
-
"typography/primary",
|
|
2127
|
-
"color/"
|
|
2128
|
-
];
|
|
2129
|
-
const sortByDefinedOrder = R8.sortBy((file) => {
|
|
2130
|
-
const filePath = file.destination || "";
|
|
2131
|
-
const sortIndex = sortOrder.findIndex((sortElement) => {
|
|
2132
|
-
if (sortElement.endsWith("/")) {
|
|
2133
|
-
return filePath.includes(sortElement);
|
|
2134
|
-
}
|
|
2135
|
-
return filePath.includes(`${sortElement}.css`);
|
|
2136
|
-
});
|
|
2137
|
-
if (sortIndex === -1) {
|
|
2138
|
-
console.error(
|
|
2139
|
-
pc.yellow(`WARNING: CSS section does not have a defined sort order: ${filePath.replace(".css", "")}`)
|
|
2140
|
-
);
|
|
2141
|
-
console.log(
|
|
2142
|
-
pc.dim(
|
|
2143
|
-
`
|
|
2144
|
-
The section will currently be added to the end of the entry file, but the exact
|
|
2145
|
-
order may change due to nondeterminism.`.trim()
|
|
2146
|
-
)
|
|
2147
|
-
);
|
|
2148
|
-
return Infinity;
|
|
2149
|
-
}
|
|
2150
|
-
return sortIndex;
|
|
2151
|
-
});
|
|
2152
|
-
const header = `@charset "UTF-8";
|
|
2153
|
-
/*
|
|
2154
|
-
${fileHeader}
|
|
8
|
+
//#region src/tokens/format.ts
|
|
9
|
+
const formatTokens = async (options) => {
|
|
10
|
+
return await processPlatform({
|
|
11
|
+
type: "format",
|
|
12
|
+
buildTokenFormats: {},
|
|
13
|
+
...options
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
const formatTheme = async (themeConfig) => {
|
|
17
|
+
const { tokenSets } = await createTokens(themeConfig);
|
|
18
|
+
return await formatTokens({
|
|
19
|
+
tokenSets,
|
|
20
|
+
processed$themes: (await generate$Themes(tokenSetDimensions, [themeConfig.name], colorNamesByCategory(themeConfig.colors))).map(processThemeObject),
|
|
21
|
+
verbose: false
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Formats a theme configuration into CSS.
|
|
26
|
+
*
|
|
27
|
+
* This function takes a `Theme` configuration object, processes it using the
|
|
28
|
+
* `formatTheme` function, and then generates CSS using the `createThemeCSS` function.
|
|
29
|
+
*
|
|
30
|
+
* @param themeConfig - The theme configuration object to be formatted.
|
|
31
|
+
* @returns A promise that resolves to the generated CSS string.
|
|
2155
32
|
*/
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
const sortBySize = R8.sortBy(
|
|
2160
|
-
R8.pipe((s) => getFileNameWithoutExtension(s.destination ?? ""), sizeComparator)
|
|
2161
|
-
);
|
|
2162
|
-
const pickOutputs = R8.map(R8.view(R8.lensProp("output")));
|
|
2163
|
-
const themeCSSFile = R8.pipe(
|
|
2164
|
-
sortAlphabetically,
|
|
2165
|
-
sortBySize,
|
|
2166
|
-
sortByDefinedOrder,
|
|
2167
|
-
pickOutputs,
|
|
2168
|
-
R8.join("\n"),
|
|
2169
|
-
(content) => header + content
|
|
2170
|
-
);
|
|
2171
|
-
const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
|
|
2172
|
-
destination: `${theme}.css`,
|
|
2173
|
-
output: themeCSSFile(files)
|
|
2174
|
-
}));
|
|
2175
|
-
return themeCSSFiles;
|
|
2176
|
-
};
|
|
2177
|
-
|
|
2178
|
-
// src/tokens/process/platform.ts
|
|
2179
|
-
import pc3 from "picocolors";
|
|
2180
|
-
import * as R22 from "ramda";
|
|
2181
|
-
import StyleDictionary2 from "style-dictionary";
|
|
2182
|
-
|
|
2183
|
-
// src/tokens/process/configs.ts
|
|
2184
|
-
import { register } from "@tokens-studio/sd-transforms";
|
|
2185
|
-
import * as R21 from "ramda";
|
|
2186
|
-
import StyleDictionary from "style-dictionary";
|
|
2187
|
-
|
|
2188
|
-
// src/tokens/process/configs/color.ts
|
|
2189
|
-
import * as R16 from "ramda";
|
|
2190
|
-
|
|
2191
|
-
// src/tokens/process/formats/css/color.ts
|
|
2192
|
-
import * as R9 from "ramda";
|
|
2193
|
-
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
2194
|
-
var prefersColorScheme = (colorScheme2, content) => `
|
|
2195
|
-
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
2196
|
-
[data-color-scheme="auto"] ${content}
|
|
2197
|
-
}
|
|
2198
|
-
`;
|
|
2199
|
-
var colorScheme = {
|
|
2200
|
-
name: "ds/css-colorscheme",
|
|
2201
|
-
format: async ({ dictionary, options, platform }) => {
|
|
2202
|
-
const { allTokens } = dictionary;
|
|
2203
|
-
const { outputReferences, usesDtcg } = options;
|
|
2204
|
-
const { selector, colorScheme: colorScheme2, layer } = platform;
|
|
2205
|
-
const colorScheme_ = colorScheme2;
|
|
2206
|
-
const format = createPropertyFormatter({
|
|
2207
|
-
outputReferences,
|
|
2208
|
-
dictionary,
|
|
2209
|
-
format: "css",
|
|
2210
|
-
usesDtcg
|
|
2211
|
-
});
|
|
2212
|
-
const colorSchemeProperty = colorScheme_ === "dark" || colorScheme_ === "light" ? `
|
|
2213
|
-
color-scheme: ${colorScheme_};
|
|
2214
|
-
` : "";
|
|
2215
|
-
const filteredAllTokens = allTokens.filter(
|
|
2216
|
-
R9.allPass([
|
|
2217
|
-
R9.anyPass([
|
|
2218
|
-
// Include semantic tokens in the output
|
|
2219
|
-
isSemanticToken,
|
|
2220
|
-
// Include global color tokens
|
|
2221
|
-
isGlobalColorToken
|
|
2222
|
-
]),
|
|
2223
|
-
// Don't include color category tokens -- they are exported separately
|
|
2224
|
-
(t) => !isColorCategoryToken(t)
|
|
2225
|
-
])
|
|
2226
|
-
);
|
|
2227
|
-
const formattedMap = filteredAllTokens.map((token) => ({
|
|
2228
|
-
token,
|
|
2229
|
-
formatted: format(token)
|
|
2230
|
-
}));
|
|
2231
|
-
const formattedTokens = formattedMap.map(R9.view(R9.lensProp("formatted"))).join("\n");
|
|
2232
|
-
const content = `{
|
|
2233
|
-
${formattedTokens}
|
|
2234
|
-
${colorSchemeProperty}}
|
|
2235
|
-
`;
|
|
2236
|
-
const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
|
|
2237
|
-
const body = R9.isNotNil(layer) ? `@layer ${layer} {
|
|
2238
|
-
${selector} ${content} ${autoSelectorContent}
|
|
2239
|
-
}
|
|
2240
|
-
` : `${selector} ${content} ${autoSelectorContent}
|
|
2241
|
-
`;
|
|
2242
|
-
return body;
|
|
2243
|
-
}
|
|
2244
|
-
};
|
|
2245
|
-
var colorCategory = {
|
|
2246
|
-
name: "ds/css-colorcategory",
|
|
2247
|
-
format: async ({ dictionary, file, options, platform }) => {
|
|
2248
|
-
const { outputReferences, usesDtcg } = options;
|
|
2249
|
-
const { selector, layer } = platform;
|
|
2250
|
-
const destination = file.destination;
|
|
2251
|
-
const format = R9.compose(
|
|
2252
|
-
createPropertyFormatter({
|
|
2253
|
-
outputReferences,
|
|
2254
|
-
dictionary,
|
|
2255
|
-
format: "css",
|
|
2256
|
-
usesDtcg
|
|
2257
|
-
}),
|
|
2258
|
-
(token) => ({
|
|
2259
|
-
...token,
|
|
2260
|
-
name: token.name.replace(/color-\w+-/, "color-"),
|
|
2261
|
-
original: {
|
|
2262
|
-
...token.original,
|
|
2263
|
-
$value: new RegExp(`color-(${colorCategories.main}|${colorCategories.support})-`).test(token.name) ? token.original.$value : `{${token.path.join(".")}}`
|
|
2264
|
-
}
|
|
2265
|
-
})
|
|
2266
|
-
);
|
|
2267
|
-
const formattedMap = dictionary.allTokens.map((token) => ({
|
|
2268
|
-
token,
|
|
2269
|
-
formatted: format(token)
|
|
2270
|
-
}));
|
|
2271
|
-
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2272
|
-
const formattedTokens = formattedMap.map(R9.view(R9.lensProp("formatted"))).join("\n");
|
|
2273
|
-
const content = `{
|
|
2274
|
-
${formattedTokens}
|
|
2275
|
-
}
|
|
2276
|
-
`;
|
|
2277
|
-
const body = R9.isNotNil(layer) ? `@layer ${layer} {
|
|
2278
|
-
${selector} ${content}
|
|
2279
|
-
}
|
|
2280
|
-
` : `${selector} ${content}
|
|
2281
|
-
`;
|
|
2282
|
-
return body;
|
|
2283
|
-
}
|
|
2284
|
-
};
|
|
2285
|
-
|
|
2286
|
-
// src/tokens/process/formats/css/semantic.ts
|
|
2287
|
-
import * as R11 from "ramda";
|
|
2288
|
-
import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
|
|
2289
|
-
|
|
2290
|
-
// src/tokens/process/formats/css/size.ts
|
|
2291
|
-
import * as R10 from "ramda";
|
|
2292
|
-
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
2293
|
-
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
2294
|
-
var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
|
|
2295
|
-
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
2296
|
-
var isInlineTokens = R10.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
2297
|
-
var overrideSizingFormula = (format, token) => {
|
|
2298
|
-
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
2299
|
-
let calc;
|
|
2300
|
-
let round;
|
|
2301
|
-
if (token.path[1] === "unit") {
|
|
2302
|
-
calc = `calc(1rem * ${value})`;
|
|
2303
|
-
} else if (value.startsWith("floor")) {
|
|
2304
|
-
calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
|
|
2305
|
-
round = `round(down, ${calc}, 1px)`;
|
|
2306
|
-
} else {
|
|
2307
|
-
calc = value.includes("*") ? `calc(${value})` : value;
|
|
2308
|
-
}
|
|
2309
|
-
return {
|
|
2310
|
-
name,
|
|
2311
|
-
round: round ?? calc,
|
|
2312
|
-
calc
|
|
2313
|
-
};
|
|
2314
|
-
};
|
|
2315
|
-
var formatSizingTokens = (format, tokens) => R10.reduce(
|
|
2316
|
-
(acc, token) => {
|
|
2317
|
-
const { round, calc, name } = overrideSizingFormula(format, token);
|
|
2318
|
-
return {
|
|
2319
|
-
tokens: [...acc.tokens, token],
|
|
2320
|
-
round: [...acc.round, `${name}: ${round};`],
|
|
2321
|
-
calc: [...acc.calc, `${name}: ${calc};`]
|
|
2322
|
-
};
|
|
2323
|
-
},
|
|
2324
|
-
{ tokens: [], round: [], calc: [] },
|
|
2325
|
-
tokens
|
|
2326
|
-
);
|
|
2327
|
-
var sizingTemplate = ({ round, calc }) => {
|
|
2328
|
-
const usesRounding = round.filter((val, i) => val !== calc[i]);
|
|
2329
|
-
return `
|
|
2330
|
-
${calc.join("\n")}
|
|
2331
|
-
|
|
2332
|
-
@supports (width: round(down, .1em, 1px)) {
|
|
2333
|
-
${usesRounding.join("\n ")}
|
|
2334
|
-
}`;
|
|
2335
|
-
};
|
|
2336
|
-
var size = {
|
|
2337
|
-
name: "ds/css-size",
|
|
2338
|
-
format: async ({ dictionary, file, options, platform }) => {
|
|
2339
|
-
const { outputReferences, usesDtcg } = options;
|
|
2340
|
-
const { selector, layer } = platform;
|
|
2341
|
-
const destination = file.destination;
|
|
2342
|
-
const format = createPropertyFormatter2({
|
|
2343
|
-
outputReferences,
|
|
2344
|
-
dictionary,
|
|
2345
|
-
format: "css",
|
|
2346
|
-
usesDtcg
|
|
2347
|
-
});
|
|
2348
|
-
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
2349
|
-
const filteredTokens = R10.reject((token) => R10.equals(["_size", "mode-font-size"], token.path), tokens);
|
|
2350
|
-
const [sizingTokens, restTokens] = R10.partition(
|
|
2351
|
-
(t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
|
|
2352
|
-
filteredTokens
|
|
2353
|
-
);
|
|
2354
|
-
const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
|
|
2355
|
-
const formattedMap = restTokens.map((token) => ({
|
|
2356
|
-
token,
|
|
2357
|
-
formatted: format(token)
|
|
2358
|
-
}));
|
|
2359
|
-
const formattedSizingMap = formattedSizingTokens.round.map((t, i) => ({
|
|
2360
|
-
token: formattedSizingTokens.tokens[i],
|
|
2361
|
-
formatted: t
|
|
2362
|
-
}));
|
|
2363
|
-
buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
|
|
2364
|
-
const formattedTokens = [formattedMap.map(R10.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
|
|
2365
|
-
const content = `${selector} {
|
|
2366
|
-
${formattedTokens.join("\n")}
|
|
2367
|
-
}
|
|
2368
|
-
`;
|
|
2369
|
-
const body = R10.isNotNil(layer) ? `@layer ${layer} {
|
|
2370
|
-
${content}
|
|
2371
|
-
}
|
|
2372
|
-
` : `${content}
|
|
2373
|
-
`;
|
|
2374
|
-
return body;
|
|
2375
|
-
}
|
|
2376
|
-
};
|
|
2377
|
-
|
|
2378
|
-
// src/tokens/process/formats/css/semantic.ts
|
|
2379
|
-
var semantic = {
|
|
2380
|
-
name: "ds/css-semantic",
|
|
2381
|
-
format: async ({ dictionary, file, options, platform }) => {
|
|
2382
|
-
const { outputReferences, usesDtcg } = options;
|
|
2383
|
-
const { selector, layer } = platform;
|
|
2384
|
-
const destination = file.destination;
|
|
2385
|
-
const format = createPropertyFormatter3({
|
|
2386
|
-
outputReferences,
|
|
2387
|
-
dictionary,
|
|
2388
|
-
format: "css",
|
|
2389
|
-
usesDtcg
|
|
2390
|
-
});
|
|
2391
|
-
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
2392
|
-
const formattedMap = tokens.map((token) => ({
|
|
2393
|
-
token,
|
|
2394
|
-
formatted: format(token)
|
|
2395
|
-
}));
|
|
2396
|
-
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2397
|
-
const formattedTokens = formattedMap.map(R11.prop("formatted")).join("\n");
|
|
2398
|
-
const content = `${selector} {
|
|
2399
|
-
${formattedTokens}
|
|
2400
|
-
}
|
|
2401
|
-
`;
|
|
2402
|
-
const body = R11.isNotNil(layer) ? `@layer ${layer} {
|
|
2403
|
-
${content}
|
|
2404
|
-
}
|
|
2405
|
-
` : `${content}
|
|
2406
|
-
`;
|
|
2407
|
-
return body;
|
|
2408
|
-
}
|
|
2409
|
-
};
|
|
2410
|
-
|
|
2411
|
-
// src/tokens/process/formats/css/size-mode.ts
|
|
2412
|
-
import * as R13 from "ramda";
|
|
2413
|
-
import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
|
|
2414
|
-
|
|
2415
|
-
// src/tokens/process/transformers.ts
|
|
2416
|
-
import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
|
|
2417
|
-
import * as R12 from "ramda";
|
|
2418
|
-
var isPx = R12.test(/\b\d+px\b/g);
|
|
2419
|
-
var sizeRem = {
|
|
2420
|
-
name: "ds/size/toRem",
|
|
2421
|
-
type: "value",
|
|
2422
|
-
transitive: true,
|
|
2423
|
-
filter: (token) => {
|
|
2424
|
-
const hasWantedType = typeEquals(["dimension", "fontsize"], token);
|
|
2425
|
-
const hasWantedPath = pathStartsWithOneOf([
|
|
2426
|
-
"border-radius",
|
|
2427
|
-
"font-size"
|
|
2428
|
-
/*, ['_size', 'mode-font-size']*/
|
|
2429
|
-
], token);
|
|
2430
|
-
return hasWantedType && hasWantedPath;
|
|
2431
|
-
},
|
|
2432
|
-
transform: (token, config) => {
|
|
2433
|
-
const value = getValue(token);
|
|
2434
|
-
if (isPx(value)) {
|
|
2435
|
-
const baseFont = config.basePxFontSize || 16;
|
|
2436
|
-
const size2 = parseInt(value, 10);
|
|
2437
|
-
if (size2 === 0) {
|
|
2438
|
-
return "0";
|
|
2439
|
-
}
|
|
2440
|
-
return `${size2 / baseFont}rem`;
|
|
2441
|
-
}
|
|
2442
|
-
return value;
|
|
2443
|
-
}
|
|
2444
|
-
};
|
|
2445
|
-
var typographyName = {
|
|
2446
|
-
name: "name/typography",
|
|
2447
|
-
type: "name",
|
|
2448
|
-
transitive: true,
|
|
2449
|
-
// expanded tokens have different type so we match on path instead
|
|
2450
|
-
filter: (token) => pathStartsWithOneOf(["typography"], token),
|
|
2451
|
-
transform: (token) => {
|
|
2452
|
-
return token.name.replace("-typography", "");
|
|
2453
|
-
}
|
|
2454
|
-
};
|
|
2455
|
-
var resolveMath = {
|
|
2456
|
-
name: "ds/resolveMath",
|
|
2457
|
-
type: "value",
|
|
2458
|
-
transitive: true,
|
|
2459
|
-
filter: (token) => {
|
|
2460
|
-
const isValidValue = ["string", "object"].includes(typeof getValue(token));
|
|
2461
|
-
const isTokenOfInterest = !pathStartsWithOneOf(["border-radius"], token);
|
|
2462
|
-
return isValidValue && isTokenOfInterest;
|
|
2463
|
-
},
|
|
2464
|
-
transform: (token, platformCfg) => checkAndEvaluateMath(token, platformCfg.mathFractionDigits)
|
|
2465
|
-
};
|
|
2466
|
-
var unitless = {
|
|
2467
|
-
name: "ds/unitless",
|
|
2468
|
-
type: "value",
|
|
2469
|
-
transitive: true,
|
|
2470
|
-
filter: (token) => pathStartsWithOneOf(["size", "_size"], token),
|
|
2471
|
-
transform: (token) => parseInt(getValue(token), 10)
|
|
2472
|
-
};
|
|
2473
|
-
|
|
2474
|
-
// src/tokens/process/configs/shared.ts
|
|
2475
|
-
var prefix = "ds";
|
|
2476
|
-
var basePxFontSize = 16;
|
|
2477
|
-
var dsTransformers = [
|
|
2478
|
-
"name/kebab",
|
|
2479
|
-
resolveMath.name,
|
|
2480
|
-
"ts/size/px",
|
|
2481
|
-
sizeRem.name,
|
|
2482
|
-
unitless.name,
|
|
2483
|
-
"ts/typography/fontWeight",
|
|
2484
|
-
typographyName.name,
|
|
2485
|
-
"ts/color/modifiers",
|
|
2486
|
-
"ts/color/css/hexrgba",
|
|
2487
|
-
"ts/size/lineheight",
|
|
2488
|
-
"shadow/css/shorthand"
|
|
2489
|
-
];
|
|
2490
|
-
|
|
2491
|
-
// src/tokens/process/formats/css/size-mode.ts
|
|
2492
|
-
var formatBaseSizeToken = (size2) => (token) => ({
|
|
2493
|
-
...token,
|
|
2494
|
-
originalName: token.name,
|
|
2495
|
-
name: `${token.name}--${shortSizeName(size2)}`,
|
|
2496
|
-
$value: token.$value / basePxFontSize
|
|
2497
|
-
});
|
|
2498
|
-
var sizeMode = {
|
|
2499
|
-
name: "ds/css-size-mode",
|
|
2500
|
-
format: async ({ dictionary, file, options, platform }) => {
|
|
2501
|
-
const { outputReferences, usesDtcg } = options;
|
|
2502
|
-
const { selector, layer, size: size2 } = platform;
|
|
2503
|
-
const destination = file.destination;
|
|
2504
|
-
const format = createPropertyFormatter4({
|
|
2505
|
-
outputReferences,
|
|
2506
|
-
dictionary,
|
|
2507
|
-
format: "css",
|
|
2508
|
-
usesDtcg
|
|
2509
|
-
});
|
|
2510
|
-
const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
|
|
2511
|
-
const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
|
|
2512
|
-
const formattedMap = sizeSpecificTokens.map((token) => ({
|
|
2513
|
-
token,
|
|
2514
|
-
formatted: format({
|
|
2515
|
-
...token,
|
|
2516
|
-
// Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
|
|
2517
|
-
name: token.originalName
|
|
2518
|
-
})
|
|
2519
|
-
}));
|
|
2520
|
-
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2521
|
-
const content = `${selector} /* ${size2} */ {
|
|
2522
|
-
${sizeSpecificVariables}
|
|
2523
|
-
}`;
|
|
2524
|
-
const body = wrapInLayer(content, layer);
|
|
2525
|
-
const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
|
|
2526
|
-
const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
|
|
2527
|
-
const sizingToggles = `:root, [data-size] {
|
|
2528
|
-
--ds-size: var(--ds-size--${defaultSize});
|
|
2529
|
-
${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
|
|
2530
|
-
--ds-size-mode-font-size:
|
|
2531
|
-
${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
|
|
2532
|
-
}`;
|
|
2533
|
-
const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
|
|
2534
|
-
const sharedContent = `${sizingToggles}
|
|
2535
|
-
|
|
2536
|
-
${sizingHelpers}`;
|
|
2537
|
-
const sharedBody = shortSizeName(size2) === R13.last(sizes) ? `
|
|
2538
|
-
${wrapInLayer(sharedContent, layer)}` : "";
|
|
2539
|
-
return body + sharedBody;
|
|
2540
|
-
}
|
|
2541
|
-
};
|
|
2542
|
-
function wrapInLayer(content, layer) {
|
|
2543
|
-
return R13.isNotNil(layer) ? `@layer ${layer} {
|
|
2544
|
-
${content}
|
|
2545
|
-
}
|
|
2546
|
-
` : `${content}
|
|
2547
|
-
`;
|
|
2548
|
-
}
|
|
2549
|
-
|
|
2550
|
-
// src/tokens/process/formats/css/typography.ts
|
|
2551
|
-
import * as R14 from "ramda";
|
|
2552
|
-
import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
|
|
2553
|
-
var typographyFontFamilyPredicate = R14.allPass([
|
|
2554
|
-
R14.pathSatisfies(R14.includes("typography"), ["path"]),
|
|
2555
|
-
R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
|
|
2556
|
-
]);
|
|
2557
|
-
var typography = {
|
|
2558
|
-
name: "ds/css-typography",
|
|
2559
|
-
format: async ({ dictionary, file, options, platform }) => {
|
|
2560
|
-
const { outputReferences, usesDtcg } = options;
|
|
2561
|
-
const { selector, layer } = platform;
|
|
2562
|
-
const destination = file.destination;
|
|
2563
|
-
const format = createPropertyFormatter5({
|
|
2564
|
-
outputReferences,
|
|
2565
|
-
dictionary,
|
|
2566
|
-
format: "css",
|
|
2567
|
-
usesDtcg
|
|
2568
|
-
});
|
|
2569
|
-
const filteredTokens = R14.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
2570
|
-
const formattedMap = filteredTokens.map((token) => ({
|
|
2571
|
-
token,
|
|
2572
|
-
formatted: format(token)
|
|
2573
|
-
}));
|
|
2574
|
-
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2575
|
-
const formattedTokens = formattedMap.map(R14.view(R14.lensProp("formatted"))).join("\n");
|
|
2576
|
-
const content = selector ? `${selector} {
|
|
2577
|
-
${formattedTokens}
|
|
2578
|
-
}` : formattedTokens;
|
|
2579
|
-
const body = R14.isNotNil(layer) ? `@layer ${layer} {
|
|
2580
|
-
${content}
|
|
2581
|
-
}` : content;
|
|
2582
|
-
return body;
|
|
2583
|
-
}
|
|
2584
|
-
};
|
|
2585
|
-
|
|
2586
|
-
// src/tokens/process/formats/css/type-scale.ts
|
|
2587
|
-
import * as R15 from "ramda";
|
|
2588
|
-
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
2589
|
-
var isTypographyFontFamilyToken = R15.allPass([
|
|
2590
|
-
R15.pathSatisfies(R15.includes("typography"), ["path"]),
|
|
2591
|
-
R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
|
|
2592
|
-
]);
|
|
2593
|
-
var formatTypographySizeToken = (format, token) => {
|
|
2594
|
-
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
2595
|
-
let calc;
|
|
2596
|
-
let round;
|
|
2597
|
-
if (R15.startsWith(["font-size"], token.path)) {
|
|
2598
|
-
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
2599
|
-
round = `round(${calc}, 1px)`;
|
|
2600
|
-
} else {
|
|
2601
|
-
calc = value;
|
|
2602
|
-
}
|
|
2603
|
-
return { name, calc, round: round ?? calc };
|
|
2604
|
-
};
|
|
2605
|
-
var formatTypographySizeTokens = (format, tokens) => R15.reduce(
|
|
2606
|
-
(acc, token) => {
|
|
2607
|
-
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
2608
|
-
acc.tokens.push(token);
|
|
2609
|
-
acc.calc.push(`${name}: ${calc};`);
|
|
2610
|
-
acc.round.push(`${name}: ${round};`);
|
|
2611
|
-
return acc;
|
|
2612
|
-
},
|
|
2613
|
-
{ tokens: [], calc: [], round: [] },
|
|
2614
|
-
tokens
|
|
2615
|
-
);
|
|
2616
|
-
var typeScale = {
|
|
2617
|
-
name: "ds/css-type-scale",
|
|
2618
|
-
format: async ({ dictionary, file, options, platform }) => {
|
|
2619
|
-
const { outputReferences, usesDtcg } = options;
|
|
2620
|
-
const { selector, layer } = platform;
|
|
2621
|
-
const destination = file.destination;
|
|
2622
|
-
const format = createPropertyFormatter6({
|
|
2623
|
-
outputReferences,
|
|
2624
|
-
dictionary,
|
|
2625
|
-
format: "css",
|
|
2626
|
-
usesDtcg
|
|
2627
|
-
});
|
|
2628
|
-
const filteredTokens = R15.reject(R15.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
2629
|
-
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
2630
|
-
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
2631
|
-
token: formattedTokens.tokens[i],
|
|
2632
|
-
formatted: t
|
|
2633
|
-
}));
|
|
2634
|
-
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2635
|
-
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
2636
|
-
const content = `${selector} {
|
|
2637
|
-
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
2638
|
-
}`;
|
|
2639
|
-
const body = R15.isNotNil(layer) ? `@layer ${layer} {
|
|
2640
|
-
${content}
|
|
2641
|
-
}` : content;
|
|
2642
|
-
return body;
|
|
2643
|
-
}
|
|
2644
|
-
};
|
|
2645
|
-
|
|
2646
|
-
// src/tokens/process/formats/css.ts
|
|
2647
|
-
var formats = {
|
|
2648
|
-
colorScheme,
|
|
2649
|
-
colorCategory,
|
|
2650
|
-
semantic,
|
|
2651
|
-
sizeMode,
|
|
2652
|
-
size,
|
|
2653
|
-
typography,
|
|
2654
|
-
typeScale
|
|
2655
|
-
};
|
|
2656
|
-
|
|
2657
|
-
// src/tokens/process/configs/color.ts
|
|
2658
|
-
var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
|
|
2659
|
-
const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
|
|
2660
|
-
const layer = `ds.theme.color-scheme.${colorScheme2}`;
|
|
2661
|
-
return {
|
|
2662
|
-
preprocessors: ["tokens-studio"],
|
|
2663
|
-
platforms: {
|
|
2664
|
-
css: {
|
|
2665
|
-
// custom
|
|
2666
|
-
colorScheme: colorScheme2,
|
|
2667
|
-
theme,
|
|
2668
|
-
selector,
|
|
2669
|
-
layer,
|
|
2670
|
-
//
|
|
2671
|
-
prefix,
|
|
2672
|
-
buildPath: `${theme}/`,
|
|
2673
|
-
transforms: dsTransformers,
|
|
2674
|
-
files: [
|
|
2675
|
-
{
|
|
2676
|
-
destination: `color-scheme/${colorScheme2}.css`,
|
|
2677
|
-
format: formats.colorScheme.name,
|
|
2678
|
-
filter: (token) => typeEquals("color", token) && !R16.startsWith(["global"], token.path)
|
|
2679
|
-
}
|
|
2680
|
-
],
|
|
2681
|
-
options: {
|
|
2682
|
-
outputReferences: false
|
|
2683
|
-
}
|
|
2684
|
-
}
|
|
2685
|
-
}
|
|
2686
|
-
};
|
|
2687
|
-
};
|
|
2688
|
-
var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, ...permutation }) => {
|
|
2689
|
-
const category = opts.category;
|
|
2690
|
-
const color = category === "builtin" ? opts.color : permutation[`${category}-color`];
|
|
2691
|
-
if (!color) {
|
|
2692
|
-
throw new Error(
|
|
2693
|
-
category === "builtin" ? `Missing color for built-in color ${opts.color}` : `Missing color for category ${category}`
|
|
2694
|
-
);
|
|
2695
|
-
}
|
|
2696
|
-
const layer = `ds.theme.color`;
|
|
2697
|
-
const isRootColor = color === buildOptions?.defaultColor;
|
|
2698
|
-
const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
|
|
2699
|
-
const config = {
|
|
2700
|
-
preprocessors: ["tokens-studio"],
|
|
2701
|
-
platforms: {
|
|
2702
|
-
css: {
|
|
2703
|
-
// custom
|
|
2704
|
-
colorScheme: colorScheme2,
|
|
2705
|
-
theme,
|
|
2706
|
-
selector,
|
|
2707
|
-
layer,
|
|
2708
|
-
//
|
|
2709
|
-
prefix,
|
|
2710
|
-
buildPath: `${theme}/`,
|
|
2711
|
-
transforms: dsTransformers,
|
|
2712
|
-
files: [
|
|
2713
|
-
{
|
|
2714
|
-
destination: `color/${color}.css`,
|
|
2715
|
-
format: formats.colorCategory.name,
|
|
2716
|
-
filter: (token) => category === "builtin" ? isSemanticColorToken(token, color) : isColorCategoryToken(token, category)
|
|
2717
|
-
}
|
|
2718
|
-
],
|
|
2719
|
-
options: {
|
|
2720
|
-
outputReferences: true
|
|
2721
|
-
}
|
|
2722
|
-
}
|
|
2723
|
-
}
|
|
2724
|
-
};
|
|
2725
|
-
return config;
|
|
2726
|
-
};
|
|
2727
|
-
|
|
2728
|
-
// src/tokens/process/configs/semantic.ts
|
|
2729
|
-
import * as R17 from "ramda";
|
|
2730
|
-
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
2731
|
-
var semanticVariables = ({ theme }) => {
|
|
2732
|
-
const selector = `:root`;
|
|
2733
|
-
const layer = `ds.theme.semantic`;
|
|
2734
|
-
return {
|
|
2735
|
-
preprocessors: ["tokens-studio"],
|
|
2736
|
-
platforms: {
|
|
2737
|
-
css: {
|
|
2738
|
-
// custom
|
|
2739
|
-
theme,
|
|
2740
|
-
basePxFontSize,
|
|
2741
|
-
selector,
|
|
2742
|
-
layer,
|
|
2743
|
-
//
|
|
2744
|
-
prefix,
|
|
2745
|
-
buildPath: `${theme}/`,
|
|
2746
|
-
transforms: dsTransformers,
|
|
2747
|
-
files: [
|
|
2748
|
-
{
|
|
2749
|
-
destination: `semantic.css`,
|
|
2750
|
-
format: formats.semantic.name,
|
|
2751
|
-
filter: (token) => {
|
|
2752
|
-
const isUwantedToken = R17.anyPass([R17.includes("primitives/global")])(token.filePath);
|
|
2753
|
-
const isPrivateToken = R17.includes("_", token.path);
|
|
2754
|
-
const unwantedPaths = pathStartsWithOneOf(
|
|
2755
|
-
["size", "_size", "font-size", "line-height", "letter-spacing"],
|
|
2756
|
-
token
|
|
2757
|
-
);
|
|
2758
|
-
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
2759
|
-
const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
2760
|
-
return unwantedTokens;
|
|
2761
|
-
}
|
|
2762
|
-
}
|
|
2763
|
-
],
|
|
2764
|
-
options: {
|
|
2765
|
-
outputReferences: (token, options) => {
|
|
2766
|
-
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
2767
|
-
return include && outputReferencesFilter(token, options);
|
|
2768
|
-
}
|
|
2769
|
-
}
|
|
2770
|
-
}
|
|
2771
|
-
}
|
|
2772
|
-
};
|
|
2773
|
-
};
|
|
2774
|
-
|
|
2775
|
-
// src/tokens/process/configs/size.ts
|
|
2776
|
-
import * as R18 from "ramda";
|
|
2777
|
-
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
2778
|
-
var sizeVariables = ({ theme }) => {
|
|
2779
|
-
const selector = `:root, [data-size]`;
|
|
2780
|
-
const layer = `ds.theme.size`;
|
|
2781
|
-
return {
|
|
2782
|
-
preprocessors: ["tokens-studio"],
|
|
2783
|
-
platforms: {
|
|
2784
|
-
css: {
|
|
2785
|
-
// custom
|
|
2786
|
-
theme,
|
|
2787
|
-
basePxFontSize,
|
|
2788
|
-
selector,
|
|
2789
|
-
layer,
|
|
2790
|
-
//
|
|
2791
|
-
prefix,
|
|
2792
|
-
buildPath: `${theme}/`,
|
|
2793
|
-
transforms: dsTransformers,
|
|
2794
|
-
files: [
|
|
2795
|
-
{
|
|
2796
|
-
destination: `size.css`,
|
|
2797
|
-
format: formats.size.name,
|
|
2798
|
-
filter: (token) => {
|
|
2799
|
-
const isUwantedToken = R18.anyPass([R18.includes("primitives/global")])(token.filePath);
|
|
2800
|
-
const isPrivateToken = R18.includes("_", token.path);
|
|
2801
|
-
return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
|
|
2802
|
-
}
|
|
2803
|
-
}
|
|
2804
|
-
],
|
|
2805
|
-
options: {
|
|
2806
|
-
outputReferences: (token, options) => {
|
|
2807
|
-
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
|
|
2808
|
-
return isWantedSize && outputReferencesFilter2(token, options);
|
|
2809
|
-
}
|
|
2810
|
-
}
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
};
|
|
2814
|
-
};
|
|
2815
|
-
|
|
2816
|
-
// src/tokens/process/configs/size-mode.ts
|
|
2817
|
-
import * as R19 from "ramda";
|
|
2818
|
-
var sizeModeVariables = ({ theme, size: size2 }) => {
|
|
2819
|
-
const selector = `:root`;
|
|
2820
|
-
const layer = `ds.theme.size-mode`;
|
|
2821
|
-
return {
|
|
2822
|
-
preprocessors: ["tokens-studio"],
|
|
2823
|
-
platforms: {
|
|
2824
|
-
css: {
|
|
2825
|
-
// custom
|
|
2826
|
-
size: size2,
|
|
2827
|
-
theme,
|
|
2828
|
-
basePxFontSize,
|
|
2829
|
-
selector,
|
|
2830
|
-
layer,
|
|
2831
|
-
//
|
|
2832
|
-
prefix,
|
|
2833
|
-
buildPath: `${theme}/`,
|
|
2834
|
-
transforms: dsTransformers,
|
|
2835
|
-
files: [
|
|
2836
|
-
{
|
|
2837
|
-
destination: `size-mode/${size2}.css`,
|
|
2838
|
-
format: formats.sizeMode.name,
|
|
2839
|
-
filter: (token) => {
|
|
2840
|
-
return R19.equals(["_size", "mode-font-size"], token.path);
|
|
2841
|
-
}
|
|
2842
|
-
}
|
|
2843
|
-
]
|
|
2844
|
-
}
|
|
2845
|
-
}
|
|
2846
|
-
};
|
|
2847
|
-
};
|
|
2848
|
-
|
|
2849
|
-
// src/tokens/process/configs/type-scale.ts
|
|
2850
|
-
var typeScaleVariables = ({ theme }) => {
|
|
2851
|
-
const selector = ":root, [data-size]";
|
|
2852
|
-
const layer = `ds.theme.type-scale`;
|
|
2853
|
-
return {
|
|
2854
|
-
usesDtcg: true,
|
|
2855
|
-
preprocessors: ["tokens-studio"],
|
|
2856
|
-
expand: {
|
|
2857
|
-
include: ["typography"]
|
|
2858
|
-
},
|
|
2859
|
-
platforms: {
|
|
2860
|
-
css: {
|
|
2861
|
-
prefix,
|
|
2862
|
-
selector,
|
|
2863
|
-
layer,
|
|
2864
|
-
buildPath: `${theme}/`,
|
|
2865
|
-
basePxFontSize,
|
|
2866
|
-
transforms: [
|
|
2867
|
-
"name/kebab",
|
|
2868
|
-
"ts/size/px",
|
|
2869
|
-
sizeRem.name,
|
|
2870
|
-
"ts/size/lineheight",
|
|
2871
|
-
"ts/typography/fontWeight",
|
|
2872
|
-
typographyName.name
|
|
2873
|
-
],
|
|
2874
|
-
files: [
|
|
2875
|
-
{
|
|
2876
|
-
destination: `type-scale.css`,
|
|
2877
|
-
format: formats.typeScale.name,
|
|
2878
|
-
filter: (token) => {
|
|
2879
|
-
const included = typeEquals(["typography", "dimension", "fontsize"], token);
|
|
2880
|
-
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
2881
|
-
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
|
|
2882
|
-
}
|
|
2883
|
-
}
|
|
2884
|
-
],
|
|
2885
|
-
options: {
|
|
2886
|
-
outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
|
|
2887
|
-
}
|
|
2888
|
-
}
|
|
2889
|
-
}
|
|
2890
|
-
};
|
|
2891
|
-
};
|
|
2892
|
-
|
|
2893
|
-
// src/tokens/process/configs/typography.ts
|
|
2894
|
-
import { expandTypesMap } from "@tokens-studio/sd-transforms";
|
|
2895
|
-
var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
2896
|
-
const selector = `${typography2 === "primary" ? ":root, " : ""}[data-typography="${typography2}"]`;
|
|
2897
|
-
const layer = `ds.theme.typography.${typography2}`;
|
|
2898
|
-
return {
|
|
2899
|
-
usesDtcg: true,
|
|
2900
|
-
preprocessors: ["tokens-studio"],
|
|
2901
|
-
expand: {
|
|
2902
|
-
include: ["typography"],
|
|
2903
|
-
typesMap: { ...expandTypesMap, typography: { ...expandTypesMap.typography, letterSpacing: "dimension" } }
|
|
2904
|
-
},
|
|
2905
|
-
platforms: {
|
|
2906
|
-
css: {
|
|
2907
|
-
prefix,
|
|
2908
|
-
typography: typography2,
|
|
2909
|
-
selector,
|
|
2910
|
-
layer,
|
|
2911
|
-
buildPath: `${theme}/`,
|
|
2912
|
-
basePxFontSize,
|
|
2913
|
-
transforms: [
|
|
2914
|
-
"name/kebab",
|
|
2915
|
-
"ts/size/px",
|
|
2916
|
-
sizeRem.name,
|
|
2917
|
-
"ts/size/lineheight",
|
|
2918
|
-
"ts/typography/fontWeight",
|
|
2919
|
-
"ts/size/css/letterspacing",
|
|
2920
|
-
typographyName.name
|
|
2921
|
-
],
|
|
2922
|
-
files: [
|
|
2923
|
-
{
|
|
2924
|
-
destination: `typography/${typography2}.css`,
|
|
2925
|
-
format: formats.typography.name,
|
|
2926
|
-
filter: (token) => {
|
|
2927
|
-
const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
|
|
2928
|
-
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
2929
|
-
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
|
|
2930
|
-
}
|
|
2931
|
-
}
|
|
2932
|
-
]
|
|
2933
|
-
}
|
|
2934
|
-
}
|
|
2935
|
-
};
|
|
2936
|
-
};
|
|
2937
|
-
|
|
2938
|
-
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
2939
|
-
import pc2 from "picocolors";
|
|
2940
|
-
import * as R20 from "ramda";
|
|
2941
|
-
|
|
2942
|
-
// src/tokens/process/utils/kebab-case.ts
|
|
2943
|
-
function kebabCase(str) {
|
|
2944
|
-
return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
2945
|
-
}
|
|
2946
|
-
|
|
2947
|
-
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
2948
|
-
var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
2949
|
-
const verboseLogging = buildOptions?.verbose;
|
|
2950
|
-
const grouped$themes = groupThemes(processed$themes);
|
|
2951
|
-
const permutations = permutateThemes(grouped$themes);
|
|
2952
|
-
const ALL_DEPENDENT_ON = ["theme"];
|
|
2953
|
-
const keys3 = R20.keys(grouped$themes);
|
|
2954
|
-
const nonDependentKeys = keys3.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
2955
|
-
if (verboseLogging) {
|
|
2956
|
-
console.log(pc2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
2957
|
-
console.log(pc2.cyan(` (ignoring permutations for ${nonDependentKeys})`));
|
|
2958
|
-
}
|
|
2959
|
-
return permutations.filter((val) => {
|
|
2960
|
-
const filters = nonDependentKeys.map((x) => val.permutation[x] === grouped$themes[x][0].name);
|
|
2961
|
-
return filters.every((x) => x);
|
|
2962
|
-
});
|
|
2963
|
-
};
|
|
2964
|
-
var processed = /* @__PURE__ */ Symbol("Type brand for ProcessedThemeObject");
|
|
2965
|
-
function isProcessed(theme) {
|
|
2966
|
-
return Boolean(theme[processed]);
|
|
2967
|
-
}
|
|
2968
|
-
function processThemeObject(theme) {
|
|
2969
|
-
if (isProcessed(theme)) {
|
|
2970
|
-
return theme;
|
|
2971
|
-
}
|
|
2972
|
-
const result = { ...theme, [processed]: true };
|
|
2973
|
-
if (result.group) {
|
|
2974
|
-
result.group = kebabCase(result.group);
|
|
2975
|
-
}
|
|
2976
|
-
result.name = kebabCase(result.name);
|
|
2977
|
-
return result;
|
|
2978
|
-
}
|
|
2979
|
-
function groupThemes(themes) {
|
|
2980
|
-
const groups = {};
|
|
2981
|
-
for (const theme of themes) {
|
|
2982
|
-
if (theme.group) {
|
|
2983
|
-
const groupKey = theme.group;
|
|
2984
|
-
groups[groupKey] = [...groups[groupKey] ?? [], theme];
|
|
2985
|
-
} else {
|
|
2986
|
-
throw new Error(
|
|
2987
|
-
`Theme ${theme.name} does not have a group property, which is required for multi-dimensional theming.`
|
|
2988
|
-
);
|
|
2989
|
-
}
|
|
2990
|
-
}
|
|
2991
|
-
return groups;
|
|
2992
|
-
}
|
|
2993
|
-
var hasUnknownProps = R20.pipe(R20.values, R20.none(R20.equals("unknown")), R20.not);
|
|
2994
|
-
function permutateThemes(groups) {
|
|
2995
|
-
const separator = "_";
|
|
2996
|
-
const permutations = cartesian(Object.values(groups));
|
|
2997
|
-
const permutatedThemes = permutations.map((perm) => {
|
|
2998
|
-
const permutatedTheme = perm.reduce(
|
|
2999
|
-
(acc, theme) => {
|
|
3000
|
-
const { group, name, selectedTokenSets } = theme;
|
|
3001
|
-
let updatedPermutation = acc.permutation;
|
|
3002
|
-
if (group) {
|
|
3003
|
-
const groupProp = R20.lensProp(group);
|
|
3004
|
-
updatedPermutation = R20.set(groupProp, name, updatedPermutation);
|
|
3005
|
-
}
|
|
3006
|
-
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
3007
|
-
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
3008
|
-
return {
|
|
3009
|
-
permutation: updatedPermutation,
|
|
3010
|
-
name: updatedName,
|
|
3011
|
-
selectedTokenSets: sets
|
|
3012
|
-
};
|
|
3013
|
-
},
|
|
3014
|
-
{
|
|
3015
|
-
name: "",
|
|
3016
|
-
selectedTokenSets: [],
|
|
3017
|
-
permutation: {
|
|
3018
|
-
"color-scheme": "unknown",
|
|
3019
|
-
"main-color": "unknown",
|
|
3020
|
-
"support-color": "unknown",
|
|
3021
|
-
theme: "unknown",
|
|
3022
|
-
semantic: "unknown",
|
|
3023
|
-
size: "unknown",
|
|
3024
|
-
typography: "unknown"
|
|
3025
|
-
}
|
|
3026
|
-
}
|
|
3027
|
-
);
|
|
3028
|
-
if (hasUnknownProps(permutatedTheme)) {
|
|
3029
|
-
throw Error(`Theme ${permutatedTheme.name} has unknown props: ${JSON.stringify(permutatedTheme)}`);
|
|
3030
|
-
}
|
|
3031
|
-
const uniqueTokenSets = new Set(permutatedTheme.selectedTokenSets);
|
|
3032
|
-
return { ...permutatedTheme, selectedTokenSets: Array.from(uniqueTokenSets) };
|
|
3033
|
-
});
|
|
3034
|
-
return permutatedThemes;
|
|
3035
|
-
}
|
|
3036
|
-
function filterTokenSets(tokensets) {
|
|
3037
|
-
return Object.entries(tokensets).filter(([, val]) => val !== TokenSetStatus.DISABLED).sort((a, b) => {
|
|
3038
|
-
if (a[1] === TokenSetStatus.SOURCE && b[1] === TokenSetStatus.ENABLED) {
|
|
3039
|
-
return -1;
|
|
3040
|
-
}
|
|
3041
|
-
if (a[1] === TokenSetStatus.ENABLED && b[1] === TokenSetStatus.SOURCE) {
|
|
3042
|
-
return 1;
|
|
3043
|
-
}
|
|
3044
|
-
return 0;
|
|
3045
|
-
}).map((entry) => entry[0]);
|
|
3046
|
-
}
|
|
3047
|
-
function cartesian(a) {
|
|
3048
|
-
return a.reduce((a2, b) => a2.flatMap((d) => b.map((e) => [d, e].flat())));
|
|
3049
|
-
}
|
|
3050
|
-
var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
|
|
3051
|
-
if (!x.group) {
|
|
3052
|
-
return false;
|
|
3053
|
-
}
|
|
3054
|
-
return colorGroups.includes(x.group);
|
|
3055
|
-
}).map((x) => x.name);
|
|
3056
|
-
|
|
3057
|
-
// src/tokens/process/configs.ts
|
|
3058
|
-
void register(StyleDictionary, { withSDBuiltins: false });
|
|
3059
|
-
StyleDictionary.registerTransform(sizeRem);
|
|
3060
|
-
StyleDictionary.registerTransform(typographyName);
|
|
3061
|
-
StyleDictionary.registerTransform(resolveMath);
|
|
3062
|
-
StyleDictionary.registerTransform(unitless);
|
|
3063
|
-
for (const format of Object.values(formats)) {
|
|
3064
|
-
StyleDictionary.registerFormat(format);
|
|
3065
|
-
}
|
|
3066
|
-
var configs = {
|
|
3067
|
-
colorSchemeVariables,
|
|
3068
|
-
mainColorVariables: colorCategoryVariables({ category: "main" }),
|
|
3069
|
-
supportColorVariables: colorCategoryVariables({ category: "support" }),
|
|
3070
|
-
neutralColorVariables: colorCategoryVariables({ category: "builtin", color: "neutral" }),
|
|
3071
|
-
successColorVariables: colorCategoryVariables({ category: "builtin", color: "success" }),
|
|
3072
|
-
dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
|
|
3073
|
-
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
3074
|
-
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
3075
|
-
sizeModeVariables,
|
|
3076
|
-
sizeVariables,
|
|
3077
|
-
typographyVariables,
|
|
3078
|
-
typeScaleVariables,
|
|
3079
|
-
semanticVariables
|
|
3080
|
-
};
|
|
3081
|
-
var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
|
|
3082
|
-
const { tokensDir, tokenSets } = options;
|
|
3083
|
-
const permutations = getMultidimensionalThemes(processed$themes, dimensions);
|
|
3084
|
-
return permutations.flatMap(({ selectedTokenSets, permutation }) => {
|
|
3085
|
-
const tokenSource = { source: void 0, tokens: {} };
|
|
3086
|
-
if (tokenSets) {
|
|
3087
|
-
for (const tokenSet of selectedTokenSets) {
|
|
3088
|
-
const tokens = tokenSets.get(tokenSet);
|
|
3089
|
-
if (tokens) {
|
|
3090
|
-
const tokensWithFilePath = traverseObj(tokens, (obj) => {
|
|
3091
|
-
if (Object.hasOwn(obj, `$value`) && !obj.filePath) {
|
|
3092
|
-
obj.filePath = tokenSet;
|
|
3093
|
-
}
|
|
3094
|
-
});
|
|
3095
|
-
tokenSource.tokens = R21.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
|
|
3096
|
-
}
|
|
3097
|
-
}
|
|
3098
|
-
} else {
|
|
3099
|
-
tokenSource.source = selectedTokenSets.map((x) => `${tokensDir}/${x}.json`);
|
|
3100
|
-
}
|
|
3101
|
-
const configOrConfigs = getConfig(permutation);
|
|
3102
|
-
const configs_ = Array.isArray(configOrConfigs) ? configOrConfigs : [{ config: configOrConfigs }];
|
|
3103
|
-
const configs2 = configs_.map(({ config, permutationOverrides }) => {
|
|
3104
|
-
return {
|
|
3105
|
-
permutation: { ...permutation, ...permutationOverrides },
|
|
3106
|
-
config: {
|
|
3107
|
-
...config,
|
|
3108
|
-
/** Use official W3C design token format
|
|
3109
|
-
@see https://v4.styledictionary.com/info/dtcg/
|
|
3110
|
-
@see https://design-tokens.github.io/community-group/format/ */
|
|
3111
|
-
usesDtcg: true,
|
|
3112
|
-
log: {
|
|
3113
|
-
...config?.log,
|
|
3114
|
-
verbosity: buildOptions?.verbose ? "verbose" : "silent"
|
|
3115
|
-
},
|
|
3116
|
-
...tokenSource
|
|
3117
|
-
}
|
|
3118
|
-
};
|
|
3119
|
-
});
|
|
3120
|
-
return configs2;
|
|
3121
|
-
}).sort();
|
|
3122
|
-
};
|
|
3123
|
-
|
|
3124
|
-
// src/tokens/process/platform.ts
|
|
3125
|
-
var initResult = {
|
|
3126
|
-
formatted: [],
|
|
3127
|
-
tokens: [],
|
|
3128
|
-
permutation: {
|
|
3129
|
-
"color-scheme": "",
|
|
3130
|
-
"main-color": "",
|
|
3131
|
-
"support-color": "",
|
|
3132
|
-
semantic: "",
|
|
3133
|
-
size: "",
|
|
3134
|
-
theme: "",
|
|
3135
|
-
typography: ""
|
|
3136
|
-
}
|
|
3137
|
-
};
|
|
3138
|
-
var buildOptions = {
|
|
3139
|
-
verbose: false,
|
|
3140
|
-
processed$themes: [],
|
|
3141
|
-
buildTokenFormats: {}
|
|
3142
|
-
};
|
|
3143
|
-
var sd = new StyleDictionary2();
|
|
3144
|
-
var buildConfigs = {
|
|
3145
|
-
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
3146
|
-
sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
|
|
3147
|
-
size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
|
|
3148
|
-
typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
|
|
3149
|
-
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
3150
|
-
"main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
|
|
3151
|
-
"support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
|
|
3152
|
-
"neutral-color": {
|
|
3153
|
-
getConfig: configs.neutralColorVariables,
|
|
3154
|
-
dimensions: ["semantic"],
|
|
3155
|
-
log: ({ permutation: { theme } }) => `${theme} - neutral`
|
|
3156
|
-
},
|
|
3157
|
-
"success-color": {
|
|
3158
|
-
getConfig: configs.successColorVariables,
|
|
3159
|
-
dimensions: ["semantic"],
|
|
3160
|
-
log: ({ permutation: { theme } }) => `${theme} - success`
|
|
3161
|
-
},
|
|
3162
|
-
"danger-color": {
|
|
3163
|
-
getConfig: configs.dangerColorVariables,
|
|
3164
|
-
dimensions: ["semantic"],
|
|
3165
|
-
log: ({ permutation: { theme } }) => `${theme} - danger`
|
|
3166
|
-
},
|
|
3167
|
-
"warning-color": {
|
|
3168
|
-
getConfig: configs.warningColorVariables,
|
|
3169
|
-
dimensions: ["semantic"],
|
|
3170
|
-
log: ({ permutation: { theme } }) => `${theme} - warning`
|
|
3171
|
-
},
|
|
3172
|
-
"info-color": {
|
|
3173
|
-
getConfig: configs.infoColorVariables,
|
|
3174
|
-
dimensions: ["semantic"],
|
|
3175
|
-
log: ({ permutation: { theme } }) => `${theme} - info`
|
|
3176
|
-
},
|
|
3177
|
-
semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] }
|
|
3178
|
-
};
|
|
3179
|
-
async function processPlatform(options) {
|
|
3180
|
-
const { type, processed$themes } = options;
|
|
3181
|
-
const platform = "css";
|
|
3182
|
-
const tokenSets = type === "format" ? options.tokenSets : void 0;
|
|
3183
|
-
const tokensDir = type === "build" ? options.tokensDir : void 0;
|
|
3184
|
-
const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
|
|
3185
|
-
if (UNSAFE_DEFAULT_COLOR) {
|
|
3186
|
-
console.warn(
|
|
3187
|
-
pc3.yellow(
|
|
3188
|
-
`
|
|
3189
|
-
\u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${pc3.blue(UNSAFE_DEFAULT_COLOR)}. This will override the default color.`
|
|
3190
|
-
)
|
|
3191
|
-
);
|
|
3192
|
-
}
|
|
3193
|
-
const UNSAFE_COLOR_GROUPS = Array.from(process.env.UNSAFE_COLOR_GROUPS?.split(",") ?? []);
|
|
3194
|
-
if (UNSAFE_COLOR_GROUPS.length > 0) {
|
|
3195
|
-
console.warn(
|
|
3196
|
-
pc3.yellow(
|
|
3197
|
-
`
|
|
3198
|
-
\u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${pc3.blue(`[${UNSAFE_COLOR_GROUPS.join(", ")}]`)}. This will override the default color groups.`
|
|
3199
|
-
)
|
|
3200
|
-
);
|
|
3201
|
-
}
|
|
3202
|
-
const colorGroups = UNSAFE_COLOR_GROUPS.length > 0 ? UNSAFE_COLOR_GROUPS : [colorCategories.main, colorCategories.support].map((c) => `${c}-color`);
|
|
3203
|
-
buildOptions = options;
|
|
3204
|
-
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
3205
|
-
buildOptions.colorGroups = colorGroups;
|
|
3206
|
-
if (!buildOptions.defaultColor) {
|
|
3207
|
-
const customColors = getCustomColors(processed$themes, colorGroups);
|
|
3208
|
-
const firstMainColor = R22.head(customColors);
|
|
3209
|
-
buildOptions.defaultColor = firstMainColor;
|
|
3210
|
-
}
|
|
3211
|
-
if (buildOptions.defaultColor) {
|
|
3212
|
-
console.log(`
|
|
3213
|
-
\u{1F3A8} Using ${pc3.blue(buildOptions.defaultColor)} as default color`);
|
|
3214
|
-
}
|
|
3215
|
-
const sizeModes2 = processed$themes.filter((x) => x.group === "size").map((x) => x.name);
|
|
3216
|
-
buildOptions.sizeModes = sizeModes2;
|
|
3217
|
-
if (!buildOptions.defaultSize) {
|
|
3218
|
-
const defaultSize = R22.head(sizeModes2);
|
|
3219
|
-
buildOptions.defaultSize = defaultSize;
|
|
3220
|
-
}
|
|
3221
|
-
if (buildOptions.defaultSize) {
|
|
3222
|
-
console.log(`
|
|
3223
|
-
\u{1F4CF} Using ${pc3.blue(buildOptions.defaultSize)} as default size`);
|
|
3224
|
-
}
|
|
3225
|
-
const buildAndSdConfigs = R22.map((buildConfig) => {
|
|
3226
|
-
const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
|
|
3227
|
-
tokensDir,
|
|
3228
|
-
tokenSets
|
|
3229
|
-
});
|
|
3230
|
-
const unknownConfigs = buildConfig.dimensions.map(
|
|
3231
|
-
(dimension) => sdConfigs.filter((x) => x.permutation[dimension] === "unknown")
|
|
3232
|
-
);
|
|
3233
|
-
for (const unknowns of unknownConfigs) {
|
|
3234
|
-
if (unknowns.length === sdConfigs.length) {
|
|
3235
|
-
buildConfig.enabled = () => false;
|
|
3236
|
-
}
|
|
3237
|
-
}
|
|
3238
|
-
return {
|
|
3239
|
-
buildConfig,
|
|
3240
|
-
sdConfigs
|
|
3241
|
-
};
|
|
3242
|
-
}, buildConfigs);
|
|
3243
|
-
const processedBuilds = {
|
|
3244
|
-
"color-scheme": [initResult],
|
|
3245
|
-
"main-color": [initResult],
|
|
3246
|
-
"support-color": [initResult],
|
|
3247
|
-
"neutral-color": [initResult],
|
|
3248
|
-
"success-color": [initResult],
|
|
3249
|
-
"danger-color": [initResult],
|
|
3250
|
-
"warning-color": [initResult],
|
|
3251
|
-
"info-color": [initResult],
|
|
3252
|
-
semantic: [initResult],
|
|
3253
|
-
typography: [initResult],
|
|
3254
|
-
sizeMode: [initResult],
|
|
3255
|
-
size: [initResult],
|
|
3256
|
-
typeScale: [initResult]
|
|
3257
|
-
};
|
|
3258
|
-
try {
|
|
3259
|
-
for (const [buildName, { buildConfig, sdConfigs }] of R22.toPairs(buildAndSdConfigs)) {
|
|
3260
|
-
if (!(buildConfig.enabled?.() ?? true)) {
|
|
3261
|
-
continue;
|
|
3262
|
-
}
|
|
3263
|
-
if (sdConfigs.length > 0) {
|
|
3264
|
-
console.log(`
|
|
3265
|
-
\u{1F371} Building ${pc3.green(buildConfig.name ?? buildName)}`);
|
|
3266
|
-
const results = await Promise.all(
|
|
3267
|
-
sdConfigs.map(async (sdConfig) => {
|
|
3268
|
-
const { config, permutation } = sdConfig;
|
|
3269
|
-
const modes = ["theme", ...buildConfig.dimensions];
|
|
3270
|
-
const modeMessage = modes.map((x) => permutation[x]).join(" - ");
|
|
3271
|
-
const logMessage = R22.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
|
|
3272
|
-
console.log(logMessage);
|
|
3273
|
-
const sdOptions = { cache: true };
|
|
3274
|
-
const sdExtended = await sd.extend(config);
|
|
3275
|
-
const formatted = await sdExtended.formatPlatform(platform, sdOptions);
|
|
3276
|
-
const tokens = (await sdExtended.getPlatformTokens(platform, sdOptions)).allTokens;
|
|
3277
|
-
const result = {
|
|
3278
|
-
permutation,
|
|
3279
|
-
formatted,
|
|
3280
|
-
tokens
|
|
3281
|
-
};
|
|
3282
|
-
return Promise.resolve(result);
|
|
3283
|
-
})
|
|
3284
|
-
);
|
|
3285
|
-
processedBuilds[buildName] = results;
|
|
3286
|
-
}
|
|
3287
|
-
}
|
|
3288
|
-
} catch (err) {
|
|
3289
|
-
if (err instanceof Error) {
|
|
3290
|
-
err.message = err.message.replace('log.verbosity "verbose" or use ', "");
|
|
3291
|
-
}
|
|
3292
|
-
throw err;
|
|
3293
|
-
}
|
|
3294
|
-
return processedBuilds;
|
|
3295
|
-
}
|
|
3296
|
-
|
|
3297
|
-
// src/tokens/format.ts
|
|
3298
|
-
var formatTokens = async (options) => {
|
|
3299
|
-
const processedBuilds = await processPlatform({
|
|
3300
|
-
type: "format",
|
|
3301
|
-
buildTokenFormats: {},
|
|
3302
|
-
...options
|
|
3303
|
-
});
|
|
3304
|
-
return processedBuilds;
|
|
3305
|
-
};
|
|
3306
|
-
var formatTheme = async (themeConfig) => {
|
|
3307
|
-
const { tokenSets } = await createTokens(themeConfig);
|
|
3308
|
-
const sizeModes2 = ["small", "medium", "large"];
|
|
3309
|
-
const $themes = await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors, sizeModes2);
|
|
3310
|
-
const processed$themes = $themes.map(processThemeObject);
|
|
3311
|
-
const processedBuilds = await formatTokens({
|
|
3312
|
-
tokenSets,
|
|
3313
|
-
processed$themes,
|
|
3314
|
-
verbose: false
|
|
3315
|
-
});
|
|
3316
|
-
return processedBuilds;
|
|
3317
|
-
};
|
|
3318
|
-
var formatThemeCSS = async (themeConfig) => {
|
|
3319
|
-
const processedBuilds = await formatTheme(themeConfig);
|
|
3320
|
-
const themeCSSFiles = createThemeCSSFiles({ processedBuilds });
|
|
3321
|
-
return R23.head(themeCSSFiles)?.output ?? "";
|
|
3322
|
-
};
|
|
3323
|
-
export {
|
|
3324
|
-
formatTheme,
|
|
3325
|
-
formatThemeCSS,
|
|
3326
|
-
formatTokens
|
|
33
|
+
const formatThemeCSS = async (themeConfig) => {
|
|
34
|
+
const themeCSSFiles = createThemeCSSFiles({ processedBuilds: await formatTheme(themeConfig) });
|
|
35
|
+
return R.head(themeCSSFiles)?.output ?? "";
|
|
3327
36
|
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { formatTheme, formatThemeCSS, formatTokens };
|