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