@digdir/designsystemet 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configs/digdir.config.json +4 -0
- package/dist/bin/designsystemet.js +488 -166
- package/dist/global-Y35YADVH.json +100 -0
- package/dist/src/index.js +527 -203
- package/dist/src/scripts/update-preview-tokens.js +478 -128
- package/dist/src/tokens/build.js +429 -111
- package/dist/src/tokens/create/defaults.js +27 -23
- package/dist/src/tokens/create/generators/$designsystemet.js +6 -6
- package/dist/src/tokens/create/write.js +6 -6
- package/dist/src/tokens/create.js +27 -23
- package/dist/src/tokens/format.js +527 -203
- package/dist/src/tokens/index.js +527 -203
- package/dist/src/tokens/process/configs/color.js +366 -66
- package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/semantic.js +368 -68
- package/dist/src/tokens/process/configs/shared.js +9 -2
- package/dist/src/tokens/process/configs/size-mode.d.ts +3 -0
- package/dist/src/tokens/process/configs/size-mode.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/size-mode.js +1067 -0
- package/dist/src/tokens/process/configs/size.d.ts +3 -0
- package/dist/src/tokens/process/configs/size.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/size.js +1069 -0
- package/dist/src/tokens/process/configs/type-scale.d.ts +3 -0
- package/dist/src/tokens/process/configs/type-scale.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/type-scale.js +1067 -0
- package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/typography.js +364 -64
- package/dist/src/tokens/process/configs.d.ts +3 -0
- package/dist/src/tokens/process/configs.d.ts.map +1 -1
- package/dist/src/tokens/process/configs.js +373 -71
- package/dist/src/tokens/process/formats/css/color.js +381 -79
- package/dist/src/tokens/process/formats/css/semantic.d.ts +0 -14
- package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/semantic.js +407 -109
- package/dist/src/tokens/process/formats/css/size-mode.d.ts +4 -0
- package/dist/src/tokens/process/formats/css/size-mode.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/size-mode.js +1068 -0
- package/dist/src/tokens/process/formats/css/size.d.ts +17 -0
- package/dist/src/tokens/process/formats/css/size.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/size.js +1069 -0
- package/dist/src/tokens/process/formats/css/type-scale.d.ts +3 -0
- package/dist/src/tokens/process/formats/css/type-scale.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/type-scale.js +1069 -0
- package/dist/src/tokens/process/formats/css/typography.js +365 -63
- package/dist/src/tokens/process/formats/css.d.ts +3 -0
- package/dist/src/tokens/process/formats/css.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css.js +364 -64
- package/dist/src/tokens/process/output/declarations.js +376 -74
- package/dist/src/tokens/process/output/theme.d.ts.map +1 -1
- package/dist/src/tokens/process/output/theme.js +63 -14
- package/dist/src/tokens/process/platform.d.ts +16 -0
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +402 -95
- package/dist/src/tokens/process/transformers.js +9 -2
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +373 -71
- package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +1 -1
- package/dist/src/tokens/utils.d.ts +4 -1
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +24 -1
- package/package.json +6 -6
- package/dist/global-XVXVBKM6.json +0 -96
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import pc4 from "picocolors";
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
var
|
|
7
|
-
$schema: "
|
|
8
|
-
outDir: "
|
|
5
|
+
// configs/digdir.config.json
|
|
6
|
+
var digdir_config_default = {
|
|
7
|
+
$schema: "../dist/config.schema.json",
|
|
8
|
+
outDir: "./temp/digdir/design-tokens",
|
|
9
9
|
clean: true,
|
|
10
10
|
themes: {
|
|
11
|
-
|
|
11
|
+
digdir: {
|
|
12
12
|
colors: {
|
|
13
13
|
main: {
|
|
14
14
|
accent: "#0062BA"
|
|
@@ -24,6 +24,45 @@ var designsystemet_config_default = {
|
|
|
24
24
|
typography: {
|
|
25
25
|
fontFamily: "Inter"
|
|
26
26
|
}
|
|
27
|
+
},
|
|
28
|
+
altinn: {
|
|
29
|
+
colors: {
|
|
30
|
+
main: {
|
|
31
|
+
accent: "#0062BA"
|
|
32
|
+
},
|
|
33
|
+
support: {
|
|
34
|
+
brand1: "#0162BA",
|
|
35
|
+
brand2: "#3F3161",
|
|
36
|
+
brand3: "#E02F4A"
|
|
37
|
+
},
|
|
38
|
+
neutral: "#1E2B3C"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
uutilsynet: {
|
|
42
|
+
colors: {
|
|
43
|
+
main: {
|
|
44
|
+
accent: "#0062BA"
|
|
45
|
+
},
|
|
46
|
+
support: {
|
|
47
|
+
brand1: "#5B60D1",
|
|
48
|
+
brand2: "#FEA769",
|
|
49
|
+
brand3: "#5DA290"
|
|
50
|
+
},
|
|
51
|
+
neutral: "#1E2B3C"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
portal: {
|
|
55
|
+
colors: {
|
|
56
|
+
main: {
|
|
57
|
+
accent: "#38628C"
|
|
58
|
+
},
|
|
59
|
+
support: {
|
|
60
|
+
brand1: "#D9ECFF",
|
|
61
|
+
brand2: "#FFCA99",
|
|
62
|
+
brand3: "#D96C79"
|
|
63
|
+
},
|
|
64
|
+
neutral: "#203040"
|
|
65
|
+
}
|
|
27
66
|
}
|
|
28
67
|
}
|
|
29
68
|
};
|
|
@@ -512,95 +551,99 @@ var global_default = {
|
|
|
512
551
|
_size: {
|
|
513
552
|
"0": {
|
|
514
553
|
$type: "dimension",
|
|
515
|
-
$value: "floor({_size.
|
|
554
|
+
$value: "floor({_size.unit} * 0)"
|
|
516
555
|
},
|
|
517
556
|
"1": {
|
|
518
557
|
$type: "dimension",
|
|
519
|
-
$value: "floor({_size.
|
|
558
|
+
$value: "floor({_size.unit} * 1)"
|
|
520
559
|
},
|
|
521
560
|
"2": {
|
|
522
561
|
$type: "dimension",
|
|
523
|
-
$value: "floor({_size.
|
|
562
|
+
$value: "floor({_size.unit} * 2)"
|
|
524
563
|
},
|
|
525
564
|
"3": {
|
|
526
565
|
$type: "dimension",
|
|
527
|
-
$value: "floor({_size.
|
|
566
|
+
$value: "floor({_size.unit} * 3)"
|
|
528
567
|
},
|
|
529
568
|
"4": {
|
|
530
569
|
$type: "dimension",
|
|
531
|
-
$value: "floor({_size.
|
|
570
|
+
$value: "floor({_size.unit} * 4)"
|
|
532
571
|
},
|
|
533
572
|
"5": {
|
|
534
573
|
$type: "dimension",
|
|
535
|
-
$value: "floor({_size.
|
|
574
|
+
$value: "floor({_size.unit} * 5)"
|
|
536
575
|
},
|
|
537
576
|
"6": {
|
|
538
577
|
$type: "dimension",
|
|
539
|
-
$value: "floor({_size.
|
|
578
|
+
$value: "floor({_size.unit} * 6)"
|
|
540
579
|
},
|
|
541
580
|
"7": {
|
|
542
581
|
$type: "dimension",
|
|
543
|
-
$value: "floor({_size.
|
|
582
|
+
$value: "floor({_size.unit} * 7)"
|
|
544
583
|
},
|
|
545
584
|
"8": {
|
|
546
585
|
$type: "dimension",
|
|
547
|
-
$value: "floor({_size.
|
|
586
|
+
$value: "floor({_size.unit} * 8)"
|
|
548
587
|
},
|
|
549
588
|
"9": {
|
|
550
589
|
$type: "dimension",
|
|
551
|
-
$value: "floor({_size.
|
|
590
|
+
$value: "floor({_size.unit} * 9)"
|
|
552
591
|
},
|
|
553
592
|
"10": {
|
|
554
593
|
$type: "dimension",
|
|
555
|
-
$value: "floor({_size.
|
|
594
|
+
$value: "floor({_size.unit} * 10)"
|
|
556
595
|
},
|
|
557
596
|
"11": {
|
|
558
597
|
$type: "dimension",
|
|
559
|
-
$value: "floor({_size.
|
|
598
|
+
$value: "floor({_size.unit} * 11)"
|
|
560
599
|
},
|
|
561
600
|
"12": {
|
|
562
601
|
$type: "dimension",
|
|
563
|
-
$value: "floor({_size.
|
|
602
|
+
$value: "floor({_size.unit} * 12)"
|
|
564
603
|
},
|
|
565
604
|
"13": {
|
|
566
605
|
$type: "dimension",
|
|
567
|
-
$value: "floor({_size.
|
|
606
|
+
$value: "floor({_size.unit} * 13)"
|
|
568
607
|
},
|
|
569
608
|
"14": {
|
|
570
609
|
$type: "dimension",
|
|
571
|
-
$value: "floor({_size.
|
|
610
|
+
$value: "floor({_size.unit} * 14)"
|
|
572
611
|
},
|
|
573
612
|
"15": {
|
|
574
613
|
$type: "dimension",
|
|
575
|
-
$value: "floor({_size.
|
|
614
|
+
$value: "floor({_size.unit} * 15)"
|
|
576
615
|
},
|
|
577
616
|
"18": {
|
|
578
617
|
$type: "dimension",
|
|
579
|
-
$value: "floor({_size.
|
|
618
|
+
$value: "floor({_size.unit} * 18)"
|
|
580
619
|
},
|
|
581
620
|
"22": {
|
|
582
621
|
$type: "dimension",
|
|
583
|
-
$value: "floor({_size.
|
|
622
|
+
$value: "floor({_size.unit} * 22)"
|
|
584
623
|
},
|
|
585
624
|
"26": {
|
|
586
625
|
$type: "dimension",
|
|
587
|
-
$value: "floor({_size.
|
|
626
|
+
$value: "floor({_size.unit} * 26)"
|
|
588
627
|
},
|
|
589
628
|
"30": {
|
|
590
629
|
$type: "dimension",
|
|
591
|
-
$value: "floor({_size.
|
|
630
|
+
$value: "floor({_size.unit} * 30)"
|
|
592
631
|
},
|
|
593
632
|
"mode-font-size": {
|
|
594
|
-
$type: "
|
|
633
|
+
$type: "number",
|
|
595
634
|
$value: "{size._mode-font-size}"
|
|
596
635
|
},
|
|
597
636
|
base: {
|
|
598
|
-
$type: "
|
|
637
|
+
$type: "number",
|
|
599
638
|
$value: "{size._base}"
|
|
600
639
|
},
|
|
601
640
|
step: {
|
|
602
|
-
$type: "
|
|
641
|
+
$type: "number",
|
|
603
642
|
$value: "{size._step}"
|
|
643
|
+
},
|
|
644
|
+
unit: {
|
|
645
|
+
$type: "number",
|
|
646
|
+
$value: "{_size.step} / {_size.base} * {_size.mode-font-size}"
|
|
604
647
|
}
|
|
605
648
|
}
|
|
606
649
|
};
|
|
@@ -2435,7 +2478,7 @@ var createTokens = async (opts) => {
|
|
|
2435
2478
|
|
|
2436
2479
|
// src/tokens/process/platform.ts
|
|
2437
2480
|
import pc2 from "picocolors";
|
|
2438
|
-
import * as
|
|
2481
|
+
import * as R21 from "ramda";
|
|
2439
2482
|
import StyleDictionary2 from "style-dictionary";
|
|
2440
2483
|
|
|
2441
2484
|
// src/tokens/types.ts
|
|
@@ -2446,7 +2489,7 @@ var colorCategories = {
|
|
|
2446
2489
|
|
|
2447
2490
|
// src/tokens/process/configs.ts
|
|
2448
2491
|
import { register } from "@tokens-studio/sd-transforms";
|
|
2449
|
-
import * as
|
|
2492
|
+
import * as R20 from "ramda";
|
|
2450
2493
|
import StyleDictionary from "style-dictionary";
|
|
2451
2494
|
|
|
2452
2495
|
// src/tokens/utils.ts
|
|
@@ -2469,7 +2512,10 @@ var pathStartsWithOneOf = R7.curry(
|
|
|
2469
2512
|
return false;
|
|
2470
2513
|
}
|
|
2471
2514
|
const tokenPath = mapToLowerCase(token.path);
|
|
2472
|
-
const matchPathsStartingWith = R7.map((
|
|
2515
|
+
const matchPathsStartingWith = R7.map((pathOrString) => {
|
|
2516
|
+
const path2 = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
|
|
2517
|
+
return R7.startsWith(mapToLowerCase(path2), tokenPath);
|
|
2518
|
+
}, paths);
|
|
2473
2519
|
return hasAnyTruth(matchPathsStartingWith);
|
|
2474
2520
|
}
|
|
2475
2521
|
);
|
|
@@ -2493,11 +2539,11 @@ function isColorCategoryToken(token, category) {
|
|
|
2493
2539
|
var isDigit = (s) => /^\d+$/.test(s);
|
|
2494
2540
|
function traverseObj(obj, fn) {
|
|
2495
2541
|
for (const key in obj) {
|
|
2496
|
-
const
|
|
2497
|
-
if (
|
|
2498
|
-
fn.apply(null, [obj, key,
|
|
2499
|
-
if (typeof
|
|
2500
|
-
traverseObj(
|
|
2542
|
+
const prop4 = obj[key];
|
|
2543
|
+
if (prop4 != null) {
|
|
2544
|
+
fn.apply(null, [obj, key, prop4]);
|
|
2545
|
+
if (typeof prop4 === "object") {
|
|
2546
|
+
traverseObj(prop4, fn);
|
|
2501
2547
|
}
|
|
2502
2548
|
}
|
|
2503
2549
|
}
|
|
@@ -2517,9 +2563,26 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
2517
2563
|
return tokenWithInlinedRefs;
|
|
2518
2564
|
});
|
|
2519
2565
|
}
|
|
2566
|
+
var sizeMap = {
|
|
2567
|
+
xsmall: "xs",
|
|
2568
|
+
small: "sm",
|
|
2569
|
+
medium: "md",
|
|
2570
|
+
large: "lg",
|
|
2571
|
+
xlarge: "xl"
|
|
2572
|
+
};
|
|
2573
|
+
function shortSizeName(size2) {
|
|
2574
|
+
return sizeMap[size2] ?? size2;
|
|
2575
|
+
}
|
|
2576
|
+
var sizeComparator = (size2) => {
|
|
2577
|
+
const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
|
|
2578
|
+
return sortIndex ?? 0;
|
|
2579
|
+
};
|
|
2580
|
+
function orderBySize(sizes) {
|
|
2581
|
+
return R7.sortBy(sizeComparator, sizes);
|
|
2582
|
+
}
|
|
2520
2583
|
|
|
2521
2584
|
// src/tokens/process/configs/color.ts
|
|
2522
|
-
import * as
|
|
2585
|
+
import * as R15 from "ramda";
|
|
2523
2586
|
|
|
2524
2587
|
// src/tokens/process/formats/css/color.ts
|
|
2525
2588
|
import * as R8 from "ramda";
|
|
@@ -2577,10 +2640,10 @@ ${selector} ${content} ${autoSelectorContent}
|
|
|
2577
2640
|
};
|
|
2578
2641
|
var colorCategory = {
|
|
2579
2642
|
name: "ds/css-colorcategory",
|
|
2580
|
-
format: async ({ dictionary, options, platform }) => {
|
|
2643
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
2581
2644
|
const { outputReferences, usesDtcg } = options;
|
|
2582
|
-
const { selector, layer
|
|
2583
|
-
const destination =
|
|
2645
|
+
const { selector, layer } = platform;
|
|
2646
|
+
const destination = file.destination;
|
|
2584
2647
|
const format = R8.compose(
|
|
2585
2648
|
createPropertyFormatter({
|
|
2586
2649
|
outputReferences,
|
|
@@ -2617,6 +2680,10 @@ ${selector} ${content}
|
|
|
2617
2680
|
};
|
|
2618
2681
|
|
|
2619
2682
|
// src/tokens/process/formats/css/semantic.ts
|
|
2683
|
+
import * as R10 from "ramda";
|
|
2684
|
+
import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
|
|
2685
|
+
|
|
2686
|
+
// src/tokens/process/formats/css/size.ts
|
|
2620
2687
|
import * as R9 from "ramda";
|
|
2621
2688
|
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
2622
2689
|
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
@@ -2624,12 +2691,20 @@ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.pa
|
|
|
2624
2691
|
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
2625
2692
|
var isInlineTokens = R9.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
2626
2693
|
var overrideSizingFormula = (format, token) => {
|
|
2627
|
-
const [name, value] = format(token).split(":");
|
|
2628
|
-
|
|
2629
|
-
|
|
2694
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
2695
|
+
let calc;
|
|
2696
|
+
let round;
|
|
2697
|
+
if (token.path[1] === "unit") {
|
|
2698
|
+
calc = `calc(1rem * ${value})`;
|
|
2699
|
+
} else if (value.startsWith("floor")) {
|
|
2700
|
+
calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
|
|
2701
|
+
round = `round(down, ${calc}, 1px)`;
|
|
2702
|
+
} else {
|
|
2703
|
+
calc = value.includes("*") ? `calc(${value})` : value;
|
|
2704
|
+
}
|
|
2630
2705
|
return {
|
|
2631
2706
|
name,
|
|
2632
|
-
round,
|
|
2707
|
+
round: round ?? calc,
|
|
2633
2708
|
calc
|
|
2634
2709
|
};
|
|
2635
2710
|
};
|
|
@@ -2645,18 +2720,21 @@ var formatSizingTokens = (format, tokens) => R9.reduce(
|
|
|
2645
2720
|
{ tokens: [], round: [], calc: [] },
|
|
2646
2721
|
tokens
|
|
2647
2722
|
);
|
|
2648
|
-
var sizingTemplate = ({ round, calc }) =>
|
|
2723
|
+
var sizingTemplate = ({ round, calc }) => {
|
|
2724
|
+
const usesRounding = round.filter((val, i) => val !== calc[i]);
|
|
2725
|
+
return `
|
|
2649
2726
|
${calc.join("\n")}
|
|
2650
2727
|
|
|
2651
2728
|
@supports (width: round(down, .1em, 1px)) {
|
|
2652
|
-
${
|
|
2729
|
+
${usesRounding.join("\n ")}
|
|
2653
2730
|
}`;
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2731
|
+
};
|
|
2732
|
+
var size = {
|
|
2733
|
+
name: "ds/css-size",
|
|
2734
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
2657
2735
|
const { outputReferences, usesDtcg } = options;
|
|
2658
|
-
const { selector, layer
|
|
2659
|
-
const destination =
|
|
2736
|
+
const { selector, layer } = platform;
|
|
2737
|
+
const destination = file.destination;
|
|
2660
2738
|
const format = createPropertyFormatter2({
|
|
2661
2739
|
outputReferences,
|
|
2662
2740
|
dictionary,
|
|
@@ -2664,9 +2742,9 @@ var semantic = {
|
|
|
2664
2742
|
usesDtcg
|
|
2665
2743
|
});
|
|
2666
2744
|
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
2667
|
-
const filteredTokens = R9.reject((token) =>
|
|
2745
|
+
const filteredTokens = R9.reject((token) => R9.equals(["_size", "mode-font-size"], token.path), tokens);
|
|
2668
2746
|
const [sizingTokens, restTokens] = R9.partition(
|
|
2669
|
-
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
2747
|
+
(t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
|
|
2670
2748
|
filteredTokens
|
|
2671
2749
|
);
|
|
2672
2750
|
const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
|
|
@@ -2679,64 +2757,56 @@ var semantic = {
|
|
|
2679
2757
|
formatted: t
|
|
2680
2758
|
}));
|
|
2681
2759
|
buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
|
|
2682
|
-
const
|
|
2683
|
-
const
|
|
2684
|
-
const content = `{
|
|
2760
|
+
const formattedTokens = [formattedMap.map(R9.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
|
|
2761
|
+
const content = `${selector} {
|
|
2685
2762
|
${formattedTokens.join("\n")}
|
|
2686
2763
|
}
|
|
2687
2764
|
`;
|
|
2688
2765
|
const body = R9.isNotNil(layer) ? `@layer ${layer} {
|
|
2689
|
-
${
|
|
2766
|
+
${content}
|
|
2690
2767
|
}
|
|
2691
|
-
` : `${
|
|
2768
|
+
` : `${content}
|
|
2692
2769
|
`;
|
|
2693
2770
|
return body;
|
|
2694
2771
|
}
|
|
2695
2772
|
};
|
|
2696
2773
|
|
|
2697
|
-
// src/tokens/process/formats/css/
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
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 }) => {
|
|
2774
|
+
// src/tokens/process/formats/css/semantic.ts
|
|
2775
|
+
var semantic = {
|
|
2776
|
+
name: "ds/css-semantic",
|
|
2777
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
2707
2778
|
const { outputReferences, usesDtcg } = options;
|
|
2708
|
-
const { selector, layer
|
|
2709
|
-
const destination =
|
|
2779
|
+
const { selector, layer } = platform;
|
|
2780
|
+
const destination = file.destination;
|
|
2710
2781
|
const format = createPropertyFormatter3({
|
|
2711
2782
|
outputReferences,
|
|
2712
2783
|
dictionary,
|
|
2713
2784
|
format: "css",
|
|
2714
2785
|
usesDtcg
|
|
2715
2786
|
});
|
|
2716
|
-
const
|
|
2717
|
-
const formattedMap =
|
|
2787
|
+
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
2788
|
+
const formattedMap = tokens.map((token) => ({
|
|
2718
2789
|
token,
|
|
2719
2790
|
formatted: format(token)
|
|
2720
2791
|
}));
|
|
2721
2792
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2722
|
-
const formattedTokens = formattedMap.map(R10.
|
|
2723
|
-
const content =
|
|
2793
|
+
const formattedTokens = formattedMap.map(R10.prop("formatted")).join("\n");
|
|
2794
|
+
const content = `${selector} {
|
|
2724
2795
|
${formattedTokens}
|
|
2725
|
-
}
|
|
2796
|
+
}
|
|
2797
|
+
`;
|
|
2726
2798
|
const body = R10.isNotNil(layer) ? `@layer ${layer} {
|
|
2727
2799
|
${content}
|
|
2728
|
-
}
|
|
2800
|
+
}
|
|
2801
|
+
` : `${content}
|
|
2802
|
+
`;
|
|
2729
2803
|
return body;
|
|
2730
2804
|
}
|
|
2731
2805
|
};
|
|
2732
2806
|
|
|
2733
|
-
// src/tokens/process/formats/css.ts
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
colorCategory,
|
|
2737
|
-
semantic,
|
|
2738
|
-
typography
|
|
2739
|
-
};
|
|
2807
|
+
// src/tokens/process/formats/css/size-mode.ts
|
|
2808
|
+
import * as R12 from "ramda";
|
|
2809
|
+
import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
|
|
2740
2810
|
|
|
2741
2811
|
// src/tokens/process/transformers.ts
|
|
2742
2812
|
import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
|
|
@@ -2748,18 +2818,22 @@ var sizeRem = {
|
|
|
2748
2818
|
transitive: true,
|
|
2749
2819
|
filter: (token) => {
|
|
2750
2820
|
const hasWantedType = typeEquals(["dimension", "fontsize"], token);
|
|
2751
|
-
const hasWantedPath = pathStartsWithOneOf([
|
|
2821
|
+
const hasWantedPath = pathStartsWithOneOf([
|
|
2822
|
+
"border-radius",
|
|
2823
|
+
"font-size"
|
|
2824
|
+
/*, ['_size', 'mode-font-size']*/
|
|
2825
|
+
], token);
|
|
2752
2826
|
return hasWantedType && hasWantedPath;
|
|
2753
2827
|
},
|
|
2754
2828
|
transform: (token, config) => {
|
|
2755
2829
|
const value = getValue(token);
|
|
2756
2830
|
if (isPx(value)) {
|
|
2757
2831
|
const baseFont = config.basePxFontSize || 16;
|
|
2758
|
-
const
|
|
2759
|
-
if (
|
|
2832
|
+
const size2 = parseInt(value, 10);
|
|
2833
|
+
if (size2 === 0) {
|
|
2760
2834
|
return "0";
|
|
2761
2835
|
}
|
|
2762
|
-
return `${
|
|
2836
|
+
return `${size2 / baseFont}rem`;
|
|
2763
2837
|
}
|
|
2764
2838
|
return value;
|
|
2765
2839
|
}
|
|
@@ -2810,6 +2884,154 @@ var dsTransformers = [
|
|
|
2810
2884
|
"shadow/css/shorthand"
|
|
2811
2885
|
];
|
|
2812
2886
|
|
|
2887
|
+
// src/tokens/process/formats/css/size-mode.ts
|
|
2888
|
+
var formatBaseSizeToken = (size2) => (token) => ({
|
|
2889
|
+
...token,
|
|
2890
|
+
originalName: token.name,
|
|
2891
|
+
name: `${token.name}--${shortSizeName(size2)}`,
|
|
2892
|
+
$value: token.$value / basePxFontSize
|
|
2893
|
+
});
|
|
2894
|
+
var sizeMode = {
|
|
2895
|
+
name: "ds/css-size-mode",
|
|
2896
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
2897
|
+
const { outputReferences, usesDtcg } = options;
|
|
2898
|
+
const { selector, layer, size: size2 } = platform;
|
|
2899
|
+
const destination = file.destination;
|
|
2900
|
+
const format = createPropertyFormatter4({
|
|
2901
|
+
outputReferences,
|
|
2902
|
+
dictionary,
|
|
2903
|
+
format: "css",
|
|
2904
|
+
usesDtcg
|
|
2905
|
+
});
|
|
2906
|
+
const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
|
|
2907
|
+
const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
|
|
2908
|
+
const formattedMap = sizeSpecificTokens.map((token) => ({
|
|
2909
|
+
token,
|
|
2910
|
+
formatted: format({
|
|
2911
|
+
...token,
|
|
2912
|
+
// Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
|
|
2913
|
+
name: token.originalName
|
|
2914
|
+
})
|
|
2915
|
+
}));
|
|
2916
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2917
|
+
const content = `${selector} /* ${size2} */ {
|
|
2918
|
+
${sizeSpecificVariables}
|
|
2919
|
+
}`;
|
|
2920
|
+
const body = wrapInLayer(content, layer);
|
|
2921
|
+
const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
|
|
2922
|
+
const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
|
|
2923
|
+
const sizingToggles = `:root, [data-size] {
|
|
2924
|
+
--ds-size: var(--ds-size--${defaultSize});
|
|
2925
|
+
${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
|
|
2926
|
+
--ds-size-mode-font-size:
|
|
2927
|
+
${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
|
|
2928
|
+
}`;
|
|
2929
|
+
const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
|
|
2930
|
+
const sharedContent = `${sizingToggles}
|
|
2931
|
+
|
|
2932
|
+
${sizingHelpers}`;
|
|
2933
|
+
const sharedBody = shortSizeName(size2) === R12.last(sizes) ? `
|
|
2934
|
+
${wrapInLayer(sharedContent, layer)}` : "";
|
|
2935
|
+
return body + sharedBody;
|
|
2936
|
+
}
|
|
2937
|
+
};
|
|
2938
|
+
function wrapInLayer(content, layer) {
|
|
2939
|
+
return R12.isNotNil(layer) ? `@layer ${layer} {
|
|
2940
|
+
${content}
|
|
2941
|
+
}
|
|
2942
|
+
` : `${content}
|
|
2943
|
+
`;
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
// src/tokens/process/formats/css/typography.ts
|
|
2947
|
+
import * as R13 from "ramda";
|
|
2948
|
+
import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
|
|
2949
|
+
var typographyFontFamilyPredicate = R13.allPass([
|
|
2950
|
+
R13.pathSatisfies(R13.includes("typography"), ["path"]),
|
|
2951
|
+
R13.pathSatisfies(R13.includes("fontFamily"), ["path"])
|
|
2952
|
+
]);
|
|
2953
|
+
var typography = {
|
|
2954
|
+
name: "ds/css-typography",
|
|
2955
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
2956
|
+
const { outputReferences, usesDtcg } = options;
|
|
2957
|
+
const { selector, layer } = platform;
|
|
2958
|
+
const destination = file.destination;
|
|
2959
|
+
const format = createPropertyFormatter5({
|
|
2960
|
+
outputReferences,
|
|
2961
|
+
dictionary,
|
|
2962
|
+
format: "css",
|
|
2963
|
+
usesDtcg
|
|
2964
|
+
});
|
|
2965
|
+
const filteredTokens = R13.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
2966
|
+
const formattedMap = filteredTokens.map((token) => ({
|
|
2967
|
+
token,
|
|
2968
|
+
formatted: format(token)
|
|
2969
|
+
}));
|
|
2970
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2971
|
+
const formattedTokens = formattedMap.map(R13.view(R13.lensProp("formatted"))).join("\n");
|
|
2972
|
+
const content = selector ? `${selector} {
|
|
2973
|
+
${formattedTokens}
|
|
2974
|
+
}` : formattedTokens;
|
|
2975
|
+
const body = R13.isNotNil(layer) ? `@layer ${layer} {
|
|
2976
|
+
${content}
|
|
2977
|
+
}` : content;
|
|
2978
|
+
return body;
|
|
2979
|
+
}
|
|
2980
|
+
};
|
|
2981
|
+
|
|
2982
|
+
// src/tokens/process/formats/css/type-scale.ts
|
|
2983
|
+
import * as R14 from "ramda";
|
|
2984
|
+
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
2985
|
+
var typographyFontFamilyPredicate2 = R14.allPass([
|
|
2986
|
+
R14.pathSatisfies(R14.includes("typography"), ["path"]),
|
|
2987
|
+
R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
|
|
2988
|
+
]);
|
|
2989
|
+
function formatTypographySizeToken(token) {
|
|
2990
|
+
return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
|
|
2991
|
+
}
|
|
2992
|
+
var typeScale = {
|
|
2993
|
+
name: "ds/css-type-scale",
|
|
2994
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
2995
|
+
const { outputReferences, usesDtcg } = options;
|
|
2996
|
+
const { selector, layer } = platform;
|
|
2997
|
+
const destination = file.destination;
|
|
2998
|
+
const format = createPropertyFormatter6({
|
|
2999
|
+
outputReferences,
|
|
3000
|
+
dictionary,
|
|
3001
|
+
format: "css",
|
|
3002
|
+
usesDtcg
|
|
3003
|
+
});
|
|
3004
|
+
const filteredTokens = R14.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
|
|
3005
|
+
const tokens = R14.map(formatTypographySizeToken, filteredTokens);
|
|
3006
|
+
const formattedMap = tokens.map((token) => ({
|
|
3007
|
+
token,
|
|
3008
|
+
formatted: format(token)
|
|
3009
|
+
}));
|
|
3010
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
3011
|
+
const formattedTokens = formattedMap.map(R14.prop("formatted")).join("\n");
|
|
3012
|
+
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
3013
|
+
const content = `${selector} {
|
|
3014
|
+
${sizeFactor}
|
|
3015
|
+
${formattedTokens}
|
|
3016
|
+
}`;
|
|
3017
|
+
const body = R14.isNotNil(layer) ? `@layer ${layer} {
|
|
3018
|
+
${content}
|
|
3019
|
+
}` : content;
|
|
3020
|
+
return body;
|
|
3021
|
+
}
|
|
3022
|
+
};
|
|
3023
|
+
|
|
3024
|
+
// src/tokens/process/formats/css.ts
|
|
3025
|
+
var formats = {
|
|
3026
|
+
colorScheme,
|
|
3027
|
+
colorCategory,
|
|
3028
|
+
semantic,
|
|
3029
|
+
sizeMode,
|
|
3030
|
+
size,
|
|
3031
|
+
typography,
|
|
3032
|
+
typeScale
|
|
3033
|
+
};
|
|
3034
|
+
|
|
2813
3035
|
// src/tokens/process/configs/color.ts
|
|
2814
3036
|
var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
|
|
2815
3037
|
const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
|
|
@@ -2831,7 +3053,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
|
|
|
2831
3053
|
{
|
|
2832
3054
|
destination: `color-scheme/${colorScheme2}.css`,
|
|
2833
3055
|
format: formats.colorScheme.name,
|
|
2834
|
-
filter: (token) => typeEquals("color", token) && !
|
|
3056
|
+
filter: (token) => typeEquals("color", token) && !R15.startsWith(["global"], token.path)
|
|
2835
3057
|
}
|
|
2836
3058
|
],
|
|
2837
3059
|
options: {
|
|
@@ -2882,7 +3104,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
2882
3104
|
};
|
|
2883
3105
|
|
|
2884
3106
|
// src/tokens/process/configs/semantic.ts
|
|
2885
|
-
import * as
|
|
3107
|
+
import * as R16 from "ramda";
|
|
2886
3108
|
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
2887
3109
|
var semanticVariables = ({ theme }) => {
|
|
2888
3110
|
const selector = `:root`;
|
|
@@ -2905,9 +3127,12 @@ var semanticVariables = ({ theme }) => {
|
|
|
2905
3127
|
destination: `semantic.css`,
|
|
2906
3128
|
format: formats.semantic.name,
|
|
2907
3129
|
filter: (token) => {
|
|
2908
|
-
const isUwantedToken =
|
|
2909
|
-
const isPrivateToken =
|
|
2910
|
-
const unwantedPaths = pathStartsWithOneOf(
|
|
3130
|
+
const isUwantedToken = R16.anyPass([R16.includes("primitives/global")])(token.filePath);
|
|
3131
|
+
const isPrivateToken = R16.includes("_", token.path);
|
|
3132
|
+
const unwantedPaths = pathStartsWithOneOf(
|
|
3133
|
+
["size", "_size", "font-size", "line-height", "letter-spacing"],
|
|
3134
|
+
token
|
|
3135
|
+
);
|
|
2911
3136
|
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
2912
3137
|
const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
2913
3138
|
return unwantedTokens;
|
|
@@ -2917,8 +3142,7 @@ var semanticVariables = ({ theme }) => {
|
|
|
2917
3142
|
options: {
|
|
2918
3143
|
outputReferences: (token, options) => {
|
|
2919
3144
|
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
2920
|
-
|
|
2921
|
-
return (include || isWantedSize) && outputReferencesFilter(token, options);
|
|
3145
|
+
return include && outputReferencesFilter(token, options);
|
|
2922
3146
|
}
|
|
2923
3147
|
}
|
|
2924
3148
|
}
|
|
@@ -2926,6 +3150,124 @@ var semanticVariables = ({ theme }) => {
|
|
|
2926
3150
|
};
|
|
2927
3151
|
};
|
|
2928
3152
|
|
|
3153
|
+
// src/tokens/process/configs/size.ts
|
|
3154
|
+
import * as R17 from "ramda";
|
|
3155
|
+
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
3156
|
+
var sizeVariables = ({ theme }) => {
|
|
3157
|
+
const selector = `:root, [data-size]`;
|
|
3158
|
+
const layer = `ds.theme.size`;
|
|
3159
|
+
return {
|
|
3160
|
+
preprocessors: ["tokens-studio"],
|
|
3161
|
+
platforms: {
|
|
3162
|
+
css: {
|
|
3163
|
+
// custom
|
|
3164
|
+
theme,
|
|
3165
|
+
basePxFontSize,
|
|
3166
|
+
selector,
|
|
3167
|
+
layer,
|
|
3168
|
+
//
|
|
3169
|
+
prefix,
|
|
3170
|
+
buildPath: `${theme}/`,
|
|
3171
|
+
transforms: dsTransformers,
|
|
3172
|
+
files: [
|
|
3173
|
+
{
|
|
3174
|
+
destination: `size.css`,
|
|
3175
|
+
format: formats.size.name,
|
|
3176
|
+
filter: (token) => {
|
|
3177
|
+
const isUwantedToken = R17.anyPass([R17.includes("primitives/global")])(token.filePath);
|
|
3178
|
+
const isPrivateToken = R17.includes("_", token.path);
|
|
3179
|
+
return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
],
|
|
3183
|
+
options: {
|
|
3184
|
+
outputReferences: (token, options) => {
|
|
3185
|
+
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
|
|
3186
|
+
return isWantedSize && outputReferencesFilter2(token, options);
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
};
|
|
3192
|
+
};
|
|
3193
|
+
|
|
3194
|
+
// src/tokens/process/configs/size-mode.ts
|
|
3195
|
+
import * as R18 from "ramda";
|
|
3196
|
+
var sizeModeVariables = ({ theme, size: size2 }) => {
|
|
3197
|
+
const selector = `:root`;
|
|
3198
|
+
const layer = `ds.theme.size-mode`;
|
|
3199
|
+
return {
|
|
3200
|
+
preprocessors: ["tokens-studio"],
|
|
3201
|
+
platforms: {
|
|
3202
|
+
css: {
|
|
3203
|
+
// custom
|
|
3204
|
+
size: size2,
|
|
3205
|
+
theme,
|
|
3206
|
+
basePxFontSize,
|
|
3207
|
+
selector,
|
|
3208
|
+
layer,
|
|
3209
|
+
//
|
|
3210
|
+
prefix,
|
|
3211
|
+
buildPath: `${theme}/`,
|
|
3212
|
+
transforms: dsTransformers,
|
|
3213
|
+
files: [
|
|
3214
|
+
{
|
|
3215
|
+
destination: `size-mode/${size2}.css`,
|
|
3216
|
+
format: formats.sizeMode.name,
|
|
3217
|
+
filter: (token) => {
|
|
3218
|
+
return R18.equals(["_size", "mode-font-size"], token.path);
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
]
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
};
|
|
3225
|
+
};
|
|
3226
|
+
|
|
3227
|
+
// src/tokens/process/configs/type-scale.ts
|
|
3228
|
+
var typeScaleVariables = ({ theme, size: size2 }) => {
|
|
3229
|
+
const selector = ":root, [data-size]";
|
|
3230
|
+
const layer = `ds.theme.type-scale`;
|
|
3231
|
+
return {
|
|
3232
|
+
usesDtcg: true,
|
|
3233
|
+
preprocessors: ["tokens-studio"],
|
|
3234
|
+
expand: {
|
|
3235
|
+
include: ["typography"]
|
|
3236
|
+
},
|
|
3237
|
+
platforms: {
|
|
3238
|
+
css: {
|
|
3239
|
+
prefix,
|
|
3240
|
+
selector,
|
|
3241
|
+
layer,
|
|
3242
|
+
buildPath: `${theme}/`,
|
|
3243
|
+
basePxFontSize,
|
|
3244
|
+
transforms: [
|
|
3245
|
+
"name/kebab",
|
|
3246
|
+
"ts/size/px",
|
|
3247
|
+
sizeRem.name,
|
|
3248
|
+
"ts/size/lineheight",
|
|
3249
|
+
"ts/typography/fontWeight",
|
|
3250
|
+
typographyName.name
|
|
3251
|
+
],
|
|
3252
|
+
files: [
|
|
3253
|
+
{
|
|
3254
|
+
destination: `type-scale.css`,
|
|
3255
|
+
format: formats.typeScale.name,
|
|
3256
|
+
filter: (token) => {
|
|
3257
|
+
const included = typeEquals(["typography", "dimension", "fontsize"], token);
|
|
3258
|
+
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
3259
|
+
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
],
|
|
3263
|
+
options: {
|
|
3264
|
+
outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
};
|
|
3269
|
+
};
|
|
3270
|
+
|
|
2929
3271
|
// src/tokens/process/configs/typography.ts
|
|
2930
3272
|
import { expandTypesMap } from "@tokens-studio/sd-transforms";
|
|
2931
3273
|
var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
@@ -2960,12 +3302,9 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
2960
3302
|
destination: `typography/${typography2}.css`,
|
|
2961
3303
|
format: formats.typography.name,
|
|
2962
3304
|
filter: (token) => {
|
|
2963
|
-
const included = typeEquals(
|
|
2964
|
-
["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
|
|
2965
|
-
token
|
|
2966
|
-
);
|
|
3305
|
+
const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
|
|
2967
3306
|
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
2968
|
-
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
|
|
3307
|
+
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
|
|
2969
3308
|
}
|
|
2970
3309
|
}
|
|
2971
3310
|
]
|
|
@@ -2977,13 +3316,13 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
2977
3316
|
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
2978
3317
|
import { kebabCase } from "change-case";
|
|
2979
3318
|
import pc from "picocolors";
|
|
2980
|
-
import * as
|
|
3319
|
+
import * as R19 from "ramda";
|
|
2981
3320
|
var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
2982
3321
|
const verboseLogging = buildOptions?.verbose;
|
|
2983
3322
|
const grouped$themes = groupThemes(processed$themes);
|
|
2984
3323
|
const permutations = permutateThemes(grouped$themes);
|
|
2985
3324
|
const ALL_DEPENDENT_ON = ["theme"];
|
|
2986
|
-
const keys2 =
|
|
3325
|
+
const keys2 = R19.keys(grouped$themes);
|
|
2987
3326
|
const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
2988
3327
|
if (verboseLogging) {
|
|
2989
3328
|
console.log(pc.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
@@ -3023,7 +3362,7 @@ function groupThemes(themes) {
|
|
|
3023
3362
|
}
|
|
3024
3363
|
return groups;
|
|
3025
3364
|
}
|
|
3026
|
-
var hasUnknownProps =
|
|
3365
|
+
var hasUnknownProps = R19.pipe(R19.values, R19.none(R19.equals("unknown")), R19.not);
|
|
3027
3366
|
function permutateThemes(groups) {
|
|
3028
3367
|
const separator = "_";
|
|
3029
3368
|
const permutations = cartesian(Object.values(groups));
|
|
@@ -3033,8 +3372,8 @@ function permutateThemes(groups) {
|
|
|
3033
3372
|
const { group, name, selectedTokenSets } = theme;
|
|
3034
3373
|
let updatedPermutation = acc.permutation;
|
|
3035
3374
|
if (group) {
|
|
3036
|
-
const groupProp =
|
|
3037
|
-
updatedPermutation =
|
|
3375
|
+
const groupProp = R19.lensProp(group);
|
|
3376
|
+
updatedPermutation = R19.set(groupProp, name, updatedPermutation);
|
|
3038
3377
|
}
|
|
3039
3378
|
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
3040
3379
|
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
@@ -3105,7 +3444,10 @@ var configs = {
|
|
|
3105
3444
|
dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
|
|
3106
3445
|
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
3107
3446
|
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
3447
|
+
sizeModeVariables,
|
|
3448
|
+
sizeVariables,
|
|
3108
3449
|
typographyVariables,
|
|
3450
|
+
typeScaleVariables,
|
|
3109
3451
|
semanticVariables
|
|
3110
3452
|
};
|
|
3111
3453
|
var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
|
|
@@ -3122,7 +3464,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
3122
3464
|
obj.filePath = tokenSet;
|
|
3123
3465
|
}
|
|
3124
3466
|
});
|
|
3125
|
-
tokenSource.tokens =
|
|
3467
|
+
tokenSource.tokens = R20.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
|
|
3126
3468
|
}
|
|
3127
3469
|
}
|
|
3128
3470
|
} else {
|
|
@@ -3173,6 +3515,9 @@ var buildOptions = {
|
|
|
3173
3515
|
var sd = new StyleDictionary2();
|
|
3174
3516
|
var buildConfigs = {
|
|
3175
3517
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
3518
|
+
sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
|
|
3519
|
+
size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
|
|
3520
|
+
typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
|
|
3176
3521
|
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
3177
3522
|
"main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
|
|
3178
3523
|
"support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
|
|
@@ -3208,9 +3553,6 @@ async function processPlatform(options) {
|
|
|
3208
3553
|
const platform = "css";
|
|
3209
3554
|
const tokenSets = type === "format" ? options.tokenSets : void 0;
|
|
3210
3555
|
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
3556
|
const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
|
|
3215
3557
|
if (UNSAFE_DEFAULT_COLOR) {
|
|
3216
3558
|
console.warn(
|
|
@@ -3234,24 +3576,29 @@ async function processPlatform(options) {
|
|
|
3234
3576
|
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
3235
3577
|
buildOptions.colorGroups = colorGroups;
|
|
3236
3578
|
if (!buildOptions.defaultColor) {
|
|
3237
|
-
const customColors = getCustomColors(
|
|
3238
|
-
const firstMainColor =
|
|
3579
|
+
const customColors = getCustomColors(processed$themes, colorGroups);
|
|
3580
|
+
const firstMainColor = R21.head(customColors);
|
|
3239
3581
|
buildOptions.defaultColor = firstMainColor;
|
|
3240
3582
|
}
|
|
3241
3583
|
if (buildOptions.defaultColor) {
|
|
3242
3584
|
console.log(`
|
|
3243
3585
|
\u{1F3A8} Using ${pc2.blue(buildOptions.defaultColor)} as default color`);
|
|
3244
3586
|
}
|
|
3245
|
-
const
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3587
|
+
const sizeModes = processed$themes.filter((x) => x.group === "size").map((x) => x.name);
|
|
3588
|
+
buildOptions.sizeModes = sizeModes;
|
|
3589
|
+
if (!buildOptions.defaultSize) {
|
|
3590
|
+
const defaultSize = R21.head(sizeModes);
|
|
3591
|
+
buildOptions.defaultSize = defaultSize;
|
|
3592
|
+
}
|
|
3593
|
+
if (buildOptions.defaultSize) {
|
|
3594
|
+
console.log(`
|
|
3595
|
+
\u{1F4CF} Using ${pc2.blue(buildOptions.defaultSize)} as default size`);
|
|
3596
|
+
}
|
|
3597
|
+
const buildAndSdConfigs = R21.map((buildConfig) => {
|
|
3598
|
+
const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
|
|
3599
|
+
tokensDir,
|
|
3600
|
+
tokenSets
|
|
3601
|
+
});
|
|
3255
3602
|
const unknownConfigs = buildConfig.dimensions.map(
|
|
3256
3603
|
(dimension) => sdConfigs.filter((x) => x.permutation[dimension] === "unknown")
|
|
3257
3604
|
);
|
|
@@ -3275,10 +3622,13 @@ async function processPlatform(options) {
|
|
|
3275
3622
|
"warning-color": [initResult],
|
|
3276
3623
|
"info-color": [initResult],
|
|
3277
3624
|
semantic: [initResult],
|
|
3278
|
-
typography: [initResult]
|
|
3625
|
+
typography: [initResult],
|
|
3626
|
+
sizeMode: [initResult],
|
|
3627
|
+
size: [initResult],
|
|
3628
|
+
typeScale: [initResult]
|
|
3279
3629
|
};
|
|
3280
3630
|
try {
|
|
3281
|
-
for (const [buildName, { buildConfig, sdConfigs }] of
|
|
3631
|
+
for (const [buildName, { buildConfig, sdConfigs }] of R21.toPairs(buildAndSdConfigs)) {
|
|
3282
3632
|
if (!(buildConfig.enabled?.() ?? true)) {
|
|
3283
3633
|
continue;
|
|
3284
3634
|
}
|
|
@@ -3290,7 +3640,7 @@ async function processPlatform(options) {
|
|
|
3290
3640
|
const { config, permutation } = sdConfig;
|
|
3291
3641
|
const modes = ["theme", ...buildConfig.dimensions];
|
|
3292
3642
|
const modeMessage = modes.map((x) => permutation[x]).join(" - ");
|
|
3293
|
-
const logMessage =
|
|
3643
|
+
const logMessage = R21.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
|
|
3294
3644
|
console.log(logMessage);
|
|
3295
3645
|
const sdOptions = { cache: true };
|
|
3296
3646
|
const sdExtended = await sd.extend(config);
|
|
@@ -3433,13 +3783,13 @@ var formatTheme = async (themeConfig) => {
|
|
|
3433
3783
|
};
|
|
3434
3784
|
formatTheme({
|
|
3435
3785
|
name: "test",
|
|
3436
|
-
borderRadius:
|
|
3786
|
+
borderRadius: digdir_config_default.themes.digdir.borderRadius,
|
|
3437
3787
|
colors: {
|
|
3438
|
-
main:
|
|
3439
|
-
support:
|
|
3440
|
-
neutral:
|
|
3788
|
+
main: digdir_config_default.themes.digdir.colors.main,
|
|
3789
|
+
support: digdir_config_default.themes.digdir.colors.support,
|
|
3790
|
+
neutral: digdir_config_default.themes.digdir.colors.neutral
|
|
3441
3791
|
},
|
|
3442
|
-
typography:
|
|
3792
|
+
typography: digdir_config_default.themes.digdir.typography
|
|
3443
3793
|
});
|
|
3444
3794
|
export {
|
|
3445
3795
|
formatTheme
|