@digdir/designsystemet 1.0.8 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/config.d.ts +3 -3
- package/dist/bin/config.d.ts.map +1 -1
- package/dist/bin/config.js +45 -45
- package/dist/bin/designsystemet.js +827 -748
- package/dist/config.schema.json +4 -4
- package/dist/src/colors/index.d.ts +2 -2
- package/dist/src/colors/index.d.ts.map +1 -1
- package/dist/src/colors/index.js +143 -143
- package/dist/src/colors/theme.d.ts +1 -2
- package/dist/src/colors/theme.d.ts.map +1 -1
- package/dist/src/config.d.ts +6 -21
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +43 -40
- package/dist/src/index.js +418 -430
- package/dist/src/scripts/createJsonSchema.js +23 -24
- package/dist/src/scripts/update-template.d.ts.map +1 -1
- 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 +359 -280
- package/dist/src/tokens/create/generators/$designsystemet.js +16 -15
- package/dist/src/tokens/create/generators/color.js +21 -21
- package/dist/src/tokens/create/write.js +17 -16
- package/dist/src/tokens/create.d.ts +1 -0
- package/dist/src/tokens/create.d.ts.map +1 -1
- package/dist/src/tokens/create.js +22 -21
- package/dist/src/tokens/format.d.ts.map +1 -1
- package/dist/src/tokens/format.js +931 -944
- package/dist/src/tokens/index.d.ts +2 -2
- package/dist/src/tokens/index.d.ts.map +1 -1
- package/dist/src/tokens/index.js +295 -307
- package/dist/src/tokens/process/configs/color.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/color.js +5 -5
- package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/semantic.js +5 -5
- package/dist/src/tokens/process/configs/storefront.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/storefront.js +1 -1
- package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/typography.js +5 -5
- package/dist/src/tokens/process/configs.d.ts.map +1 -1
- package/dist/src/tokens/process/configs.js +5 -5
- package/dist/src/tokens/process/formats/css/color.js +2 -2
- package/dist/src/tokens/process/formats/css/semantic.js +2 -2
- package/dist/src/tokens/process/formats/css/typography.js +1 -1
- package/dist/src/tokens/process/formats/css.js +5 -5
- package/dist/src/tokens/process/formats/js-tokens.js +1 -1
- package/dist/src/tokens/process/output/declarations.d.ts +4 -0
- package/dist/src/tokens/process/output/declarations.d.ts.map +1 -0
- package/dist/src/tokens/process/output/declarations.js +860 -0
- package/dist/src/tokens/process/output/tailwind.d.ts +3 -0
- package/dist/src/tokens/process/output/tailwind.d.ts.map +1 -0
- package/dist/src/tokens/process/output/tailwind.js +59 -0
- package/dist/src/tokens/process/{theme.d.ts → output/theme.d.ts} +2 -2
- package/dist/src/tokens/process/output/theme.d.ts.map +1 -0
- package/dist/src/tokens/process/{theme.js → output/theme.js} +20 -19
- package/dist/src/tokens/process/platform.d.ts +8 -4
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +27 -56
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts +1 -0
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts.map +1 -1
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +12 -5
- package/dist/src/tokens/types.d.ts +1 -1
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/package.json +16 -15
- package/dist/src/tokens/process/theme.d.ts.map +0 -1
package/dist/src/index.js
CHANGED
|
@@ -1,146 +1,3 @@
|
|
|
1
|
-
// src/colors/utils.ts
|
|
2
|
-
import chroma from "chroma-js";
|
|
3
|
-
import Colorjs from "colorjs.io";
|
|
4
|
-
import { Hsluv } from "hsluv";
|
|
5
|
-
var hexToCssHsl = (hex, valuesOnly = false) => {
|
|
6
|
-
const [h, s, l] = chroma(hex).hsl();
|
|
7
|
-
const hRounded = Math.round(h);
|
|
8
|
-
const sRounded = Math.round(s * 100);
|
|
9
|
-
const lRounded = Math.round(l * 100);
|
|
10
|
-
const cssString = `${hRounded},${sRounded}%,${lRounded}%`;
|
|
11
|
-
return valuesOnly ? cssString : `hsl(${cssString})`;
|
|
12
|
-
};
|
|
13
|
-
var hexToHSL = (hex) => {
|
|
14
|
-
const [h, s, l] = chroma(hex).hsl();
|
|
15
|
-
return [Math.round(h), Math.round(s * 100), Math.round(l * 100)];
|
|
16
|
-
};
|
|
17
|
-
var hexToHsluv = (hex) => {
|
|
18
|
-
const conv = new Hsluv();
|
|
19
|
-
conv.hex = hex;
|
|
20
|
-
conv.hexToHsluv();
|
|
21
|
-
return [conv.hsluv_h, conv.hsluv_s, conv.hsluv_l];
|
|
22
|
-
};
|
|
23
|
-
var hslArrToCss = (HSL) => {
|
|
24
|
-
return "hsl(" + HSL[0] + "," + HSL[1] + "%," + HSL[2] + "%)";
|
|
25
|
-
};
|
|
26
|
-
var HSLToHex = (h, s, l) => {
|
|
27
|
-
return chroma.hsl(h, s / 100, l / 100).hex();
|
|
28
|
-
};
|
|
29
|
-
var hexToRgb = (hex, type = "255") => {
|
|
30
|
-
const rgb = chroma(hex).rgb();
|
|
31
|
-
return {
|
|
32
|
-
r: type === "255" ? rgb[0] : rgb[0] / 255,
|
|
33
|
-
g: type === "255" ? rgb[1] : rgb[1] / 255,
|
|
34
|
-
b: type === "255" ? rgb[2] : rgb[2] / 255
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
var getContrastFromHex = (color1, color2) => {
|
|
38
|
-
const lum1 = chroma(color1).luminance();
|
|
39
|
-
const lum2 = chroma(color2).luminance();
|
|
40
|
-
return (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);
|
|
41
|
-
};
|
|
42
|
-
var getContrastFromLightness = (lightness, mainColor, backgroundColor) => {
|
|
43
|
-
const conv = new Hsluv();
|
|
44
|
-
conv.hex = mainColor;
|
|
45
|
-
conv.hexToHsluv();
|
|
46
|
-
conv.hsluv_l = lightness;
|
|
47
|
-
conv.hsluvToHex();
|
|
48
|
-
const lightMainColor = conv.hex;
|
|
49
|
-
const lum1 = chroma(lightMainColor).luminance();
|
|
50
|
-
const lum2 = chroma(backgroundColor).luminance();
|
|
51
|
-
const ratio = (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);
|
|
52
|
-
return ratio;
|
|
53
|
-
};
|
|
54
|
-
var areColorsContrasting = (color1, color2, type = "aa") => {
|
|
55
|
-
const contrast = getContrastFromHex(color1, color2);
|
|
56
|
-
if (contrast !== null) {
|
|
57
|
-
if (type === "aaa") {
|
|
58
|
-
return contrast >= 7;
|
|
59
|
-
}
|
|
60
|
-
if (type === "aa") {
|
|
61
|
-
return contrast >= 4.5;
|
|
62
|
-
}
|
|
63
|
-
return contrast >= 3;
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
};
|
|
67
|
-
var isHexColor = (hex) => {
|
|
68
|
-
return typeof hex === "string" && hex.length === 6 && !Number.isNaN(Number("0x" + hex));
|
|
69
|
-
};
|
|
70
|
-
var getLuminanceFromLightness = (lightness) => {
|
|
71
|
-
const conv = new Hsluv();
|
|
72
|
-
conv.hsluv_l = lightness;
|
|
73
|
-
conv.hsluvToHex();
|
|
74
|
-
return chroma(conv.hex).luminance();
|
|
75
|
-
};
|
|
76
|
-
var getLuminanceFromColor = (color) => {
|
|
77
|
-
return chroma(color).luminance();
|
|
78
|
-
};
|
|
79
|
-
var getLightnessFromHex = (hex) => {
|
|
80
|
-
const conv = new Hsluv();
|
|
81
|
-
conv.hex = hex;
|
|
82
|
-
conv.hexToHsluv();
|
|
83
|
-
return conv.hsluv_l;
|
|
84
|
-
};
|
|
85
|
-
var canTextBeUsedOnColors = (baseDefaultColor, baseActiveColor) => {
|
|
86
|
-
const defaultAgainstWhite = getContrastFromHex(baseDefaultColor, "#ffffff");
|
|
87
|
-
const defaultAgainstBlack = getContrastFromHex(baseDefaultColor, "#000000");
|
|
88
|
-
const activeAgainstWhite = getContrastFromHex(baseActiveColor, "#ffffff");
|
|
89
|
-
const activeAgainstBlack = getContrastFromHex(baseActiveColor, "#000000");
|
|
90
|
-
if (defaultAgainstWhite >= 4.5 && activeAgainstWhite >= 4.5) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
if (defaultAgainstBlack >= 4.5 && activeAgainstBlack >= 4.5) {
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
};
|
|
98
|
-
var convertToHex = (color) => {
|
|
99
|
-
if (!color) {
|
|
100
|
-
return "#000000";
|
|
101
|
-
}
|
|
102
|
-
if (/^#[0-9A-Fa-f]{6}$/.test(color)) {
|
|
103
|
-
return color;
|
|
104
|
-
}
|
|
105
|
-
return chroma(color).hex();
|
|
106
|
-
};
|
|
107
|
-
var rgbToHex = (rgb) => {
|
|
108
|
-
return `#${[rgb.r, rgb.g, rgb.b].map((x) => {
|
|
109
|
-
const hex = Math.round(x * 255).toString(16);
|
|
110
|
-
return hex.length === 1 ? "0" + hex : hex;
|
|
111
|
-
}).join("")}`;
|
|
112
|
-
};
|
|
113
|
-
var convertColor = (cssColor, format) => {
|
|
114
|
-
const color = new Colorjs(cssColor);
|
|
115
|
-
switch (format) {
|
|
116
|
-
case "rgb":
|
|
117
|
-
case "rgba":
|
|
118
|
-
return color.toString({
|
|
119
|
-
format: {
|
|
120
|
-
name: format,
|
|
121
|
-
coords: ["<number>[0, 255]", "<number>[0, 255]", "<number>[0, 255]"]
|
|
122
|
-
},
|
|
123
|
-
precision: 3
|
|
124
|
-
});
|
|
125
|
-
case "hex":
|
|
126
|
-
return color.toString({ format, precision: 3 });
|
|
127
|
-
case "hct":
|
|
128
|
-
return color.to(format).toString({
|
|
129
|
-
format: {
|
|
130
|
-
name: format,
|
|
131
|
-
coords: ["<number>", "<number>", "<number>"]
|
|
132
|
-
},
|
|
133
|
-
precision: 3
|
|
134
|
-
});
|
|
135
|
-
default:
|
|
136
|
-
return color.to(format).toString({ precision: 3 });
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
// src/colors/theme.ts
|
|
141
|
-
import chroma2 from "chroma-js";
|
|
142
|
-
import * as R2 from "ramda";
|
|
143
|
-
|
|
144
1
|
// src/colors/colorMetadata.ts
|
|
145
2
|
import * as R from "ramda";
|
|
146
3
|
var baseColors = {
|
|
@@ -397,6 +254,149 @@ var getColorMetadataByNumber = (number) => {
|
|
|
397
254
|
return colorMetadataByNumber[number];
|
|
398
255
|
};
|
|
399
256
|
|
|
257
|
+
// src/colors/theme.ts
|
|
258
|
+
import chroma2 from "chroma-js";
|
|
259
|
+
import * as R2 from "ramda";
|
|
260
|
+
|
|
261
|
+
// src/colors/utils.ts
|
|
262
|
+
import chroma from "chroma-js";
|
|
263
|
+
import Colorjs from "colorjs.io";
|
|
264
|
+
import { Hsluv } from "hsluv";
|
|
265
|
+
var hexToCssHsl = (hex, valuesOnly = false) => {
|
|
266
|
+
const [h, s, l] = chroma(hex).hsl();
|
|
267
|
+
const hRounded = Math.round(h);
|
|
268
|
+
const sRounded = Math.round(s * 100);
|
|
269
|
+
const lRounded = Math.round(l * 100);
|
|
270
|
+
const cssString = `${hRounded},${sRounded}%,${lRounded}%`;
|
|
271
|
+
return valuesOnly ? cssString : `hsl(${cssString})`;
|
|
272
|
+
};
|
|
273
|
+
var hexToHSL = (hex) => {
|
|
274
|
+
const [h, s, l] = chroma(hex).hsl();
|
|
275
|
+
return [Math.round(h), Math.round(s * 100), Math.round(l * 100)];
|
|
276
|
+
};
|
|
277
|
+
var hexToHsluv = (hex) => {
|
|
278
|
+
const conv = new Hsluv();
|
|
279
|
+
conv.hex = hex;
|
|
280
|
+
conv.hexToHsluv();
|
|
281
|
+
return [conv.hsluv_h, conv.hsluv_s, conv.hsluv_l];
|
|
282
|
+
};
|
|
283
|
+
var hslArrToCss = (HSL) => {
|
|
284
|
+
return "hsl(" + HSL[0] + "," + HSL[1] + "%," + HSL[2] + "%)";
|
|
285
|
+
};
|
|
286
|
+
var HSLToHex = (h, s, l) => {
|
|
287
|
+
return chroma.hsl(h, s / 100, l / 100).hex();
|
|
288
|
+
};
|
|
289
|
+
var hexToRgb = (hex, type = "255") => {
|
|
290
|
+
const rgb = chroma(hex).rgb();
|
|
291
|
+
return {
|
|
292
|
+
r: type === "255" ? rgb[0] : rgb[0] / 255,
|
|
293
|
+
g: type === "255" ? rgb[1] : rgb[1] / 255,
|
|
294
|
+
b: type === "255" ? rgb[2] : rgb[2] / 255
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
var getContrastFromHex = (color1, color2) => {
|
|
298
|
+
const lum1 = chroma(color1).luminance();
|
|
299
|
+
const lum2 = chroma(color2).luminance();
|
|
300
|
+
return (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);
|
|
301
|
+
};
|
|
302
|
+
var getContrastFromLightness = (lightness, mainColor, backgroundColor) => {
|
|
303
|
+
const conv = new Hsluv();
|
|
304
|
+
conv.hex = mainColor;
|
|
305
|
+
conv.hexToHsluv();
|
|
306
|
+
conv.hsluv_l = lightness;
|
|
307
|
+
conv.hsluvToHex();
|
|
308
|
+
const lightMainColor = conv.hex;
|
|
309
|
+
const lum1 = chroma(lightMainColor).luminance();
|
|
310
|
+
const lum2 = chroma(backgroundColor).luminance();
|
|
311
|
+
const ratio = (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);
|
|
312
|
+
return ratio;
|
|
313
|
+
};
|
|
314
|
+
var areColorsContrasting = (color1, color2, type = "aa") => {
|
|
315
|
+
const contrast = getContrastFromHex(color1, color2);
|
|
316
|
+
if (contrast !== null) {
|
|
317
|
+
if (type === "aaa") {
|
|
318
|
+
return contrast >= 7;
|
|
319
|
+
}
|
|
320
|
+
if (type === "aa") {
|
|
321
|
+
return contrast >= 4.5;
|
|
322
|
+
}
|
|
323
|
+
return contrast >= 3;
|
|
324
|
+
}
|
|
325
|
+
return false;
|
|
326
|
+
};
|
|
327
|
+
var isHexColor = (hex) => {
|
|
328
|
+
return typeof hex === "string" && hex.length === 6 && !Number.isNaN(Number("0x" + hex));
|
|
329
|
+
};
|
|
330
|
+
var getLuminanceFromLightness = (lightness) => {
|
|
331
|
+
const conv = new Hsluv();
|
|
332
|
+
conv.hsluv_l = lightness;
|
|
333
|
+
conv.hsluvToHex();
|
|
334
|
+
return chroma(conv.hex).luminance();
|
|
335
|
+
};
|
|
336
|
+
var getLuminanceFromColor = (color) => {
|
|
337
|
+
return chroma(color).luminance();
|
|
338
|
+
};
|
|
339
|
+
var getLightnessFromHex = (hex) => {
|
|
340
|
+
const conv = new Hsluv();
|
|
341
|
+
conv.hex = hex;
|
|
342
|
+
conv.hexToHsluv();
|
|
343
|
+
return conv.hsluv_l;
|
|
344
|
+
};
|
|
345
|
+
var canTextBeUsedOnColors = (baseDefaultColor, baseActiveColor) => {
|
|
346
|
+
const defaultAgainstWhite = getContrastFromHex(baseDefaultColor, "#ffffff");
|
|
347
|
+
const defaultAgainstBlack = getContrastFromHex(baseDefaultColor, "#000000");
|
|
348
|
+
const activeAgainstWhite = getContrastFromHex(baseActiveColor, "#ffffff");
|
|
349
|
+
const activeAgainstBlack = getContrastFromHex(baseActiveColor, "#000000");
|
|
350
|
+
if (defaultAgainstWhite >= 4.5 && activeAgainstWhite >= 4.5) {
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
if (defaultAgainstBlack >= 4.5 && activeAgainstBlack >= 4.5) {
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
return false;
|
|
357
|
+
};
|
|
358
|
+
var convertToHex = (color) => {
|
|
359
|
+
if (!color) {
|
|
360
|
+
return "#000000";
|
|
361
|
+
}
|
|
362
|
+
if (/^#[0-9A-Fa-f]{6}$/.test(color)) {
|
|
363
|
+
return color;
|
|
364
|
+
}
|
|
365
|
+
return chroma(color).hex();
|
|
366
|
+
};
|
|
367
|
+
var rgbToHex = (rgb) => {
|
|
368
|
+
return `#${[rgb.r, rgb.g, rgb.b].map((x) => {
|
|
369
|
+
const hex = Math.round(x * 255).toString(16);
|
|
370
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
371
|
+
}).join("")}`;
|
|
372
|
+
};
|
|
373
|
+
var convertColor = (cssColor, format) => {
|
|
374
|
+
const color = new Colorjs(cssColor);
|
|
375
|
+
switch (format) {
|
|
376
|
+
case "rgb":
|
|
377
|
+
case "rgba":
|
|
378
|
+
return color.toString({
|
|
379
|
+
format: {
|
|
380
|
+
name: format,
|
|
381
|
+
coords: ["<number>[0, 255]", "<number>[0, 255]", "<number>[0, 255]"]
|
|
382
|
+
},
|
|
383
|
+
precision: 3
|
|
384
|
+
});
|
|
385
|
+
case "hex":
|
|
386
|
+
return color.toString({ format, precision: 3 });
|
|
387
|
+
case "hct":
|
|
388
|
+
return color.to(format).toString({
|
|
389
|
+
format: {
|
|
390
|
+
name: format,
|
|
391
|
+
coords: ["<number>", "<number>", "<number>"]
|
|
392
|
+
},
|
|
393
|
+
precision: 3
|
|
394
|
+
});
|
|
395
|
+
default:
|
|
396
|
+
return color.to(format).toString({ precision: 3 });
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
|
|
400
400
|
// src/colors/theme.ts
|
|
401
401
|
var RESERVED_COLORS = [
|
|
402
402
|
"neutral",
|
|
@@ -2186,6 +2186,7 @@ var generateTypography = (themeName, { fontFamily }) => {
|
|
|
2186
2186
|
var cliOptions = {
|
|
2187
2187
|
outDir: "out-dir",
|
|
2188
2188
|
clean: "clean",
|
|
2189
|
+
tailwind: "tailwind",
|
|
2189
2190
|
theme: {
|
|
2190
2191
|
colors: {
|
|
2191
2192
|
main: "main-colors",
|
|
@@ -2562,11 +2563,180 @@ function generateTypographyGroup(themes) {
|
|
|
2562
2563
|
group: "Typography"
|
|
2563
2564
|
}
|
|
2564
2565
|
];
|
|
2565
|
-
}
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
// src/tokens/process/output/theme.ts
|
|
2569
|
+
import chalk from "chalk";
|
|
2570
|
+
import * as R7 from "ramda";
|
|
2571
|
+
|
|
2572
|
+
// package.json
|
|
2573
|
+
var package_default = {
|
|
2574
|
+
name: "@digdir/designsystemet",
|
|
2575
|
+
version: "1.1.1",
|
|
2576
|
+
description: "CLI for Designsystemet",
|
|
2577
|
+
author: "Designsystemet team",
|
|
2578
|
+
engines: {
|
|
2579
|
+
node: ">=22.16.0"
|
|
2580
|
+
},
|
|
2581
|
+
repository: {
|
|
2582
|
+
type: "git",
|
|
2583
|
+
url: "git+https://github.com/digdir/designsystemet.git"
|
|
2584
|
+
},
|
|
2585
|
+
homepage: "https://github.com/digdir/designsystemet/tree/main/packages/cli",
|
|
2586
|
+
license: "MIT",
|
|
2587
|
+
type: "module",
|
|
2588
|
+
main: "./dist/src/index.js",
|
|
2589
|
+
files: [
|
|
2590
|
+
"./dist/**",
|
|
2591
|
+
"./configs/**"
|
|
2592
|
+
],
|
|
2593
|
+
bin: "dist/bin/designsystemet.js",
|
|
2594
|
+
exports: {
|
|
2595
|
+
".": {
|
|
2596
|
+
import: "./dist/src/index.js"
|
|
2597
|
+
},
|
|
2598
|
+
"./color": {
|
|
2599
|
+
import: "./dist/src/colors/index.js"
|
|
2600
|
+
},
|
|
2601
|
+
"./tokens": {
|
|
2602
|
+
import: "./dist/src/tokens/index.js"
|
|
2603
|
+
}
|
|
2604
|
+
},
|
|
2605
|
+
publishConfig: {
|
|
2606
|
+
access: "public"
|
|
2607
|
+
},
|
|
2608
|
+
scripts: {
|
|
2609
|
+
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
2610
|
+
"designsystemet:inspect": "tsx --inspect-brk ./bin/designsystemet.ts",
|
|
2611
|
+
build: "tsup && pnpm build:types && pnpm build:json-schema",
|
|
2612
|
+
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
2613
|
+
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
2614
|
+
types: "tsc --noEmit",
|
|
2615
|
+
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
|
|
2616
|
+
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
|
|
2617
|
+
"test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
|
|
2618
|
+
"test:tokens-build-tailwind": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean --experimental-tailwind",
|
|
2619
|
+
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
2620
|
+
"test:tokens-build-config:inspect": "pnpm run designsystemet:inspect tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
2621
|
+
"test:tokens-build-config-tailwind": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean --experimental-tailwind",
|
|
2622
|
+
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
2623
|
+
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
2624
|
+
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
2625
|
+
"digdir:tokens-build": "pnpm run designsystemet tokens build -t ../../internal/design-tokens -o ../../packages/theme/brand --clean --experimental-tailwind",
|
|
2626
|
+
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
2627
|
+
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
2628
|
+
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts && pnpm digdir:tokens-build",
|
|
2629
|
+
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
2630
|
+
},
|
|
2631
|
+
dependencies: {
|
|
2632
|
+
"@commander-js/extra-typings": "^14.0.0",
|
|
2633
|
+
"@tokens-studio/sd-transforms": "1.3.0",
|
|
2634
|
+
"apca-w3": "^0.1.9",
|
|
2635
|
+
chalk: "^5.4.1",
|
|
2636
|
+
"change-case": "^5.4.4",
|
|
2637
|
+
"chroma-js": "^3.1.2",
|
|
2638
|
+
"colorjs.io": "^0.6.0-alpha.1",
|
|
2639
|
+
commander: "^14.0.0",
|
|
2640
|
+
"fast-glob": "^3.3.3",
|
|
2641
|
+
hsluv: "^1.0.1",
|
|
2642
|
+
"object-hash": "^3.0.0",
|
|
2643
|
+
postcss: "^8.5.6",
|
|
2644
|
+
ramda: "^0.30.1",
|
|
2645
|
+
"style-dictionary": "^5.0.0",
|
|
2646
|
+
zod: "^3.25.67",
|
|
2647
|
+
"zod-validation-error": "^3.5.2"
|
|
2648
|
+
},
|
|
2649
|
+
devDependencies: {
|
|
2650
|
+
"@tokens-studio/types": "0.5.2",
|
|
2651
|
+
"@types/apca-w3": "^0.1.3",
|
|
2652
|
+
"@types/chroma-js": "^3.1.1",
|
|
2653
|
+
"@types/fs-extra": "^11.0.4",
|
|
2654
|
+
"@types/glob": "^8.1.0",
|
|
2655
|
+
"@types/node": "^22.15.32",
|
|
2656
|
+
"@types/object-hash": "^3.0.6",
|
|
2657
|
+
"@types/ramda": "^0.30.2",
|
|
2658
|
+
"fs-extra": "^11.3.0",
|
|
2659
|
+
tslib: "^2.8.1",
|
|
2660
|
+
tsup: "^8.5.0",
|
|
2661
|
+
tsx: "^4.20.3",
|
|
2662
|
+
typescript: "^5.8.3"
|
|
2663
|
+
}
|
|
2664
|
+
};
|
|
2665
|
+
|
|
2666
|
+
// src/tokens/process/output/theme.ts
|
|
2667
|
+
var defaultFileHeader = `build: v${package_default.version}`;
|
|
2668
|
+
var createThemeCSSFiles = ({
|
|
2669
|
+
processedBuilds,
|
|
2670
|
+
fileHeader: fileHeader2 = defaultFileHeader
|
|
2671
|
+
}) => {
|
|
2672
|
+
const groupedByTheme = {};
|
|
2673
|
+
for (const [_, buildResults] of Object.entries(processedBuilds)) {
|
|
2674
|
+
for (const buildResult of buildResults) {
|
|
2675
|
+
const themeName = buildResult.permutation.theme;
|
|
2676
|
+
const newOutputs = buildResult.formatted;
|
|
2677
|
+
if (R7.isNotEmpty(newOutputs)) {
|
|
2678
|
+
const currentOutputs = groupedByTheme[themeName] ?? [];
|
|
2679
|
+
groupedByTheme[themeName] = R7.concat(currentOutputs, newOutputs);
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
const sortOrder = [
|
|
2684
|
+
"color-scheme/light",
|
|
2685
|
+
"typography/secondary",
|
|
2686
|
+
"semantic",
|
|
2687
|
+
"color-scheme/dark",
|
|
2688
|
+
"color-scheme/contrast",
|
|
2689
|
+
"typography/primary",
|
|
2690
|
+
"color/"
|
|
2691
|
+
];
|
|
2692
|
+
const sortByDefinedOrder = R7.sortBy((file) => {
|
|
2693
|
+
const filePath = file.destination || "";
|
|
2694
|
+
const sortIndex = sortOrder.findIndex((sortElement) => {
|
|
2695
|
+
if (sortElement.endsWith("/")) {
|
|
2696
|
+
return filePath.includes(sortElement);
|
|
2697
|
+
}
|
|
2698
|
+
return filePath.includes(`${sortElement}.css`);
|
|
2699
|
+
});
|
|
2700
|
+
if (sortIndex === -1) {
|
|
2701
|
+
console.error(
|
|
2702
|
+
chalk.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
|
|
2703
|
+
);
|
|
2704
|
+
console.log(
|
|
2705
|
+
chalk.dim(
|
|
2706
|
+
`
|
|
2707
|
+
The section will currently be added to the end of the entry file, but the exact
|
|
2708
|
+
order may change due to nondeterminism.`.trim()
|
|
2709
|
+
)
|
|
2710
|
+
);
|
|
2711
|
+
return Infinity;
|
|
2712
|
+
}
|
|
2713
|
+
return sortIndex;
|
|
2714
|
+
});
|
|
2715
|
+
const header = `@charset "UTF-8";
|
|
2716
|
+
/*
|
|
2717
|
+
${fileHeader2}
|
|
2718
|
+
*/
|
|
2719
|
+
|
|
2720
|
+
`;
|
|
2721
|
+
const sortAlphabetically = R7.sort(R7.ascend((x) => x.destination || ""));
|
|
2722
|
+
const pickOutputs = R7.map(R7.view(R7.lensProp("output")));
|
|
2723
|
+
const themeCSSFile = R7.pipe(
|
|
2724
|
+
sortAlphabetically,
|
|
2725
|
+
sortByDefinedOrder,
|
|
2726
|
+
pickOutputs,
|
|
2727
|
+
R7.join("\n"),
|
|
2728
|
+
(content) => header + content
|
|
2729
|
+
);
|
|
2730
|
+
const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
|
|
2731
|
+
destination: `${theme}.css`,
|
|
2732
|
+
output: themeCSSFile(files)
|
|
2733
|
+
}));
|
|
2734
|
+
return themeCSSFiles;
|
|
2735
|
+
};
|
|
2566
2736
|
|
|
2567
2737
|
// src/tokens/process/platform.ts
|
|
2568
|
-
import
|
|
2569
|
-
import * as
|
|
2738
|
+
import chalk3 from "chalk";
|
|
2739
|
+
import * as R19 from "ramda";
|
|
2570
2740
|
import StyleDictionary2 from "style-dictionary";
|
|
2571
2741
|
|
|
2572
2742
|
// src/tokens/types.ts
|
|
@@ -2577,30 +2747,30 @@ var colorCategories = {
|
|
|
2577
2747
|
|
|
2578
2748
|
// src/tokens/process/configs.ts
|
|
2579
2749
|
import { register } from "@tokens-studio/sd-transforms";
|
|
2580
|
-
import * as
|
|
2750
|
+
import * as R18 from "ramda";
|
|
2581
2751
|
import StyleDictionary from "style-dictionary";
|
|
2582
2752
|
|
|
2583
2753
|
// src/tokens/utils.ts
|
|
2584
|
-
import * as
|
|
2585
|
-
var mapToLowerCase =
|
|
2586
|
-
var hasAnyTruth =
|
|
2754
|
+
import * as R8 from "ramda";
|
|
2755
|
+
var mapToLowerCase = R8.map(R8.toLower);
|
|
2756
|
+
var hasAnyTruth = R8.any(R8.equals(true));
|
|
2587
2757
|
var getType = (token) => (token.$type ?? token.type) || "";
|
|
2588
2758
|
var getValue = (token) => token.$value ?? token.value;
|
|
2589
|
-
var typeEquals =
|
|
2759
|
+
var typeEquals = R8.curry(
|
|
2590
2760
|
(types, token) => {
|
|
2591
|
-
if (
|
|
2761
|
+
if (R8.isNil(token)) {
|
|
2592
2762
|
return false;
|
|
2593
2763
|
}
|
|
2594
|
-
return
|
|
2764
|
+
return R8.includes(R8.toLower(getType(token)), R8.map(R8.toLower, Array.isArray(types) ? types : [types]));
|
|
2595
2765
|
}
|
|
2596
2766
|
);
|
|
2597
|
-
var pathStartsWithOneOf =
|
|
2767
|
+
var pathStartsWithOneOf = R8.curry(
|
|
2598
2768
|
(paths, token) => {
|
|
2599
|
-
if (
|
|
2769
|
+
if (R8.isNil(token)) {
|
|
2600
2770
|
return false;
|
|
2601
2771
|
}
|
|
2602
2772
|
const tokenPath = mapToLowerCase(token.path);
|
|
2603
|
-
const matchPathsStartingWith =
|
|
2773
|
+
const matchPathsStartingWith = R8.map((path) => R8.startsWith([path], tokenPath), mapToLowerCase(paths));
|
|
2604
2774
|
return hasAnyTruth(matchPathsStartingWith);
|
|
2605
2775
|
}
|
|
2606
2776
|
);
|
|
@@ -2608,7 +2778,7 @@ function isSemanticToken(token) {
|
|
|
2608
2778
|
return token.filePath.includes("semantic/");
|
|
2609
2779
|
}
|
|
2610
2780
|
function isSemanticColorToken(token, color) {
|
|
2611
|
-
return token.filePath.includes("semantic/") &&
|
|
2781
|
+
return token.filePath.includes("semantic/") && R8.startsWith(["color", color], token.path);
|
|
2612
2782
|
}
|
|
2613
2783
|
function isGlobalColorToken(token) {
|
|
2614
2784
|
return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
|
|
@@ -2619,7 +2789,7 @@ function isColorCategoryToken(token, category) {
|
|
|
2619
2789
|
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
2620
2790
|
);
|
|
2621
2791
|
}
|
|
2622
|
-
return
|
|
2792
|
+
return R8.startsWith(["color", category], token.path);
|
|
2623
2793
|
}
|
|
2624
2794
|
var isDigit = (s) => /^\d+$/.test(s);
|
|
2625
2795
|
function traverseObj(obj, fn) {
|
|
@@ -2635,7 +2805,7 @@ function traverseObj(obj, fn) {
|
|
|
2635
2805
|
return obj;
|
|
2636
2806
|
}
|
|
2637
2807
|
function inlineTokens(shouldInline, tokens) {
|
|
2638
|
-
const [inlineableTokens, otherTokens] =
|
|
2808
|
+
const [inlineableTokens, otherTokens] = R8.partition(shouldInline, tokens);
|
|
2639
2809
|
return otherTokens.map((token) => {
|
|
2640
2810
|
let transformed = getValue(token.original);
|
|
2641
2811
|
for (const ref of inlineableTokens) {
|
|
@@ -2644,16 +2814,16 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
2644
2814
|
transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
|
|
2645
2815
|
}
|
|
2646
2816
|
}
|
|
2647
|
-
const tokenWithInlinedRefs =
|
|
2817
|
+
const tokenWithInlinedRefs = R8.set(R8.lensPath(["original", "$value"]), transformed, token);
|
|
2648
2818
|
return tokenWithInlinedRefs;
|
|
2649
2819
|
});
|
|
2650
2820
|
}
|
|
2651
2821
|
|
|
2652
2822
|
// src/tokens/process/configs/color.ts
|
|
2653
|
-
import * as
|
|
2823
|
+
import * as R13 from "ramda";
|
|
2654
2824
|
|
|
2655
2825
|
// src/tokens/process/formats/css/color.ts
|
|
2656
|
-
import * as
|
|
2826
|
+
import * as R9 from "ramda";
|
|
2657
2827
|
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
2658
2828
|
var prefersColorScheme = (colorScheme2, content) => `
|
|
2659
2829
|
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
@@ -2662,7 +2832,7 @@ var prefersColorScheme = (colorScheme2, content) => `
|
|
|
2662
2832
|
`;
|
|
2663
2833
|
var colorScheme = {
|
|
2664
2834
|
name: "ds/css-colorscheme",
|
|
2665
|
-
format: async ({ dictionary,
|
|
2835
|
+
format: async ({ dictionary, options, platform }) => {
|
|
2666
2836
|
const { allTokens } = dictionary;
|
|
2667
2837
|
const { outputReferences, usesDtcg } = options;
|
|
2668
2838
|
const { selector, colorScheme: colorScheme2, layer } = platform;
|
|
@@ -2677,8 +2847,8 @@ var colorScheme = {
|
|
|
2677
2847
|
color-scheme: ${colorScheme_};
|
|
2678
2848
|
` : "";
|
|
2679
2849
|
const filteredAllTokens = allTokens.filter(
|
|
2680
|
-
|
|
2681
|
-
|
|
2850
|
+
R9.allPass([
|
|
2851
|
+
R9.anyPass([
|
|
2682
2852
|
// Include semantic tokens in the output
|
|
2683
2853
|
isSemanticToken,
|
|
2684
2854
|
// Include global color tokens
|
|
@@ -2694,7 +2864,7 @@ ${formattedTokens}
|
|
|
2694
2864
|
${colorSchemeProperty}}
|
|
2695
2865
|
`;
|
|
2696
2866
|
const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
|
|
2697
|
-
const body =
|
|
2867
|
+
const body = R9.isNotNil(layer) ? `@layer ${layer} {
|
|
2698
2868
|
${selector} ${content} ${autoSelectorContent}
|
|
2699
2869
|
}
|
|
2700
2870
|
` : `${selector} ${content} ${autoSelectorContent}
|
|
@@ -2704,10 +2874,10 @@ ${selector} ${content} ${autoSelectorContent}
|
|
|
2704
2874
|
};
|
|
2705
2875
|
var colorCategory = {
|
|
2706
2876
|
name: "ds/css-colorcategory",
|
|
2707
|
-
format: async ({ dictionary,
|
|
2877
|
+
format: async ({ dictionary, options, platform }) => {
|
|
2708
2878
|
const { outputReferences, usesDtcg } = options;
|
|
2709
2879
|
const { selector, layer } = platform;
|
|
2710
|
-
const format =
|
|
2880
|
+
const format = R9.compose(
|
|
2711
2881
|
createPropertyFormatter({
|
|
2712
2882
|
outputReferences,
|
|
2713
2883
|
dictionary,
|
|
@@ -2728,7 +2898,7 @@ var colorCategory = {
|
|
|
2728
2898
|
${formattedTokens}
|
|
2729
2899
|
}
|
|
2730
2900
|
`;
|
|
2731
|
-
const body =
|
|
2901
|
+
const body = R9.isNotNil(layer) ? `@layer ${layer} {
|
|
2732
2902
|
${selector} ${content}
|
|
2733
2903
|
}
|
|
2734
2904
|
` : `${selector} ${content}
|
|
@@ -2738,16 +2908,16 @@ ${selector} ${content}
|
|
|
2738
2908
|
};
|
|
2739
2909
|
|
|
2740
2910
|
// src/tokens/process/formats/css/semantic.ts
|
|
2741
|
-
import * as
|
|
2911
|
+
import * as R10 from "ramda";
|
|
2742
2912
|
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
2743
2913
|
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
2744
2914
|
var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
|
|
2745
2915
|
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
2746
|
-
var isInlineTokens =
|
|
2916
|
+
var isInlineTokens = R10.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
2747
2917
|
var overrideSizingFormula = (format, token) => {
|
|
2748
2918
|
const [name, value] = format(token).split(":");
|
|
2749
2919
|
const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
|
|
2750
|
-
const round = `round(down, ${calc},
|
|
2920
|
+
const round = `round(down, ${calc}, 1px)`;
|
|
2751
2921
|
return {
|
|
2752
2922
|
name,
|
|
2753
2923
|
round,
|
|
@@ -2755,7 +2925,7 @@ var overrideSizingFormula = (format, token) => {
|
|
|
2755
2925
|
};
|
|
2756
2926
|
};
|
|
2757
2927
|
var formatSizingTokens = (format, tokens) => {
|
|
2758
|
-
const { round, calc } =
|
|
2928
|
+
const { round, calc } = R10.reduce(
|
|
2759
2929
|
(acc, token) => {
|
|
2760
2930
|
const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
|
|
2761
2931
|
return {
|
|
@@ -2775,7 +2945,7 @@ ${round.join("\n")}
|
|
|
2775
2945
|
};
|
|
2776
2946
|
var semantic = {
|
|
2777
2947
|
name: "ds/css-semantic",
|
|
2778
|
-
format: async ({ dictionary,
|
|
2948
|
+
format: async ({ dictionary, options, platform }) => {
|
|
2779
2949
|
const { outputReferences, usesDtcg } = options;
|
|
2780
2950
|
const { selector, layer } = platform;
|
|
2781
2951
|
const format = createPropertyFormatter2({
|
|
@@ -2785,17 +2955,17 @@ var semantic = {
|
|
|
2785
2955
|
usesDtcg
|
|
2786
2956
|
});
|
|
2787
2957
|
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
2788
|
-
const filteredTokens =
|
|
2789
|
-
const [sizingTokens, restTokens] =
|
|
2958
|
+
const filteredTokens = R10.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
|
|
2959
|
+
const [sizingTokens, restTokens] = R10.partition(
|
|
2790
2960
|
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
2791
2961
|
filteredTokens
|
|
2792
2962
|
);
|
|
2793
|
-
const formattedTokens = [
|
|
2963
|
+
const formattedTokens = [R10.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
|
|
2794
2964
|
const content = `{
|
|
2795
2965
|
${formattedTokens.join("\n")}
|
|
2796
2966
|
}
|
|
2797
2967
|
`;
|
|
2798
|
-
const body =
|
|
2968
|
+
const body = R10.isNotNil(layer) ? `@layer ${layer} {
|
|
2799
2969
|
${selector} ${content}
|
|
2800
2970
|
}
|
|
2801
2971
|
` : `${selector} ${content}
|
|
@@ -2805,15 +2975,15 @@ ${selector} ${content}
|
|
|
2805
2975
|
};
|
|
2806
2976
|
|
|
2807
2977
|
// src/tokens/process/formats/css/typography.ts
|
|
2808
|
-
import * as
|
|
2978
|
+
import * as R11 from "ramda";
|
|
2809
2979
|
import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
|
|
2810
|
-
var typographyFontFamilyPredicate =
|
|
2811
|
-
|
|
2812
|
-
|
|
2980
|
+
var typographyFontFamilyPredicate = R11.allPass([
|
|
2981
|
+
R11.pathSatisfies(R11.includes("typography"), ["path"]),
|
|
2982
|
+
R11.pathSatisfies(R11.includes("fontFamily"), ["path"])
|
|
2813
2983
|
]);
|
|
2814
2984
|
var typography = {
|
|
2815
2985
|
name: "ds/css-typography",
|
|
2816
|
-
format: async ({ dictionary,
|
|
2986
|
+
format: async ({ dictionary, options, platform }) => {
|
|
2817
2987
|
const { outputReferences, usesDtcg } = options;
|
|
2818
2988
|
const { selector, layer } = platform;
|
|
2819
2989
|
const format = createPropertyFormatter3({
|
|
@@ -2822,12 +2992,12 @@ var typography = {
|
|
|
2822
2992
|
format: "css",
|
|
2823
2993
|
usesDtcg
|
|
2824
2994
|
});
|
|
2825
|
-
const filteredTokens =
|
|
2826
|
-
const formattedTokens =
|
|
2995
|
+
const filteredTokens = R11.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
2996
|
+
const formattedTokens = R11.pipe(R11.map(format), R11.join("\n"))(filteredTokens);
|
|
2827
2997
|
const content = selector ? `${selector} {
|
|
2828
2998
|
${formattedTokens}
|
|
2829
2999
|
}` : formattedTokens;
|
|
2830
|
-
const body =
|
|
3000
|
+
const body = R11.isNotNil(layer) ? `@layer ${layer} {
|
|
2831
3001
|
${content}
|
|
2832
3002
|
}` : content;
|
|
2833
3003
|
return body;
|
|
@@ -2844,8 +3014,8 @@ var formats = {
|
|
|
2844
3014
|
|
|
2845
3015
|
// src/tokens/process/transformers.ts
|
|
2846
3016
|
import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
|
|
2847
|
-
import * as
|
|
2848
|
-
var isPx =
|
|
3017
|
+
import * as R12 from "ramda";
|
|
3018
|
+
var isPx = R12.test(/\b\d+px\b/g);
|
|
2849
3019
|
var sizeRem = {
|
|
2850
3020
|
name: "ds/size/toRem",
|
|
2851
3021
|
type: "value",
|
|
@@ -2935,7 +3105,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
|
|
|
2935
3105
|
{
|
|
2936
3106
|
destination: `color-scheme/${colorScheme2}.css`,
|
|
2937
3107
|
format: formats.colorScheme.name,
|
|
2938
|
-
filter: (token) => typeEquals("color", token) && !
|
|
3108
|
+
filter: (token) => typeEquals("color", token) && !R13.startsWith(["global"], token.path)
|
|
2939
3109
|
}
|
|
2940
3110
|
],
|
|
2941
3111
|
options: {
|
|
@@ -2986,7 +3156,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
2986
3156
|
};
|
|
2987
3157
|
|
|
2988
3158
|
// src/tokens/process/configs/semantic.ts
|
|
2989
|
-
import * as
|
|
3159
|
+
import * as R14 from "ramda";
|
|
2990
3160
|
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
2991
3161
|
var semanticVariables = ({ theme }) => {
|
|
2992
3162
|
const selector = `:root`;
|
|
@@ -3009,8 +3179,8 @@ var semanticVariables = ({ theme }) => {
|
|
|
3009
3179
|
destination: `semantic.css`,
|
|
3010
3180
|
format: formats.semantic.name,
|
|
3011
3181
|
filter: (token) => {
|
|
3012
|
-
const isUwantedToken =
|
|
3013
|
-
const isPrivateToken =
|
|
3182
|
+
const isUwantedToken = R14.anyPass([R14.includes("primitives/global")])(token.filePath);
|
|
3183
|
+
const isPrivateToken = R14.includes("_", token.path);
|
|
3014
3184
|
const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
|
|
3015
3185
|
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
3016
3186
|
const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
@@ -3031,20 +3201,20 @@ var semanticVariables = ({ theme }) => {
|
|
|
3031
3201
|
};
|
|
3032
3202
|
|
|
3033
3203
|
// src/tokens/process/configs/storefront.ts
|
|
3034
|
-
import * as
|
|
3204
|
+
import * as R16 from "ramda";
|
|
3035
3205
|
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
3036
3206
|
|
|
3037
3207
|
// src/tokens/process/formats/js-tokens.ts
|
|
3038
|
-
import * as
|
|
3208
|
+
import * as R15 from "ramda";
|
|
3039
3209
|
import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
|
|
3040
|
-
var groupByType =
|
|
3041
|
-
var removeUnwatedTokens =
|
|
3042
|
-
|
|
3043
|
-
|
|
3210
|
+
var groupByType = R15.groupBy((token) => getType(token));
|
|
3211
|
+
var removeUnwatedTokens = R15.pipe(
|
|
3212
|
+
R15.reject((token) => isColorCategoryToken(token)),
|
|
3213
|
+
R15.reject((token) => R15.any((path) => path.startsWith("_"))(token.path))
|
|
3044
3214
|
);
|
|
3045
|
-
var dissocExtensions =
|
|
3046
|
-
var removeUnwatedProps =
|
|
3047
|
-
var toCssVarName =
|
|
3215
|
+
var dissocExtensions = R15.pipe(R15.dissoc("$extensions"), R15.dissocPath(["original", "$extensions"]));
|
|
3216
|
+
var removeUnwatedProps = R15.map((token) => dissocExtensions(token));
|
|
3217
|
+
var toCssVarName = R15.pipe(R15.split(":"), R15.head, R15.trim);
|
|
3048
3218
|
var jsTokens = {
|
|
3049
3219
|
name: "ds/js-tokens",
|
|
3050
3220
|
format: async ({ dictionary, file, options }) => {
|
|
@@ -3055,7 +3225,7 @@ var jsTokens = {
|
|
|
3055
3225
|
format: "css",
|
|
3056
3226
|
usesDtcg
|
|
3057
3227
|
});
|
|
3058
|
-
const formatTokens2 =
|
|
3228
|
+
const formatTokens2 = R15.map((token) => {
|
|
3059
3229
|
if (pathStartsWithOneOf(["size", "_size"], token)) {
|
|
3060
3230
|
const { calc, name } = overrideSizingFormula(format, token);
|
|
3061
3231
|
return {
|
|
@@ -3069,7 +3239,7 @@ var jsTokens = {
|
|
|
3069
3239
|
name: toCssVarName(format(token))
|
|
3070
3240
|
};
|
|
3071
3241
|
});
|
|
3072
|
-
const processTokens =
|
|
3242
|
+
const processTokens = R15.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens2, groupByType);
|
|
3073
3243
|
const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
|
|
3074
3244
|
const content = Object.entries(tokens).map(
|
|
3075
3245
|
([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
|
|
@@ -3094,9 +3264,9 @@ var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
|
|
|
3094
3264
|
destination: `${colorScheme2}.ts`,
|
|
3095
3265
|
format: jsTokens.name,
|
|
3096
3266
|
filter: (token) => {
|
|
3097
|
-
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !
|
|
3267
|
+
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R16.includes("semantic", token.filePath))
|
|
3098
3268
|
return false;
|
|
3099
|
-
const isSemanticColor =
|
|
3269
|
+
const isSemanticColor = R16.includes("semantic", token.filePath) && typeEquals(["color"], token);
|
|
3100
3270
|
const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
|
|
3101
3271
|
return isSemanticColor || wantedTypes;
|
|
3102
3272
|
}
|
|
@@ -3162,19 +3332,19 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
3162
3332
|
};
|
|
3163
3333
|
|
|
3164
3334
|
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
3165
|
-
import
|
|
3335
|
+
import chalk2 from "chalk";
|
|
3166
3336
|
import { kebabCase } from "change-case";
|
|
3167
|
-
import * as
|
|
3337
|
+
import * as R17 from "ramda";
|
|
3168
3338
|
var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
3169
3339
|
const verboseLogging = buildOptions?.verbose;
|
|
3170
3340
|
const grouped$themes = groupThemes(processed$themes);
|
|
3171
3341
|
const permutations = permutateThemes(grouped$themes);
|
|
3172
3342
|
const ALL_DEPENDENT_ON = ["theme"];
|
|
3173
|
-
const keys2 =
|
|
3343
|
+
const keys2 = R17.keys(grouped$themes);
|
|
3174
3344
|
const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
3175
3345
|
if (verboseLogging) {
|
|
3176
|
-
console.log(
|
|
3177
|
-
console.log(
|
|
3346
|
+
console.log(chalk2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
3347
|
+
console.log(chalk2.cyan(` (ignoring permutations for ${nonDependentKeys})`));
|
|
3178
3348
|
}
|
|
3179
3349
|
return permutations.filter((val) => {
|
|
3180
3350
|
const filters = nonDependentKeys.map((x) => val.permutation[x] === grouped$themes[x][0].name);
|
|
@@ -3210,7 +3380,7 @@ function groupThemes(themes) {
|
|
|
3210
3380
|
}
|
|
3211
3381
|
return groups;
|
|
3212
3382
|
}
|
|
3213
|
-
var hasUnknownProps =
|
|
3383
|
+
var hasUnknownProps = R17.pipe(R17.values, R17.none(R17.equals("unknown")), R17.not);
|
|
3214
3384
|
function permutateThemes(groups) {
|
|
3215
3385
|
const separator = "_";
|
|
3216
3386
|
const permutations = cartesian(Object.values(groups));
|
|
@@ -3220,8 +3390,8 @@ function permutateThemes(groups) {
|
|
|
3220
3390
|
const { group, name, selectedTokenSets } = theme;
|
|
3221
3391
|
let updatedPermutation = acc.permutation;
|
|
3222
3392
|
if (group) {
|
|
3223
|
-
const groupProp =
|
|
3224
|
-
updatedPermutation =
|
|
3393
|
+
const groupProp = R17.lensProp(group);
|
|
3394
|
+
updatedPermutation = R17.set(groupProp, name, updatedPermutation);
|
|
3225
3395
|
}
|
|
3226
3396
|
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
3227
3397
|
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
@@ -3267,6 +3437,12 @@ function filterTokenSets(tokensets) {
|
|
|
3267
3437
|
function cartesian(a) {
|
|
3268
3438
|
return a.reduce((a2, b) => a2.flatMap((d) => b.map((e) => [d, e].flat())));
|
|
3269
3439
|
}
|
|
3440
|
+
var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
|
|
3441
|
+
if (!x.group) {
|
|
3442
|
+
return false;
|
|
3443
|
+
}
|
|
3444
|
+
return colorGroups.includes(x.group);
|
|
3445
|
+
}).map((x) => x.name);
|
|
3270
3446
|
|
|
3271
3447
|
// src/tokens/process/configs.ts
|
|
3272
3448
|
void register(StyleDictionary, { withSDBuiltins: false });
|
|
@@ -3305,7 +3481,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
3305
3481
|
obj.filePath = tokenSet;
|
|
3306
3482
|
}
|
|
3307
3483
|
});
|
|
3308
|
-
tokenSource.tokens =
|
|
3484
|
+
tokenSource.tokens = R18.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
|
|
3309
3485
|
}
|
|
3310
3486
|
}
|
|
3311
3487
|
} else {
|
|
@@ -3349,12 +3525,6 @@ var initResult = {
|
|
|
3349
3525
|
};
|
|
3350
3526
|
var buildOptions;
|
|
3351
3527
|
var sd = new StyleDictionary2();
|
|
3352
|
-
var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
|
|
3353
|
-
if (!x.group) {
|
|
3354
|
-
return false;
|
|
3355
|
-
}
|
|
3356
|
-
return colorGroups.includes(x.group);
|
|
3357
|
-
}).map((x) => x.name);
|
|
3358
3528
|
var buildConfigs = {
|
|
3359
3529
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
3360
3530
|
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
@@ -3395,46 +3565,54 @@ var buildConfigs = {
|
|
|
3395
3565
|
// },
|
|
3396
3566
|
};
|
|
3397
3567
|
async function processPlatform(options) {
|
|
3398
|
-
const { type, $themes } = options;
|
|
3568
|
+
const { type, processed$themes } = options;
|
|
3399
3569
|
const platform = "css";
|
|
3400
3570
|
const tokenSets = type === "format" ? options.tokenSets : void 0;
|
|
3401
3571
|
const tokensDir = type === "build" ? options.tokensDir : void 0;
|
|
3402
3572
|
const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
|
|
3403
3573
|
if (UNSAFE_DEFAULT_COLOR) {
|
|
3404
3574
|
console.warn(
|
|
3405
|
-
|
|
3575
|
+
chalk3.yellow(
|
|
3406
3576
|
`
|
|
3407
|
-
\u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${
|
|
3577
|
+
\u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${chalk3.blue(UNSAFE_DEFAULT_COLOR)}. This will override the default color.`
|
|
3408
3578
|
)
|
|
3409
3579
|
);
|
|
3410
3580
|
}
|
|
3411
3581
|
const UNSAFE_COLOR_GROUPS = Array.from(process.env.UNSAFE_COLOR_GROUPS?.split(",") ?? []);
|
|
3412
3582
|
if (UNSAFE_COLOR_GROUPS.length > 0) {
|
|
3413
3583
|
console.warn(
|
|
3414
|
-
|
|
3584
|
+
chalk3.yellow(
|
|
3415
3585
|
`
|
|
3416
|
-
\u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${
|
|
3586
|
+
\u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${chalk3.blue(`[${UNSAFE_COLOR_GROUPS.join(", ")}]`)}. This will override the default color groups.`
|
|
3417
3587
|
)
|
|
3418
3588
|
);
|
|
3419
3589
|
}
|
|
3420
3590
|
const colorGroups = UNSAFE_COLOR_GROUPS.length > 0 ? UNSAFE_COLOR_GROUPS : [colorCategories.main, colorCategories.support].map((c) => `${c}-color`);
|
|
3421
3591
|
buildOptions = options;
|
|
3422
3592
|
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
3423
|
-
|
|
3424
|
-
const
|
|
3593
|
+
buildOptions.colorGroups = colorGroups;
|
|
3594
|
+
const filteredProcessed$themes = processed$themes.filter(
|
|
3595
|
+
(theme) => R19.not(theme.group === "size" && theme.name !== "medium")
|
|
3596
|
+
);
|
|
3597
|
+
const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
|
|
3425
3598
|
if (!buildOptions.defaultColor) {
|
|
3426
|
-
const firstMainColor =
|
|
3599
|
+
const firstMainColor = R19.head(customColors);
|
|
3427
3600
|
buildOptions.defaultColor = firstMainColor;
|
|
3428
3601
|
}
|
|
3429
3602
|
if (buildOptions.defaultColor) {
|
|
3430
3603
|
console.log(`
|
|
3431
|
-
\u{1F3A8} Using ${
|
|
3604
|
+
\u{1F3A8} Using ${chalk3.blue(buildOptions.defaultColor)} as default color`);
|
|
3432
3605
|
}
|
|
3433
|
-
const buildAndSdConfigs =
|
|
3434
|
-
const sdConfigs = getConfigsForThemeDimensions(
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3606
|
+
const buildAndSdConfigs = R19.map((buildConfig) => {
|
|
3607
|
+
const sdConfigs = getConfigsForThemeDimensions(
|
|
3608
|
+
buildConfig.getConfig,
|
|
3609
|
+
filteredProcessed$themes,
|
|
3610
|
+
buildConfig.dimensions,
|
|
3611
|
+
{
|
|
3612
|
+
tokensDir,
|
|
3613
|
+
tokenSets
|
|
3614
|
+
}
|
|
3615
|
+
);
|
|
3438
3616
|
const unknownConfigs = buildConfig.dimensions.map(
|
|
3439
3617
|
(dimension) => sdConfigs.filter((x) => x.permutation[dimension] === "unknown")
|
|
3440
3618
|
);
|
|
@@ -3458,23 +3636,22 @@ async function processPlatform(options) {
|
|
|
3458
3636
|
"warning-color": [initResult],
|
|
3459
3637
|
"info-color": [initResult],
|
|
3460
3638
|
semantic: [initResult],
|
|
3461
|
-
typography: [initResult]
|
|
3462
|
-
types: [initResult]
|
|
3639
|
+
typography: [initResult]
|
|
3463
3640
|
};
|
|
3464
3641
|
try {
|
|
3465
|
-
for (const [buildName, { buildConfig, sdConfigs }] of
|
|
3642
|
+
for (const [buildName, { buildConfig, sdConfigs }] of R19.toPairs(buildAndSdConfigs)) {
|
|
3466
3643
|
if (!(buildConfig.enabled?.() ?? true)) {
|
|
3467
3644
|
continue;
|
|
3468
3645
|
}
|
|
3469
3646
|
if (sdConfigs.length > 0) {
|
|
3470
3647
|
console.log(`
|
|
3471
|
-
\u{1F371} Building ${
|
|
3648
|
+
\u{1F371} Building ${chalk3.green(buildConfig.name ?? buildName)}`);
|
|
3472
3649
|
const results = await Promise.all(
|
|
3473
3650
|
sdConfigs.map(async (sdConfig) => {
|
|
3474
3651
|
const { config, permutation } = sdConfig;
|
|
3475
3652
|
const modes = ["theme", ...buildConfig.dimensions];
|
|
3476
3653
|
const modeMessage = modes.map((x) => permutation[x]).join(" - ");
|
|
3477
|
-
const logMessage =
|
|
3654
|
+
const logMessage = R19.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
|
|
3478
3655
|
console.log(logMessage);
|
|
3479
3656
|
const sdOptions = { cache: true };
|
|
3480
3657
|
const sdExtended = await sd.extend(config);
|
|
@@ -3494,198 +3671,8 @@ async function processPlatform(options) {
|
|
|
3494
3671
|
}
|
|
3495
3672
|
throw err;
|
|
3496
3673
|
}
|
|
3497
|
-
const colorsFileName = "colors.d.ts";
|
|
3498
|
-
const reactColorTypes = await createColorTypeDeclaration(customColors);
|
|
3499
|
-
processedBuilds.types = [
|
|
3500
|
-
{
|
|
3501
|
-
...initResult,
|
|
3502
|
-
formatted: [{ output: reactColorTypes, destination: colorsFileName }]
|
|
3503
|
-
}
|
|
3504
|
-
];
|
|
3505
3674
|
return processedBuilds;
|
|
3506
3675
|
}
|
|
3507
|
-
async function createColorTypeDeclaration(colors) {
|
|
3508
|
-
console.log(`
|
|
3509
|
-
\u{1F371} Building ${chalk2.green("type declarations")}`);
|
|
3510
|
-
const typeDeclaration = `
|
|
3511
|
-
import type {} from '@digdir/designsystemet-react/colors';
|
|
3512
|
-
|
|
3513
|
-
declare module '@digdir/designsystemet-react/colors' {
|
|
3514
|
-
export interface MainAndSupportColors {
|
|
3515
|
-
${colors.map((color) => ` ${color}: never;`).join("\n")}
|
|
3516
|
-
}
|
|
3517
|
-
}
|
|
3518
|
-
`.trimStart();
|
|
3519
|
-
return typeDeclaration;
|
|
3520
|
-
}
|
|
3521
|
-
|
|
3522
|
-
// src/tokens/process/theme.ts
|
|
3523
|
-
import * as R19 from "ramda";
|
|
3524
|
-
import chalk3 from "chalk";
|
|
3525
|
-
|
|
3526
|
-
// package.json
|
|
3527
|
-
var package_default = {
|
|
3528
|
-
name: "@digdir/designsystemet",
|
|
3529
|
-
version: "1.0.8",
|
|
3530
|
-
description: "CLI for Designsystemet",
|
|
3531
|
-
author: "Designsystemet team",
|
|
3532
|
-
engines: {
|
|
3533
|
-
node: ">=22.16.0"
|
|
3534
|
-
},
|
|
3535
|
-
repository: {
|
|
3536
|
-
type: "git",
|
|
3537
|
-
url: "git+https://github.com/digdir/designsystemet.git"
|
|
3538
|
-
},
|
|
3539
|
-
homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
|
|
3540
|
-
license: "MIT",
|
|
3541
|
-
type: "module",
|
|
3542
|
-
main: "./dist/src/index.js",
|
|
3543
|
-
files: [
|
|
3544
|
-
"./dist/**",
|
|
3545
|
-
"./configs/**"
|
|
3546
|
-
],
|
|
3547
|
-
bin: "dist/bin/designsystemet.js",
|
|
3548
|
-
exports: {
|
|
3549
|
-
".": {
|
|
3550
|
-
import: "./dist/src/index.js"
|
|
3551
|
-
},
|
|
3552
|
-
"./color": {
|
|
3553
|
-
import: "./dist/src/colors/index.js"
|
|
3554
|
-
},
|
|
3555
|
-
"./tokens": {
|
|
3556
|
-
import: "./dist/src/tokens/index.js"
|
|
3557
|
-
}
|
|
3558
|
-
},
|
|
3559
|
-
publishConfig: {
|
|
3560
|
-
access: "public"
|
|
3561
|
-
},
|
|
3562
|
-
scripts: {
|
|
3563
|
-
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
3564
|
-
"build:tokens": "pnpm run designsystemet tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
|
|
3565
|
-
"build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
|
|
3566
|
-
build: "tsup && pnpm build:types && pnpm build:json-schema",
|
|
3567
|
-
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
3568
|
-
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
3569
|
-
types: "tsc --noEmit",
|
|
3570
|
-
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
|
|
3571
|
-
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
|
|
3572
|
-
"test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
|
|
3573
|
-
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
3574
|
-
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
3575
|
-
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
3576
|
-
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
3577
|
-
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
3578
|
-
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
3579
|
-
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
|
|
3580
|
-
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
3581
|
-
},
|
|
3582
|
-
dependencies: {
|
|
3583
|
-
"@commander-js/extra-typings": "^13.1.0",
|
|
3584
|
-
"@tokens-studio/sd-transforms": "1.3.0",
|
|
3585
|
-
"apca-w3": "^0.1.9",
|
|
3586
|
-
chalk: "^5.4.1",
|
|
3587
|
-
"change-case": "^5.4.4",
|
|
3588
|
-
"chroma-js": "^3.1.2",
|
|
3589
|
-
"colorjs.io": "^0.6.0-alpha.1",
|
|
3590
|
-
commander: "^13.1.0",
|
|
3591
|
-
"fast-glob": "^3.3.3",
|
|
3592
|
-
hsluv: "^1.0.1",
|
|
3593
|
-
"object-hash": "^3.0.0",
|
|
3594
|
-
postcss: "^8.5.3",
|
|
3595
|
-
ramda: "^0.30.1",
|
|
3596
|
-
"style-dictionary": "^4.4.0",
|
|
3597
|
-
zod: "^3.25.30",
|
|
3598
|
-
"zod-validation-error": "^3.4.1"
|
|
3599
|
-
},
|
|
3600
|
-
devDependencies: {
|
|
3601
|
-
"@tokens-studio/types": "0.5.2",
|
|
3602
|
-
"@types/apca-w3": "^0.1.3",
|
|
3603
|
-
"@types/chroma-js": "^3.1.1",
|
|
3604
|
-
"@types/fs-extra": "^11.0.4",
|
|
3605
|
-
"@types/glob": "^8.1.0",
|
|
3606
|
-
"@types/jscodeshift": "^0.12.0",
|
|
3607
|
-
"@types/node": "^22.15.21",
|
|
3608
|
-
"@types/object-hash": "^3.0.6",
|
|
3609
|
-
"@types/ramda": "^0.30.2",
|
|
3610
|
-
"fs-extra": "^11.3.0",
|
|
3611
|
-
"ts-toolbelt": "^9.6.0",
|
|
3612
|
-
tslib: "^2.8.1",
|
|
3613
|
-
tsup: "^8.5.0",
|
|
3614
|
-
tsx: "^4.19.4",
|
|
3615
|
-
typescript: "^5.8.3"
|
|
3616
|
-
}
|
|
3617
|
-
};
|
|
3618
|
-
|
|
3619
|
-
// src/tokens/process/theme.ts
|
|
3620
|
-
var defaultFileHeader = `build: v${package_default.version}`;
|
|
3621
|
-
var createThemeCSSFiles = ({
|
|
3622
|
-
processedBuilds,
|
|
3623
|
-
fileHeader: fileHeader2 = defaultFileHeader
|
|
3624
|
-
}) => {
|
|
3625
|
-
const groupedByTheme = {};
|
|
3626
|
-
for (const [_, buildResults] of Object.entries(R19.dissoc("types", processedBuilds))) {
|
|
3627
|
-
for (const buildResult of buildResults) {
|
|
3628
|
-
const themeName = buildResult.permutation.theme;
|
|
3629
|
-
const newOutputs = buildResult.formatted;
|
|
3630
|
-
if (R19.isNotEmpty(newOutputs)) {
|
|
3631
|
-
const currentOutputs = groupedByTheme[themeName] ?? [];
|
|
3632
|
-
groupedByTheme[themeName] = R19.concat(currentOutputs, newOutputs);
|
|
3633
|
-
}
|
|
3634
|
-
}
|
|
3635
|
-
}
|
|
3636
|
-
const sortOrder = [
|
|
3637
|
-
"color-scheme/light",
|
|
3638
|
-
"typography/secondary",
|
|
3639
|
-
"semantic",
|
|
3640
|
-
"color-scheme/dark",
|
|
3641
|
-
"color-scheme/contrast",
|
|
3642
|
-
"typography/primary",
|
|
3643
|
-
"color/"
|
|
3644
|
-
];
|
|
3645
|
-
const sortByDefinedOrder = R19.sortBy((file) => {
|
|
3646
|
-
const filePath = file.destination || "";
|
|
3647
|
-
const sortIndex = sortOrder.findIndex((sortElement) => {
|
|
3648
|
-
if (sortElement.endsWith("/")) {
|
|
3649
|
-
return filePath.includes(sortElement);
|
|
3650
|
-
}
|
|
3651
|
-
return filePath.includes(`${sortElement}.css`);
|
|
3652
|
-
});
|
|
3653
|
-
if (sortIndex === -1) {
|
|
3654
|
-
console.error(
|
|
3655
|
-
chalk3.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
|
|
3656
|
-
);
|
|
3657
|
-
console.log(
|
|
3658
|
-
chalk3.dim(
|
|
3659
|
-
`
|
|
3660
|
-
The section will currently be added to the end of the entry file, but the exact
|
|
3661
|
-
order may change due to nondeterminism.`.trim()
|
|
3662
|
-
)
|
|
3663
|
-
);
|
|
3664
|
-
return Infinity;
|
|
3665
|
-
}
|
|
3666
|
-
return sortIndex;
|
|
3667
|
-
});
|
|
3668
|
-
const header = `@charset "UTF-8";
|
|
3669
|
-
/*
|
|
3670
|
-
${fileHeader2}
|
|
3671
|
-
*/
|
|
3672
|
-
|
|
3673
|
-
`;
|
|
3674
|
-
const sortAlphabetically = R19.sort(R19.ascend((x) => x.destination || ""));
|
|
3675
|
-
const pickOutputs = R19.map(R19.view(R19.lensProp("output")));
|
|
3676
|
-
const themeCSSFile = R19.pipe(
|
|
3677
|
-
sortAlphabetically,
|
|
3678
|
-
sortByDefinedOrder,
|
|
3679
|
-
pickOutputs,
|
|
3680
|
-
R19.join("\n"),
|
|
3681
|
-
(content) => header + content
|
|
3682
|
-
);
|
|
3683
|
-
const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
|
|
3684
|
-
destination: `${theme}.css`,
|
|
3685
|
-
output: themeCSSFile(files)
|
|
3686
|
-
}));
|
|
3687
|
-
return themeCSSFiles;
|
|
3688
|
-
};
|
|
3689
3676
|
|
|
3690
3677
|
// src/tokens/format.ts
|
|
3691
3678
|
var formatTokens = async (options) => {
|
|
@@ -3698,9 +3685,10 @@ var formatTokens = async (options) => {
|
|
|
3698
3685
|
var formatTheme = async (themeConfig) => {
|
|
3699
3686
|
const { tokenSets } = await createTokens(themeConfig);
|
|
3700
3687
|
const $themes = await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors);
|
|
3688
|
+
const processed$themes = $themes.map(processThemeObject);
|
|
3701
3689
|
const processedBuilds = await formatTokens({
|
|
3702
3690
|
tokenSets,
|
|
3703
|
-
$themes,
|
|
3691
|
+
processed$themes,
|
|
3704
3692
|
verbose: false,
|
|
3705
3693
|
preview: false
|
|
3706
3694
|
});
|