@digdir/designsystemet 1.1.2 → 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 +131 -187
- package/dist/src/index.js +89 -146
- 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 +99 -155
- package/dist/src/tokens/create/generators/$designsystemet.js +7 -7
- package/dist/src/tokens/create/write.js +7 -7
- 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 +89 -146
- package/dist/src/tokens/index.js +89 -146
- 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 +7 -7
- 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 +7 -7
- 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
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type BuildOptions } from './process/platform.js';
|
|
2
|
-
export declare const buildTokens: (options: Omit<BuildOptions, "type" | "processed$themes">) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
2
|
+
export declare const buildTokens: (options: Omit<BuildOptions, "type" | "processed$themes" | "buildTokenFormats">) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
3
3
|
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/tokens/build.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,uBAAuB,CAAC;AAkB3E,eAAO,MAAM,WAAW,GAAU,SAAS,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/tokens/build.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,uBAAuB,CAAC;AAkB3E,eAAO,MAAM,WAAW,GAAU,SAAS,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,kBAAkB,GAAG,mBAAmB,CAAC,2DAsD/G,CAAC"}
|
package/dist/src/tokens/build.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/tokens/build.ts
|
|
2
2
|
import path from "path";
|
|
3
3
|
import chalk6 from "chalk";
|
|
4
|
-
import * as
|
|
4
|
+
import * as R12 from "ramda";
|
|
5
5
|
|
|
6
6
|
// src/utils.ts
|
|
7
7
|
import fs from "fs/promises";
|
|
@@ -48,7 +48,7 @@ import chalk4 from "chalk";
|
|
|
48
48
|
|
|
49
49
|
// src/tokens/process/platform.ts
|
|
50
50
|
import chalk3 from "chalk";
|
|
51
|
-
import * as
|
|
51
|
+
import * as R10 from "ramda";
|
|
52
52
|
import StyleDictionary2 from "style-dictionary";
|
|
53
53
|
|
|
54
54
|
// src/tokens/types.ts
|
|
@@ -59,7 +59,7 @@ var colorCategories = {
|
|
|
59
59
|
|
|
60
60
|
// src/tokens/process/configs.ts
|
|
61
61
|
import { register } from "@tokens-studio/sd-transforms";
|
|
62
|
-
import * as
|
|
62
|
+
import * as R9 from "ramda";
|
|
63
63
|
import StyleDictionary from "style-dictionary";
|
|
64
64
|
|
|
65
65
|
// src/tokens/utils.ts
|
|
@@ -170,7 +170,11 @@ var colorScheme = {
|
|
|
170
170
|
(t) => !isColorCategoryToken(t)
|
|
171
171
|
])
|
|
172
172
|
);
|
|
173
|
-
const
|
|
173
|
+
const formattedMap = filteredAllTokens.map((token) => ({
|
|
174
|
+
token,
|
|
175
|
+
formatted: format(token)
|
|
176
|
+
}));
|
|
177
|
+
const formattedTokens = formattedMap.map(R2.view(R2.lensProp("formatted"))).join("\n");
|
|
174
178
|
const content = `{
|
|
175
179
|
${formattedTokens}
|
|
176
180
|
${colorSchemeProperty}}
|
|
@@ -188,7 +192,8 @@ var colorCategory = {
|
|
|
188
192
|
name: "ds/css-colorcategory",
|
|
189
193
|
format: async ({ dictionary, options, platform }) => {
|
|
190
194
|
const { outputReferences, usesDtcg } = options;
|
|
191
|
-
const { selector, layer } = platform;
|
|
195
|
+
const { selector, layer, files } = platform;
|
|
196
|
+
const destination = files?.[0]?.destination;
|
|
192
197
|
const format = R2.compose(
|
|
193
198
|
createPropertyFormatter({
|
|
194
199
|
outputReferences,
|
|
@@ -205,7 +210,12 @@ var colorCategory = {
|
|
|
205
210
|
}
|
|
206
211
|
})
|
|
207
212
|
);
|
|
208
|
-
const
|
|
213
|
+
const formattedMap = dictionary.allTokens.map((token) => ({
|
|
214
|
+
token,
|
|
215
|
+
formatted: format(token)
|
|
216
|
+
}));
|
|
217
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
218
|
+
const formattedTokens = formattedMap.map(R2.view(R2.lensProp("formatted"))).join("\n");
|
|
209
219
|
const content = `{
|
|
210
220
|
${formattedTokens}
|
|
211
221
|
}
|
|
@@ -236,30 +246,30 @@ var overrideSizingFormula = (format, token) => {
|
|
|
236
246
|
calc
|
|
237
247
|
};
|
|
238
248
|
};
|
|
239
|
-
var formatSizingTokens = (format, tokens) =>
|
|
240
|
-
|
|
241
|
-
(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
249
|
+
var formatSizingTokens = (format, tokens) => R3.reduce(
|
|
250
|
+
(acc, token) => {
|
|
251
|
+
const { round, calc, name } = overrideSizingFormula(format, token);
|
|
252
|
+
return {
|
|
253
|
+
tokens: [...acc.tokens, token],
|
|
254
|
+
round: [...acc.round, `${name}: ${round};`],
|
|
255
|
+
calc: [...acc.calc, `${name}: ${calc};`]
|
|
256
|
+
};
|
|
257
|
+
},
|
|
258
|
+
{ tokens: [], round: [], calc: [] },
|
|
259
|
+
tokens
|
|
260
|
+
);
|
|
261
|
+
var sizingTemplate = ({ round, calc }) => `
|
|
252
262
|
${calc.join("\n")}
|
|
253
263
|
|
|
254
264
|
@supports (width: round(down, .1em, 1px)) {
|
|
255
265
|
${round.join("\n")}
|
|
256
266
|
}`;
|
|
257
|
-
};
|
|
258
267
|
var semantic = {
|
|
259
268
|
name: "ds/css-semantic",
|
|
260
269
|
format: async ({ dictionary, options, platform }) => {
|
|
261
270
|
const { outputReferences, usesDtcg } = options;
|
|
262
|
-
const { selector, layer } = platform;
|
|
271
|
+
const { selector, layer, files } = platform;
|
|
272
|
+
const destination = files?.[0]?.destination;
|
|
263
273
|
const format = createPropertyFormatter2({
|
|
264
274
|
outputReferences,
|
|
265
275
|
dictionary,
|
|
@@ -272,7 +282,18 @@ var semantic = {
|
|
|
272
282
|
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
273
283
|
filteredTokens
|
|
274
284
|
);
|
|
275
|
-
const
|
|
285
|
+
const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
|
|
286
|
+
const formattedMap = restTokens.map((token) => ({
|
|
287
|
+
token,
|
|
288
|
+
formatted: format(token)
|
|
289
|
+
}));
|
|
290
|
+
const formattedSizingMap = formattedSizingTokens.round.map((t, i) => ({
|
|
291
|
+
token: formattedSizingTokens.tokens[i],
|
|
292
|
+
formatted: t
|
|
293
|
+
}));
|
|
294
|
+
buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
|
|
295
|
+
const sizingSnippet = sizingTemplate(formattedSizingTokens);
|
|
296
|
+
const formattedTokens = formattedMap.map(R3.view(R3.lensProp("formatted"))).concat(sizingSnippet);
|
|
276
297
|
const content = `{
|
|
277
298
|
${formattedTokens.join("\n")}
|
|
278
299
|
}
|
|
@@ -297,7 +318,8 @@ var typography = {
|
|
|
297
318
|
name: "ds/css-typography",
|
|
298
319
|
format: async ({ dictionary, options, platform }) => {
|
|
299
320
|
const { outputReferences, usesDtcg } = options;
|
|
300
|
-
const { selector, layer } = platform;
|
|
321
|
+
const { selector, layer, files } = platform;
|
|
322
|
+
const destination = files?.[0]?.destination;
|
|
301
323
|
const format = createPropertyFormatter3({
|
|
302
324
|
outputReferences,
|
|
303
325
|
dictionary,
|
|
@@ -305,7 +327,12 @@ var typography = {
|
|
|
305
327
|
usesDtcg
|
|
306
328
|
});
|
|
307
329
|
const filteredTokens = R4.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
308
|
-
const
|
|
330
|
+
const formattedMap = filteredTokens.map((token) => ({
|
|
331
|
+
token,
|
|
332
|
+
formatted: format(token)
|
|
333
|
+
}));
|
|
334
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
335
|
+
const formattedTokens = formattedMap.map(R4.view(R4.lensProp("formatted"))).join("\n");
|
|
309
336
|
const content = selector ? `${selector} {
|
|
310
337
|
${formattedTokens}
|
|
311
338
|
}` : formattedTokens;
|
|
@@ -512,90 +539,6 @@ var semanticVariables = ({ theme }) => {
|
|
|
512
539
|
};
|
|
513
540
|
};
|
|
514
541
|
|
|
515
|
-
// src/tokens/process/configs/storefront.ts
|
|
516
|
-
import * as R9 from "ramda";
|
|
517
|
-
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
518
|
-
|
|
519
|
-
// src/tokens/process/formats/js-tokens.ts
|
|
520
|
-
import * as R8 from "ramda";
|
|
521
|
-
import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
|
|
522
|
-
var groupByType = R8.groupBy((token) => getType(token));
|
|
523
|
-
var removeUnwatedTokens = R8.pipe(
|
|
524
|
-
R8.reject((token) => isColorCategoryToken(token)),
|
|
525
|
-
R8.reject((token) => R8.any((path2) => path2.startsWith("_"))(token.path))
|
|
526
|
-
);
|
|
527
|
-
var dissocExtensions = R8.pipe(R8.dissoc("$extensions"), R8.dissocPath(["original", "$extensions"]));
|
|
528
|
-
var removeUnwatedProps = R8.map((token) => dissocExtensions(token));
|
|
529
|
-
var toCssVarName = R8.pipe(R8.split(":"), R8.head, R8.trim);
|
|
530
|
-
var jsTokens = {
|
|
531
|
-
name: "ds/js-tokens",
|
|
532
|
-
format: async ({ dictionary, file, options }) => {
|
|
533
|
-
const { usesDtcg, outputReferences } = options;
|
|
534
|
-
const format = createPropertyFormatter4({
|
|
535
|
-
outputReferences,
|
|
536
|
-
dictionary,
|
|
537
|
-
format: "css",
|
|
538
|
-
usesDtcg
|
|
539
|
-
});
|
|
540
|
-
const formatTokens = R8.map((token) => {
|
|
541
|
-
if (pathStartsWithOneOf(["size", "_size"], token)) {
|
|
542
|
-
const { calc, name } = overrideSizingFormula(format, token);
|
|
543
|
-
return {
|
|
544
|
-
...token,
|
|
545
|
-
name: name.trim(),
|
|
546
|
-
$value: calc.trim()
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
return {
|
|
550
|
-
...token,
|
|
551
|
-
name: toCssVarName(format(token))
|
|
552
|
-
};
|
|
553
|
-
});
|
|
554
|
-
const processTokens = R8.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens, groupByType);
|
|
555
|
-
const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
|
|
556
|
-
const content = Object.entries(tokens).map(
|
|
557
|
-
([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
|
|
558
|
-
`
|
|
559
|
-
).join("\n");
|
|
560
|
-
return fileHeader({ file }).then((fileHeaderText) => fileHeaderText + content);
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
// src/tokens/process/configs/storefront.ts
|
|
565
|
-
var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
|
|
566
|
-
return {
|
|
567
|
-
preprocessors: ["tokens-studio"],
|
|
568
|
-
platforms: {
|
|
569
|
-
ts: {
|
|
570
|
-
prefix,
|
|
571
|
-
basePxFontSize,
|
|
572
|
-
transforms: dsTransformers,
|
|
573
|
-
buildPath: `${theme}/`,
|
|
574
|
-
files: [
|
|
575
|
-
{
|
|
576
|
-
destination: `${colorScheme2}.ts`,
|
|
577
|
-
format: jsTokens.name,
|
|
578
|
-
filter: (token) => {
|
|
579
|
-
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R9.includes("semantic", token.filePath))
|
|
580
|
-
return false;
|
|
581
|
-
const isSemanticColor = R9.includes("semantic", token.filePath) && typeEquals(["color"], token);
|
|
582
|
-
const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
|
|
583
|
-
return isSemanticColor || wantedTypes;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
],
|
|
587
|
-
options: {
|
|
588
|
-
outputReferences: (token, options) => {
|
|
589
|
-
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
590
|
-
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
|
|
591
|
-
return (include || isWantedSize) && outputReferencesFilter2(token, options);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
};
|
|
597
|
-
};
|
|
598
|
-
|
|
599
542
|
// src/tokens/process/configs/typography.ts
|
|
600
543
|
import { expandTypesMap } from "@tokens-studio/sd-transforms";
|
|
601
544
|
var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
@@ -622,6 +565,7 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
622
565
|
sizeRem.name,
|
|
623
566
|
"ts/size/lineheight",
|
|
624
567
|
"ts/typography/fontWeight",
|
|
568
|
+
"ts/size/css/letterspacing",
|
|
625
569
|
typographyName.name
|
|
626
570
|
],
|
|
627
571
|
files: [
|
|
@@ -809,13 +753,13 @@ var TypographyValues;
|
|
|
809
753
|
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
810
754
|
import chalk2 from "chalk";
|
|
811
755
|
import { kebabCase } from "change-case";
|
|
812
|
-
import * as
|
|
756
|
+
import * as R8 from "ramda";
|
|
813
757
|
var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
814
758
|
const verboseLogging = buildOptions?.verbose;
|
|
815
759
|
const grouped$themes = groupThemes(processed$themes);
|
|
816
760
|
const permutations = permutateThemes(grouped$themes);
|
|
817
761
|
const ALL_DEPENDENT_ON = ["theme"];
|
|
818
|
-
const keys2 =
|
|
762
|
+
const keys2 = R8.keys(grouped$themes);
|
|
819
763
|
const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
820
764
|
if (verboseLogging) {
|
|
821
765
|
console.log(chalk2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
@@ -855,7 +799,7 @@ function groupThemes(themes) {
|
|
|
855
799
|
}
|
|
856
800
|
return groups;
|
|
857
801
|
}
|
|
858
|
-
var hasUnknownProps =
|
|
802
|
+
var hasUnknownProps = R8.pipe(R8.values, R8.none(R8.equals("unknown")), R8.not);
|
|
859
803
|
function permutateThemes(groups) {
|
|
860
804
|
const separator = "_";
|
|
861
805
|
const permutations = cartesian(Object.values(groups));
|
|
@@ -865,8 +809,8 @@ function permutateThemes(groups) {
|
|
|
865
809
|
const { group, name, selectedTokenSets } = theme;
|
|
866
810
|
let updatedPermutation = acc.permutation;
|
|
867
811
|
if (group) {
|
|
868
|
-
const groupProp =
|
|
869
|
-
updatedPermutation =
|
|
812
|
+
const groupProp = R8.lensProp(group);
|
|
813
|
+
updatedPermutation = R8.set(groupProp, name, updatedPermutation);
|
|
870
814
|
}
|
|
871
815
|
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
872
816
|
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
@@ -925,7 +869,6 @@ StyleDictionary.registerTransform(sizeRem);
|
|
|
925
869
|
StyleDictionary.registerTransform(typographyName);
|
|
926
870
|
StyleDictionary.registerTransform(resolveMath);
|
|
927
871
|
StyleDictionary.registerTransform(unitless);
|
|
928
|
-
StyleDictionary.registerFormat(jsTokens);
|
|
929
872
|
for (const format of Object.values(formats)) {
|
|
930
873
|
StyleDictionary.registerFormat(format);
|
|
931
874
|
}
|
|
@@ -939,8 +882,7 @@ var configs = {
|
|
|
939
882
|
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
940
883
|
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
941
884
|
typographyVariables,
|
|
942
|
-
semanticVariables
|
|
943
|
-
typescriptTokens
|
|
885
|
+
semanticVariables
|
|
944
886
|
};
|
|
945
887
|
var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
|
|
946
888
|
const { tokensDir, tokenSets } = options;
|
|
@@ -956,7 +898,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
956
898
|
obj.filePath = tokenSet;
|
|
957
899
|
}
|
|
958
900
|
});
|
|
959
|
-
tokenSource.tokens =
|
|
901
|
+
tokenSource.tokens = R9.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
|
|
960
902
|
}
|
|
961
903
|
}
|
|
962
904
|
} else {
|
|
@@ -988,6 +930,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
988
930
|
// src/tokens/process/platform.ts
|
|
989
931
|
var initResult = {
|
|
990
932
|
formatted: [],
|
|
933
|
+
tokens: [],
|
|
991
934
|
permutation: {
|
|
992
935
|
"color-scheme": "",
|
|
993
936
|
"main-color": "",
|
|
@@ -998,7 +941,11 @@ var initResult = {
|
|
|
998
941
|
typography: ""
|
|
999
942
|
}
|
|
1000
943
|
};
|
|
1001
|
-
var buildOptions
|
|
944
|
+
var buildOptions = {
|
|
945
|
+
verbose: false,
|
|
946
|
+
processed$themes: [],
|
|
947
|
+
buildTokenFormats: {}
|
|
948
|
+
};
|
|
1002
949
|
var sd = new StyleDictionary2();
|
|
1003
950
|
var buildConfigs = {
|
|
1004
951
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
@@ -1031,19 +978,15 @@ var buildConfigs = {
|
|
|
1031
978
|
log: ({ permutation: { theme } }) => `${theme} - info`
|
|
1032
979
|
},
|
|
1033
980
|
semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] }
|
|
1034
|
-
// storefront: {
|
|
1035
|
-
// name: 'Storefront preview tokens',
|
|
1036
|
-
// getConfig: configs.typescriptTokens,
|
|
1037
|
-
// dimensions: ['color-scheme'],
|
|
1038
|
-
// options: { outPath: path.resolve('../../apps/storefront/tokens') },
|
|
1039
|
-
// enabled: () => buildOptions?.preview ?? false,
|
|
1040
|
-
// },
|
|
1041
981
|
};
|
|
1042
982
|
async function processPlatform(options) {
|
|
1043
983
|
const { type, processed$themes } = options;
|
|
1044
984
|
const platform = "css";
|
|
1045
985
|
const tokenSets = type === "format" ? options.tokenSets : void 0;
|
|
1046
986
|
const tokensDir = type === "build" ? options.tokensDir : void 0;
|
|
987
|
+
const filteredProcessed$themes = processed$themes.filter(
|
|
988
|
+
(theme) => R10.not(theme.group === "size" && theme.name !== "medium")
|
|
989
|
+
);
|
|
1047
990
|
const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
|
|
1048
991
|
if (UNSAFE_DEFAULT_COLOR) {
|
|
1049
992
|
console.warn(
|
|
@@ -1066,19 +1009,16 @@ async function processPlatform(options) {
|
|
|
1066
1009
|
buildOptions = options;
|
|
1067
1010
|
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
1068
1011
|
buildOptions.colorGroups = colorGroups;
|
|
1069
|
-
const filteredProcessed$themes = processed$themes.filter(
|
|
1070
|
-
(theme) => R12.not(theme.group === "size" && theme.name !== "medium")
|
|
1071
|
-
);
|
|
1072
|
-
const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
|
|
1073
1012
|
if (!buildOptions.defaultColor) {
|
|
1074
|
-
const
|
|
1013
|
+
const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
|
|
1014
|
+
const firstMainColor = R10.head(customColors);
|
|
1075
1015
|
buildOptions.defaultColor = firstMainColor;
|
|
1076
1016
|
}
|
|
1077
1017
|
if (buildOptions.defaultColor) {
|
|
1078
1018
|
console.log(`
|
|
1079
1019
|
\u{1F3A8} Using ${chalk3.blue(buildOptions.defaultColor)} as default color`);
|
|
1080
1020
|
}
|
|
1081
|
-
const buildAndSdConfigs =
|
|
1021
|
+
const buildAndSdConfigs = R10.map((buildConfig) => {
|
|
1082
1022
|
const sdConfigs = getConfigsForThemeDimensions(
|
|
1083
1023
|
buildConfig.getConfig,
|
|
1084
1024
|
filteredProcessed$themes,
|
|
@@ -1114,7 +1054,7 @@ async function processPlatform(options) {
|
|
|
1114
1054
|
typography: [initResult]
|
|
1115
1055
|
};
|
|
1116
1056
|
try {
|
|
1117
|
-
for (const [buildName, { buildConfig, sdConfigs }] of
|
|
1057
|
+
for (const [buildName, { buildConfig, sdConfigs }] of R10.toPairs(buildAndSdConfigs)) {
|
|
1118
1058
|
if (!(buildConfig.enabled?.() ?? true)) {
|
|
1119
1059
|
continue;
|
|
1120
1060
|
}
|
|
@@ -1126,13 +1066,16 @@ async function processPlatform(options) {
|
|
|
1126
1066
|
const { config, permutation } = sdConfig;
|
|
1127
1067
|
const modes = ["theme", ...buildConfig.dimensions];
|
|
1128
1068
|
const modeMessage = modes.map((x) => permutation[x]).join(" - ");
|
|
1129
|
-
const logMessage =
|
|
1069
|
+
const logMessage = R10.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
|
|
1130
1070
|
console.log(logMessage);
|
|
1131
1071
|
const sdOptions = { cache: true };
|
|
1132
1072
|
const sdExtended = await sd.extend(config);
|
|
1073
|
+
const formatted = await sdExtended.formatPlatform(platform, sdOptions);
|
|
1074
|
+
const tokens = (await sdExtended.getPlatformTokens(platform, sdOptions)).allTokens;
|
|
1133
1075
|
const result = {
|
|
1134
1076
|
permutation,
|
|
1135
|
-
formatted
|
|
1077
|
+
formatted,
|
|
1078
|
+
tokens
|
|
1136
1079
|
};
|
|
1137
1080
|
return Promise.resolve(result);
|
|
1138
1081
|
})
|
|
@@ -1169,7 +1112,7 @@ import type {} from '@digdir/designsystemet-react/colors';
|
|
|
1169
1112
|
|
|
1170
1113
|
declare module '@digdir/designsystemet-react/colors' {
|
|
1171
1114
|
export interface MainAndSupportColors {
|
|
1172
|
-
${colors.map((color) => ` ${color}: never;`).join("\n")}
|
|
1115
|
+
${colors.map((color) => ` ${color.includes("-") ? `'${color}'` : color}: never;`).join("\n")}
|
|
1173
1116
|
}
|
|
1174
1117
|
}
|
|
1175
1118
|
`.trimStart();
|
|
@@ -1235,16 +1178,16 @@ ${dynamicColors}`;
|
|
|
1235
1178
|
|
|
1236
1179
|
// src/tokens/process/output/theme.ts
|
|
1237
1180
|
import chalk5 from "chalk";
|
|
1238
|
-
import * as
|
|
1181
|
+
import * as R11 from "ramda";
|
|
1239
1182
|
|
|
1240
1183
|
// package.json
|
|
1241
1184
|
var package_default = {
|
|
1242
1185
|
name: "@digdir/designsystemet",
|
|
1243
|
-
version: "1.1.
|
|
1186
|
+
version: "1.1.4",
|
|
1244
1187
|
description: "CLI for Designsystemet",
|
|
1245
1188
|
author: "Designsystemet team",
|
|
1246
1189
|
engines: {
|
|
1247
|
-
node: ">=22.
|
|
1190
|
+
node: ">=22.17.0"
|
|
1248
1191
|
},
|
|
1249
1192
|
repository: {
|
|
1250
1193
|
type: "git",
|
|
@@ -1293,6 +1236,7 @@ var package_default = {
|
|
|
1293
1236
|
"digdir:tokens-build": "pnpm run designsystemet tokens build -t ../../internal/design-tokens -o ../../packages/theme/brand --clean --experimental-tailwind",
|
|
1294
1237
|
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
1295
1238
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
1239
|
+
"update:preview-tokens": "tsx ./src/scripts/update-preview-tokens.ts",
|
|
1296
1240
|
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts && pnpm digdir:tokens-build",
|
|
1297
1241
|
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
1298
1242
|
},
|
|
@@ -1309,9 +1253,9 @@ var package_default = {
|
|
|
1309
1253
|
hsluv: "^1.0.1",
|
|
1310
1254
|
"object-hash": "^3.0.0",
|
|
1311
1255
|
postcss: "^8.5.6",
|
|
1312
|
-
ramda: "^0.
|
|
1313
|
-
"style-dictionary": "^5.0.
|
|
1314
|
-
zod: "^3.25.
|
|
1256
|
+
ramda: "^0.31.3",
|
|
1257
|
+
"style-dictionary": "^5.0.1",
|
|
1258
|
+
zod: "^3.25.74",
|
|
1315
1259
|
"zod-validation-error": "^3.5.2"
|
|
1316
1260
|
},
|
|
1317
1261
|
devDependencies: {
|
|
@@ -1319,8 +1263,7 @@ var package_default = {
|
|
|
1319
1263
|
"@types/apca-w3": "^0.1.3",
|
|
1320
1264
|
"@types/chroma-js": "^3.1.1",
|
|
1321
1265
|
"@types/fs-extra": "^11.0.4",
|
|
1322
|
-
"@types/
|
|
1323
|
-
"@types/node": "^22.15.32",
|
|
1266
|
+
"@types/node": "^22.16.0",
|
|
1324
1267
|
"@types/object-hash": "^3.0.6",
|
|
1325
1268
|
"@types/ramda": "^0.30.2",
|
|
1326
1269
|
"fs-extra": "^11.3.0",
|
|
@@ -1335,16 +1278,16 @@ var package_default = {
|
|
|
1335
1278
|
var defaultFileHeader = `build: v${package_default.version}`;
|
|
1336
1279
|
var createThemeCSSFiles = ({
|
|
1337
1280
|
processedBuilds,
|
|
1338
|
-
fileHeader
|
|
1281
|
+
fileHeader = defaultFileHeader
|
|
1339
1282
|
}) => {
|
|
1340
1283
|
const groupedByTheme = {};
|
|
1341
1284
|
for (const [_, buildResults] of Object.entries(processedBuilds)) {
|
|
1342
1285
|
for (const buildResult of buildResults) {
|
|
1343
1286
|
const themeName = buildResult.permutation.theme;
|
|
1344
1287
|
const newOutputs = buildResult.formatted;
|
|
1345
|
-
if (
|
|
1288
|
+
if (R11.isNotEmpty(newOutputs)) {
|
|
1346
1289
|
const currentOutputs = groupedByTheme[themeName] ?? [];
|
|
1347
|
-
groupedByTheme[themeName] =
|
|
1290
|
+
groupedByTheme[themeName] = R11.concat(currentOutputs, newOutputs);
|
|
1348
1291
|
}
|
|
1349
1292
|
}
|
|
1350
1293
|
}
|
|
@@ -1357,7 +1300,7 @@ var createThemeCSSFiles = ({
|
|
|
1357
1300
|
"typography/primary",
|
|
1358
1301
|
"color/"
|
|
1359
1302
|
];
|
|
1360
|
-
const sortByDefinedOrder =
|
|
1303
|
+
const sortByDefinedOrder = R11.sortBy((file) => {
|
|
1361
1304
|
const filePath = file.destination || "";
|
|
1362
1305
|
const sortIndex = sortOrder.findIndex((sortElement) => {
|
|
1363
1306
|
if (sortElement.endsWith("/")) {
|
|
@@ -1382,17 +1325,17 @@ order may change due to nondeterminism.`.trim()
|
|
|
1382
1325
|
});
|
|
1383
1326
|
const header = `@charset "UTF-8";
|
|
1384
1327
|
/*
|
|
1385
|
-
${
|
|
1328
|
+
${fileHeader}
|
|
1386
1329
|
*/
|
|
1387
1330
|
|
|
1388
1331
|
`;
|
|
1389
|
-
const sortAlphabetically =
|
|
1390
|
-
const pickOutputs =
|
|
1391
|
-
const themeCSSFile =
|
|
1332
|
+
const sortAlphabetically = R11.sort(R11.ascend((x) => x.destination || ""));
|
|
1333
|
+
const pickOutputs = R11.map(R11.view(R11.lensProp("output")));
|
|
1334
|
+
const themeCSSFile = R11.pipe(
|
|
1392
1335
|
sortAlphabetically,
|
|
1393
1336
|
sortByDefinedOrder,
|
|
1394
1337
|
pickOutputs,
|
|
1395
|
-
|
|
1338
|
+
R11.join("\n"),
|
|
1396
1339
|
(content) => header + content
|
|
1397
1340
|
);
|
|
1398
1341
|
const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
|
|
@@ -1432,16 +1375,17 @@ var buildTokens = async (options) => {
|
|
|
1432
1375
|
outDir,
|
|
1433
1376
|
tokensDir,
|
|
1434
1377
|
type: "build",
|
|
1435
|
-
processed$themes
|
|
1378
|
+
processed$themes,
|
|
1379
|
+
buildTokenFormats: {}
|
|
1436
1380
|
});
|
|
1437
|
-
const
|
|
1381
|
+
const fileHeader = R12.join("")([
|
|
1438
1382
|
defaultFileHeader,
|
|
1439
1383
|
$designsystemet ? `
|
|
1440
1384
|
design-tokens: v${$designsystemet.version}` : ""
|
|
1441
1385
|
]);
|
|
1442
1386
|
let files = [];
|
|
1443
1387
|
const declarationFiles = createTypeDeclarationFiles(processed$themes);
|
|
1444
|
-
const cssFiles = createThemeCSSFiles({ processedBuilds, fileHeader
|
|
1388
|
+
const cssFiles = createThemeCSSFiles({ processedBuilds, fileHeader });
|
|
1445
1389
|
files = [...declarationFiles, ...cssFiles];
|
|
1446
1390
|
if (options.tailwind) {
|
|
1447
1391
|
const tailwindFiles = createTailwindCSSFiles(cssFiles);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@digdir/designsystemet",
|
|
4
|
-
version: "1.1.
|
|
4
|
+
version: "1.1.4",
|
|
5
5
|
description: "CLI for Designsystemet",
|
|
6
6
|
author: "Designsystemet team",
|
|
7
7
|
engines: {
|
|
8
|
-
node: ">=22.
|
|
8
|
+
node: ">=22.17.0"
|
|
9
9
|
},
|
|
10
10
|
repository: {
|
|
11
11
|
type: "git",
|
|
@@ -54,6 +54,7 @@ var package_default = {
|
|
|
54
54
|
"digdir:tokens-build": "pnpm run designsystemet tokens build -t ../../internal/design-tokens -o ../../packages/theme/brand --clean --experimental-tailwind",
|
|
55
55
|
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
56
56
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
57
|
+
"update:preview-tokens": "tsx ./src/scripts/update-preview-tokens.ts",
|
|
57
58
|
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts && pnpm digdir:tokens-build",
|
|
58
59
|
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
59
60
|
},
|
|
@@ -70,9 +71,9 @@ var package_default = {
|
|
|
70
71
|
hsluv: "^1.0.1",
|
|
71
72
|
"object-hash": "^3.0.0",
|
|
72
73
|
postcss: "^8.5.6",
|
|
73
|
-
ramda: "^0.
|
|
74
|
-
"style-dictionary": "^5.0.
|
|
75
|
-
zod: "^3.25.
|
|
74
|
+
ramda: "^0.31.3",
|
|
75
|
+
"style-dictionary": "^5.0.1",
|
|
76
|
+
zod: "^3.25.74",
|
|
76
77
|
"zod-validation-error": "^3.5.2"
|
|
77
78
|
},
|
|
78
79
|
devDependencies: {
|
|
@@ -80,8 +81,7 @@ var package_default = {
|
|
|
80
81
|
"@types/apca-w3": "^0.1.3",
|
|
81
82
|
"@types/chroma-js": "^3.1.1",
|
|
82
83
|
"@types/fs-extra": "^11.0.4",
|
|
83
|
-
"@types/
|
|
84
|
-
"@types/node": "^22.15.32",
|
|
84
|
+
"@types/node": "^22.16.0",
|
|
85
85
|
"@types/object-hash": "^3.0.6",
|
|
86
86
|
"@types/ramda": "^0.30.2",
|
|
87
87
|
"fs-extra": "^11.3.0",
|
|
@@ -46,11 +46,11 @@ var readFile = async (path2, dry, allowFileNotFound) => {
|
|
|
46
46
|
// package.json
|
|
47
47
|
var package_default = {
|
|
48
48
|
name: "@digdir/designsystemet",
|
|
49
|
-
version: "1.1.
|
|
49
|
+
version: "1.1.4",
|
|
50
50
|
description: "CLI for Designsystemet",
|
|
51
51
|
author: "Designsystemet team",
|
|
52
52
|
engines: {
|
|
53
|
-
node: ">=22.
|
|
53
|
+
node: ">=22.17.0"
|
|
54
54
|
},
|
|
55
55
|
repository: {
|
|
56
56
|
type: "git",
|
|
@@ -99,6 +99,7 @@ var package_default = {
|
|
|
99
99
|
"digdir:tokens-build": "pnpm run designsystemet tokens build -t ../../internal/design-tokens -o ../../packages/theme/brand --clean --experimental-tailwind",
|
|
100
100
|
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
101
101
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
102
|
+
"update:preview-tokens": "tsx ./src/scripts/update-preview-tokens.ts",
|
|
102
103
|
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts && pnpm digdir:tokens-build",
|
|
103
104
|
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
104
105
|
},
|
|
@@ -115,9 +116,9 @@ var package_default = {
|
|
|
115
116
|
hsluv: "^1.0.1",
|
|
116
117
|
"object-hash": "^3.0.0",
|
|
117
118
|
postcss: "^8.5.6",
|
|
118
|
-
ramda: "^0.
|
|
119
|
-
"style-dictionary": "^5.0.
|
|
120
|
-
zod: "^3.25.
|
|
119
|
+
ramda: "^0.31.3",
|
|
120
|
+
"style-dictionary": "^5.0.1",
|
|
121
|
+
zod: "^3.25.74",
|
|
121
122
|
"zod-validation-error": "^3.5.2"
|
|
122
123
|
},
|
|
123
124
|
devDependencies: {
|
|
@@ -125,8 +126,7 @@ var package_default = {
|
|
|
125
126
|
"@types/apca-w3": "^0.1.3",
|
|
126
127
|
"@types/chroma-js": "^3.1.1",
|
|
127
128
|
"@types/fs-extra": "^11.0.4",
|
|
128
|
-
"@types/
|
|
129
|
-
"@types/node": "^22.15.32",
|
|
129
|
+
"@types/node": "^22.16.0",
|
|
130
130
|
"@types/object-hash": "^3.0.6",
|
|
131
131
|
"@types/ramda": "^0.30.2",
|
|
132
132
|
"fs-extra": "^11.3.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type FormatOptions } from './process/platform.js';
|
|
2
2
|
import type { Theme } from './types.js';
|
|
3
|
-
export declare const formatTokens: (options: Omit<FormatOptions, "type">) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
3
|
+
export declare const formatTokens: (options: Omit<FormatOptions, "type" | "buildTokenFormats">) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
4
4
|
export declare const formatTheme: (themeConfig: Theme) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
5
5
|
/**
|
|
6
6
|
* Formats a theme configuration into CSS.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/tokens/format.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,eAAO,MAAM,YAAY,GAAU,SAAS,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/tokens/format.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,eAAO,MAAM,YAAY,GAAU,SAAS,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,mBAAmB,CAAC,2DAQ5F,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,aAAa,KAAK,2DAanD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,aAAa,KAAK,oBAItD,CAAC"}
|