@digdir/designsystemet 1.4.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/dist/bin/designsystemet.js +484 -162
- package/dist/global-Y35YADVH.json +100 -0
- package/dist/src/index.js +523 -199
- package/dist/src/scripts/update-preview-tokens.js +429 -118
- package/dist/src/tokens/build.js +425 -107
- package/dist/src/tokens/create/defaults.js +27 -23
- package/dist/src/tokens/create/generators/$designsystemet.js +2 -2
- package/dist/src/tokens/create/write.js +2 -2
- package/dist/src/tokens/create.js +27 -23
- package/dist/src/tokens/format.js +523 -199
- package/dist/src/tokens/index.js +523 -199
- 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 +372 -70
- package/dist/src/tokens/process/output/theme.d.ts.map +1 -1
- package/dist/src/tokens/process/output/theme.js +59 -10
- 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 +2 -2
- package/dist/global-XVXVBKM6.json +0 -96
|
@@ -551,95 +551,99 @@ var global_default = {
|
|
|
551
551
|
_size: {
|
|
552
552
|
"0": {
|
|
553
553
|
$type: "dimension",
|
|
554
|
-
$value: "floor({_size.
|
|
554
|
+
$value: "floor({_size.unit} * 0)"
|
|
555
555
|
},
|
|
556
556
|
"1": {
|
|
557
557
|
$type: "dimension",
|
|
558
|
-
$value: "floor({_size.
|
|
558
|
+
$value: "floor({_size.unit} * 1)"
|
|
559
559
|
},
|
|
560
560
|
"2": {
|
|
561
561
|
$type: "dimension",
|
|
562
|
-
$value: "floor({_size.
|
|
562
|
+
$value: "floor({_size.unit} * 2)"
|
|
563
563
|
},
|
|
564
564
|
"3": {
|
|
565
565
|
$type: "dimension",
|
|
566
|
-
$value: "floor({_size.
|
|
566
|
+
$value: "floor({_size.unit} * 3)"
|
|
567
567
|
},
|
|
568
568
|
"4": {
|
|
569
569
|
$type: "dimension",
|
|
570
|
-
$value: "floor({_size.
|
|
570
|
+
$value: "floor({_size.unit} * 4)"
|
|
571
571
|
},
|
|
572
572
|
"5": {
|
|
573
573
|
$type: "dimension",
|
|
574
|
-
$value: "floor({_size.
|
|
574
|
+
$value: "floor({_size.unit} * 5)"
|
|
575
575
|
},
|
|
576
576
|
"6": {
|
|
577
577
|
$type: "dimension",
|
|
578
|
-
$value: "floor({_size.
|
|
578
|
+
$value: "floor({_size.unit} * 6)"
|
|
579
579
|
},
|
|
580
580
|
"7": {
|
|
581
581
|
$type: "dimension",
|
|
582
|
-
$value: "floor({_size.
|
|
582
|
+
$value: "floor({_size.unit} * 7)"
|
|
583
583
|
},
|
|
584
584
|
"8": {
|
|
585
585
|
$type: "dimension",
|
|
586
|
-
$value: "floor({_size.
|
|
586
|
+
$value: "floor({_size.unit} * 8)"
|
|
587
587
|
},
|
|
588
588
|
"9": {
|
|
589
589
|
$type: "dimension",
|
|
590
|
-
$value: "floor({_size.
|
|
590
|
+
$value: "floor({_size.unit} * 9)"
|
|
591
591
|
},
|
|
592
592
|
"10": {
|
|
593
593
|
$type: "dimension",
|
|
594
|
-
$value: "floor({_size.
|
|
594
|
+
$value: "floor({_size.unit} * 10)"
|
|
595
595
|
},
|
|
596
596
|
"11": {
|
|
597
597
|
$type: "dimension",
|
|
598
|
-
$value: "floor({_size.
|
|
598
|
+
$value: "floor({_size.unit} * 11)"
|
|
599
599
|
},
|
|
600
600
|
"12": {
|
|
601
601
|
$type: "dimension",
|
|
602
|
-
$value: "floor({_size.
|
|
602
|
+
$value: "floor({_size.unit} * 12)"
|
|
603
603
|
},
|
|
604
604
|
"13": {
|
|
605
605
|
$type: "dimension",
|
|
606
|
-
$value: "floor({_size.
|
|
606
|
+
$value: "floor({_size.unit} * 13)"
|
|
607
607
|
},
|
|
608
608
|
"14": {
|
|
609
609
|
$type: "dimension",
|
|
610
|
-
$value: "floor({_size.
|
|
610
|
+
$value: "floor({_size.unit} * 14)"
|
|
611
611
|
},
|
|
612
612
|
"15": {
|
|
613
613
|
$type: "dimension",
|
|
614
|
-
$value: "floor({_size.
|
|
614
|
+
$value: "floor({_size.unit} * 15)"
|
|
615
615
|
},
|
|
616
616
|
"18": {
|
|
617
617
|
$type: "dimension",
|
|
618
|
-
$value: "floor({_size.
|
|
618
|
+
$value: "floor({_size.unit} * 18)"
|
|
619
619
|
},
|
|
620
620
|
"22": {
|
|
621
621
|
$type: "dimension",
|
|
622
|
-
$value: "floor({_size.
|
|
622
|
+
$value: "floor({_size.unit} * 22)"
|
|
623
623
|
},
|
|
624
624
|
"26": {
|
|
625
625
|
$type: "dimension",
|
|
626
|
-
$value: "floor({_size.
|
|
626
|
+
$value: "floor({_size.unit} * 26)"
|
|
627
627
|
},
|
|
628
628
|
"30": {
|
|
629
629
|
$type: "dimension",
|
|
630
|
-
$value: "floor({_size.
|
|
630
|
+
$value: "floor({_size.unit} * 30)"
|
|
631
631
|
},
|
|
632
632
|
"mode-font-size": {
|
|
633
|
-
$type: "
|
|
633
|
+
$type: "number",
|
|
634
634
|
$value: "{size._mode-font-size}"
|
|
635
635
|
},
|
|
636
636
|
base: {
|
|
637
|
-
$type: "
|
|
637
|
+
$type: "number",
|
|
638
638
|
$value: "{size._base}"
|
|
639
639
|
},
|
|
640
640
|
step: {
|
|
641
|
-
$type: "
|
|
641
|
+
$type: "number",
|
|
642
642
|
$value: "{size._step}"
|
|
643
|
+
},
|
|
644
|
+
unit: {
|
|
645
|
+
$type: "number",
|
|
646
|
+
$value: "{_size.step} / {_size.base} * {_size.mode-font-size}"
|
|
643
647
|
}
|
|
644
648
|
}
|
|
645
649
|
};
|
|
@@ -2474,7 +2478,7 @@ var createTokens = async (opts) => {
|
|
|
2474
2478
|
|
|
2475
2479
|
// src/tokens/process/platform.ts
|
|
2476
2480
|
import pc2 from "picocolors";
|
|
2477
|
-
import * as
|
|
2481
|
+
import * as R21 from "ramda";
|
|
2478
2482
|
import StyleDictionary2 from "style-dictionary";
|
|
2479
2483
|
|
|
2480
2484
|
// src/tokens/types.ts
|
|
@@ -2485,7 +2489,7 @@ var colorCategories = {
|
|
|
2485
2489
|
|
|
2486
2490
|
// src/tokens/process/configs.ts
|
|
2487
2491
|
import { register } from "@tokens-studio/sd-transforms";
|
|
2488
|
-
import * as
|
|
2492
|
+
import * as R20 from "ramda";
|
|
2489
2493
|
import StyleDictionary from "style-dictionary";
|
|
2490
2494
|
|
|
2491
2495
|
// src/tokens/utils.ts
|
|
@@ -2508,7 +2512,10 @@ var pathStartsWithOneOf = R7.curry(
|
|
|
2508
2512
|
return false;
|
|
2509
2513
|
}
|
|
2510
2514
|
const tokenPath = mapToLowerCase(token.path);
|
|
2511
|
-
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);
|
|
2512
2519
|
return hasAnyTruth(matchPathsStartingWith);
|
|
2513
2520
|
}
|
|
2514
2521
|
);
|
|
@@ -2532,11 +2539,11 @@ function isColorCategoryToken(token, category) {
|
|
|
2532
2539
|
var isDigit = (s) => /^\d+$/.test(s);
|
|
2533
2540
|
function traverseObj(obj, fn) {
|
|
2534
2541
|
for (const key in obj) {
|
|
2535
|
-
const
|
|
2536
|
-
if (
|
|
2537
|
-
fn.apply(null, [obj, key,
|
|
2538
|
-
if (typeof
|
|
2539
|
-
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);
|
|
2540
2547
|
}
|
|
2541
2548
|
}
|
|
2542
2549
|
}
|
|
@@ -2556,9 +2563,26 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
2556
2563
|
return tokenWithInlinedRefs;
|
|
2557
2564
|
});
|
|
2558
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
|
+
}
|
|
2559
2583
|
|
|
2560
2584
|
// src/tokens/process/configs/color.ts
|
|
2561
|
-
import * as
|
|
2585
|
+
import * as R15 from "ramda";
|
|
2562
2586
|
|
|
2563
2587
|
// src/tokens/process/formats/css/color.ts
|
|
2564
2588
|
import * as R8 from "ramda";
|
|
@@ -2616,10 +2640,10 @@ ${selector} ${content} ${autoSelectorContent}
|
|
|
2616
2640
|
};
|
|
2617
2641
|
var colorCategory = {
|
|
2618
2642
|
name: "ds/css-colorcategory",
|
|
2619
|
-
format: async ({ dictionary, options, platform }) => {
|
|
2643
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
2620
2644
|
const { outputReferences, usesDtcg } = options;
|
|
2621
|
-
const { selector, layer
|
|
2622
|
-
const destination =
|
|
2645
|
+
const { selector, layer } = platform;
|
|
2646
|
+
const destination = file.destination;
|
|
2623
2647
|
const format = R8.compose(
|
|
2624
2648
|
createPropertyFormatter({
|
|
2625
2649
|
outputReferences,
|
|
@@ -2656,6 +2680,10 @@ ${selector} ${content}
|
|
|
2656
2680
|
};
|
|
2657
2681
|
|
|
2658
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
|
|
2659
2687
|
import * as R9 from "ramda";
|
|
2660
2688
|
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
2661
2689
|
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
@@ -2663,12 +2691,20 @@ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.pa
|
|
|
2663
2691
|
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
2664
2692
|
var isInlineTokens = R9.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
2665
2693
|
var overrideSizingFormula = (format, token) => {
|
|
2666
|
-
const [name, value] = format(token).split(":");
|
|
2667
|
-
|
|
2668
|
-
|
|
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
|
+
}
|
|
2669
2705
|
return {
|
|
2670
2706
|
name,
|
|
2671
|
-
round,
|
|
2707
|
+
round: round ?? calc,
|
|
2672
2708
|
calc
|
|
2673
2709
|
};
|
|
2674
2710
|
};
|
|
@@ -2684,18 +2720,21 @@ var formatSizingTokens = (format, tokens) => R9.reduce(
|
|
|
2684
2720
|
{ tokens: [], round: [], calc: [] },
|
|
2685
2721
|
tokens
|
|
2686
2722
|
);
|
|
2687
|
-
var sizingTemplate = ({ round, calc }) =>
|
|
2723
|
+
var sizingTemplate = ({ round, calc }) => {
|
|
2724
|
+
const usesRounding = round.filter((val, i) => val !== calc[i]);
|
|
2725
|
+
return `
|
|
2688
2726
|
${calc.join("\n")}
|
|
2689
2727
|
|
|
2690
2728
|
@supports (width: round(down, .1em, 1px)) {
|
|
2691
|
-
${
|
|
2729
|
+
${usesRounding.join("\n ")}
|
|
2692
2730
|
}`;
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2731
|
+
};
|
|
2732
|
+
var size = {
|
|
2733
|
+
name: "ds/css-size",
|
|
2734
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
2696
2735
|
const { outputReferences, usesDtcg } = options;
|
|
2697
|
-
const { selector, layer
|
|
2698
|
-
const destination =
|
|
2736
|
+
const { selector, layer } = platform;
|
|
2737
|
+
const destination = file.destination;
|
|
2699
2738
|
const format = createPropertyFormatter2({
|
|
2700
2739
|
outputReferences,
|
|
2701
2740
|
dictionary,
|
|
@@ -2703,9 +2742,9 @@ var semantic = {
|
|
|
2703
2742
|
usesDtcg
|
|
2704
2743
|
});
|
|
2705
2744
|
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
2706
|
-
const filteredTokens = R9.reject((token) =>
|
|
2745
|
+
const filteredTokens = R9.reject((token) => R9.equals(["_size", "mode-font-size"], token.path), tokens);
|
|
2707
2746
|
const [sizingTokens, restTokens] = R9.partition(
|
|
2708
|
-
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
2747
|
+
(t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
|
|
2709
2748
|
filteredTokens
|
|
2710
2749
|
);
|
|
2711
2750
|
const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
|
|
@@ -2718,64 +2757,56 @@ var semantic = {
|
|
|
2718
2757
|
formatted: t
|
|
2719
2758
|
}));
|
|
2720
2759
|
buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
|
|
2721
|
-
const
|
|
2722
|
-
const
|
|
2723
|
-
const content = `{
|
|
2760
|
+
const formattedTokens = [formattedMap.map(R9.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
|
|
2761
|
+
const content = `${selector} {
|
|
2724
2762
|
${formattedTokens.join("\n")}
|
|
2725
2763
|
}
|
|
2726
2764
|
`;
|
|
2727
2765
|
const body = R9.isNotNil(layer) ? `@layer ${layer} {
|
|
2728
|
-
${
|
|
2766
|
+
${content}
|
|
2729
2767
|
}
|
|
2730
|
-
` : `${
|
|
2768
|
+
` : `${content}
|
|
2731
2769
|
`;
|
|
2732
2770
|
return body;
|
|
2733
2771
|
}
|
|
2734
2772
|
};
|
|
2735
2773
|
|
|
2736
|
-
// src/tokens/process/formats/css/
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
R10.pathSatisfies(R10.includes("typography"), ["path"]),
|
|
2741
|
-
R10.pathSatisfies(R10.includes("fontFamily"), ["path"])
|
|
2742
|
-
]);
|
|
2743
|
-
var typography = {
|
|
2744
|
-
name: "ds/css-typography",
|
|
2745
|
-
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 }) => {
|
|
2746
2778
|
const { outputReferences, usesDtcg } = options;
|
|
2747
|
-
const { selector, layer
|
|
2748
|
-
const destination =
|
|
2779
|
+
const { selector, layer } = platform;
|
|
2780
|
+
const destination = file.destination;
|
|
2749
2781
|
const format = createPropertyFormatter3({
|
|
2750
2782
|
outputReferences,
|
|
2751
2783
|
dictionary,
|
|
2752
2784
|
format: "css",
|
|
2753
2785
|
usesDtcg
|
|
2754
2786
|
});
|
|
2755
|
-
const
|
|
2756
|
-
const formattedMap =
|
|
2787
|
+
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
2788
|
+
const formattedMap = tokens.map((token) => ({
|
|
2757
2789
|
token,
|
|
2758
2790
|
formatted: format(token)
|
|
2759
2791
|
}));
|
|
2760
2792
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2761
|
-
const formattedTokens = formattedMap.map(R10.
|
|
2762
|
-
const content =
|
|
2793
|
+
const formattedTokens = formattedMap.map(R10.prop("formatted")).join("\n");
|
|
2794
|
+
const content = `${selector} {
|
|
2763
2795
|
${formattedTokens}
|
|
2764
|
-
}
|
|
2796
|
+
}
|
|
2797
|
+
`;
|
|
2765
2798
|
const body = R10.isNotNil(layer) ? `@layer ${layer} {
|
|
2766
2799
|
${content}
|
|
2767
|
-
}
|
|
2800
|
+
}
|
|
2801
|
+
` : `${content}
|
|
2802
|
+
`;
|
|
2768
2803
|
return body;
|
|
2769
2804
|
}
|
|
2770
2805
|
};
|
|
2771
2806
|
|
|
2772
|
-
// src/tokens/process/formats/css.ts
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
colorCategory,
|
|
2776
|
-
semantic,
|
|
2777
|
-
typography
|
|
2778
|
-
};
|
|
2807
|
+
// src/tokens/process/formats/css/size-mode.ts
|
|
2808
|
+
import * as R12 from "ramda";
|
|
2809
|
+
import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
|
|
2779
2810
|
|
|
2780
2811
|
// src/tokens/process/transformers.ts
|
|
2781
2812
|
import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
|
|
@@ -2787,18 +2818,22 @@ var sizeRem = {
|
|
|
2787
2818
|
transitive: true,
|
|
2788
2819
|
filter: (token) => {
|
|
2789
2820
|
const hasWantedType = typeEquals(["dimension", "fontsize"], token);
|
|
2790
|
-
const hasWantedPath = pathStartsWithOneOf([
|
|
2821
|
+
const hasWantedPath = pathStartsWithOneOf([
|
|
2822
|
+
"border-radius",
|
|
2823
|
+
"font-size"
|
|
2824
|
+
/*, ['_size', 'mode-font-size']*/
|
|
2825
|
+
], token);
|
|
2791
2826
|
return hasWantedType && hasWantedPath;
|
|
2792
2827
|
},
|
|
2793
2828
|
transform: (token, config) => {
|
|
2794
2829
|
const value = getValue(token);
|
|
2795
2830
|
if (isPx(value)) {
|
|
2796
2831
|
const baseFont = config.basePxFontSize || 16;
|
|
2797
|
-
const
|
|
2798
|
-
if (
|
|
2832
|
+
const size2 = parseInt(value, 10);
|
|
2833
|
+
if (size2 === 0) {
|
|
2799
2834
|
return "0";
|
|
2800
2835
|
}
|
|
2801
|
-
return `${
|
|
2836
|
+
return `${size2 / baseFont}rem`;
|
|
2802
2837
|
}
|
|
2803
2838
|
return value;
|
|
2804
2839
|
}
|
|
@@ -2849,6 +2884,154 @@ var dsTransformers = [
|
|
|
2849
2884
|
"shadow/css/shorthand"
|
|
2850
2885
|
];
|
|
2851
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
|
+
|
|
2852
3035
|
// src/tokens/process/configs/color.ts
|
|
2853
3036
|
var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
|
|
2854
3037
|
const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
|
|
@@ -2870,7 +3053,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
|
|
|
2870
3053
|
{
|
|
2871
3054
|
destination: `color-scheme/${colorScheme2}.css`,
|
|
2872
3055
|
format: formats.colorScheme.name,
|
|
2873
|
-
filter: (token) => typeEquals("color", token) && !
|
|
3056
|
+
filter: (token) => typeEquals("color", token) && !R15.startsWith(["global"], token.path)
|
|
2874
3057
|
}
|
|
2875
3058
|
],
|
|
2876
3059
|
options: {
|
|
@@ -2921,7 +3104,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
2921
3104
|
};
|
|
2922
3105
|
|
|
2923
3106
|
// src/tokens/process/configs/semantic.ts
|
|
2924
|
-
import * as
|
|
3107
|
+
import * as R16 from "ramda";
|
|
2925
3108
|
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
2926
3109
|
var semanticVariables = ({ theme }) => {
|
|
2927
3110
|
const selector = `:root`;
|
|
@@ -2944,9 +3127,12 @@ var semanticVariables = ({ theme }) => {
|
|
|
2944
3127
|
destination: `semantic.css`,
|
|
2945
3128
|
format: formats.semantic.name,
|
|
2946
3129
|
filter: (token) => {
|
|
2947
|
-
const isUwantedToken =
|
|
2948
|
-
const isPrivateToken =
|
|
2949
|
-
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
|
+
);
|
|
2950
3136
|
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
2951
3137
|
const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
2952
3138
|
return unwantedTokens;
|
|
@@ -2956,9 +3142,126 @@ var semanticVariables = ({ theme }) => {
|
|
|
2956
3142
|
options: {
|
|
2957
3143
|
outputReferences: (token, options) => {
|
|
2958
3144
|
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
2959
|
-
|
|
2960
|
-
|
|
3145
|
+
return include && outputReferencesFilter(token, options);
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
};
|
|
3151
|
+
};
|
|
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
|
+
}
|
|
2961
3261
|
}
|
|
3262
|
+
],
|
|
3263
|
+
options: {
|
|
3264
|
+
outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
|
|
2962
3265
|
}
|
|
2963
3266
|
}
|
|
2964
3267
|
}
|
|
@@ -2999,12 +3302,9 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
2999
3302
|
destination: `typography/${typography2}.css`,
|
|
3000
3303
|
format: formats.typography.name,
|
|
3001
3304
|
filter: (token) => {
|
|
3002
|
-
const included = typeEquals(
|
|
3003
|
-
["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
|
|
3004
|
-
token
|
|
3005
|
-
);
|
|
3305
|
+
const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
|
|
3006
3306
|
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
3007
|
-
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"));
|
|
3008
3308
|
}
|
|
3009
3309
|
}
|
|
3010
3310
|
]
|
|
@@ -3016,13 +3316,13 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
3016
3316
|
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
3017
3317
|
import { kebabCase } from "change-case";
|
|
3018
3318
|
import pc from "picocolors";
|
|
3019
|
-
import * as
|
|
3319
|
+
import * as R19 from "ramda";
|
|
3020
3320
|
var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
3021
3321
|
const verboseLogging = buildOptions?.verbose;
|
|
3022
3322
|
const grouped$themes = groupThemes(processed$themes);
|
|
3023
3323
|
const permutations = permutateThemes(grouped$themes);
|
|
3024
3324
|
const ALL_DEPENDENT_ON = ["theme"];
|
|
3025
|
-
const keys2 =
|
|
3325
|
+
const keys2 = R19.keys(grouped$themes);
|
|
3026
3326
|
const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
3027
3327
|
if (verboseLogging) {
|
|
3028
3328
|
console.log(pc.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
@@ -3062,7 +3362,7 @@ function groupThemes(themes) {
|
|
|
3062
3362
|
}
|
|
3063
3363
|
return groups;
|
|
3064
3364
|
}
|
|
3065
|
-
var hasUnknownProps =
|
|
3365
|
+
var hasUnknownProps = R19.pipe(R19.values, R19.none(R19.equals("unknown")), R19.not);
|
|
3066
3366
|
function permutateThemes(groups) {
|
|
3067
3367
|
const separator = "_";
|
|
3068
3368
|
const permutations = cartesian(Object.values(groups));
|
|
@@ -3072,8 +3372,8 @@ function permutateThemes(groups) {
|
|
|
3072
3372
|
const { group, name, selectedTokenSets } = theme;
|
|
3073
3373
|
let updatedPermutation = acc.permutation;
|
|
3074
3374
|
if (group) {
|
|
3075
|
-
const groupProp =
|
|
3076
|
-
updatedPermutation =
|
|
3375
|
+
const groupProp = R19.lensProp(group);
|
|
3376
|
+
updatedPermutation = R19.set(groupProp, name, updatedPermutation);
|
|
3077
3377
|
}
|
|
3078
3378
|
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
3079
3379
|
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
@@ -3144,7 +3444,10 @@ var configs = {
|
|
|
3144
3444
|
dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
|
|
3145
3445
|
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
3146
3446
|
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
3447
|
+
sizeModeVariables,
|
|
3448
|
+
sizeVariables,
|
|
3147
3449
|
typographyVariables,
|
|
3450
|
+
typeScaleVariables,
|
|
3148
3451
|
semanticVariables
|
|
3149
3452
|
};
|
|
3150
3453
|
var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
|
|
@@ -3161,7 +3464,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
3161
3464
|
obj.filePath = tokenSet;
|
|
3162
3465
|
}
|
|
3163
3466
|
});
|
|
3164
|
-
tokenSource.tokens =
|
|
3467
|
+
tokenSource.tokens = R20.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
|
|
3165
3468
|
}
|
|
3166
3469
|
}
|
|
3167
3470
|
} else {
|
|
@@ -3212,6 +3515,9 @@ var buildOptions = {
|
|
|
3212
3515
|
var sd = new StyleDictionary2();
|
|
3213
3516
|
var buildConfigs = {
|
|
3214
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"] },
|
|
3215
3521
|
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
3216
3522
|
"main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
|
|
3217
3523
|
"support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
|
|
@@ -3247,9 +3553,6 @@ async function processPlatform(options) {
|
|
|
3247
3553
|
const platform = "css";
|
|
3248
3554
|
const tokenSets = type === "format" ? options.tokenSets : void 0;
|
|
3249
3555
|
const tokensDir = type === "build" ? options.tokensDir : void 0;
|
|
3250
|
-
const filteredProcessed$themes = processed$themes.filter(
|
|
3251
|
-
(theme) => R16.not(theme.group === "size" && theme.name !== "medium")
|
|
3252
|
-
);
|
|
3253
3556
|
const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
|
|
3254
3557
|
if (UNSAFE_DEFAULT_COLOR) {
|
|
3255
3558
|
console.warn(
|
|
@@ -3273,24 +3576,29 @@ async function processPlatform(options) {
|
|
|
3273
3576
|
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
3274
3577
|
buildOptions.colorGroups = colorGroups;
|
|
3275
3578
|
if (!buildOptions.defaultColor) {
|
|
3276
|
-
const customColors = getCustomColors(
|
|
3277
|
-
const firstMainColor =
|
|
3579
|
+
const customColors = getCustomColors(processed$themes, colorGroups);
|
|
3580
|
+
const firstMainColor = R21.head(customColors);
|
|
3278
3581
|
buildOptions.defaultColor = firstMainColor;
|
|
3279
3582
|
}
|
|
3280
3583
|
if (buildOptions.defaultColor) {
|
|
3281
3584
|
console.log(`
|
|
3282
3585
|
\u{1F3A8} Using ${pc2.blue(buildOptions.defaultColor)} as default color`);
|
|
3283
3586
|
}
|
|
3284
|
-
const
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
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
|
+
});
|
|
3294
3602
|
const unknownConfigs = buildConfig.dimensions.map(
|
|
3295
3603
|
(dimension) => sdConfigs.filter((x) => x.permutation[dimension] === "unknown")
|
|
3296
3604
|
);
|
|
@@ -3314,10 +3622,13 @@ async function processPlatform(options) {
|
|
|
3314
3622
|
"warning-color": [initResult],
|
|
3315
3623
|
"info-color": [initResult],
|
|
3316
3624
|
semantic: [initResult],
|
|
3317
|
-
typography: [initResult]
|
|
3625
|
+
typography: [initResult],
|
|
3626
|
+
sizeMode: [initResult],
|
|
3627
|
+
size: [initResult],
|
|
3628
|
+
typeScale: [initResult]
|
|
3318
3629
|
};
|
|
3319
3630
|
try {
|
|
3320
|
-
for (const [buildName, { buildConfig, sdConfigs }] of
|
|
3631
|
+
for (const [buildName, { buildConfig, sdConfigs }] of R21.toPairs(buildAndSdConfigs)) {
|
|
3321
3632
|
if (!(buildConfig.enabled?.() ?? true)) {
|
|
3322
3633
|
continue;
|
|
3323
3634
|
}
|
|
@@ -3329,7 +3640,7 @@ async function processPlatform(options) {
|
|
|
3329
3640
|
const { config, permutation } = sdConfig;
|
|
3330
3641
|
const modes = ["theme", ...buildConfig.dimensions];
|
|
3331
3642
|
const modeMessage = modes.map((x) => permutation[x]).join(" - ");
|
|
3332
|
-
const logMessage =
|
|
3643
|
+
const logMessage = R21.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
|
|
3333
3644
|
console.log(logMessage);
|
|
3334
3645
|
const sdOptions = { cache: true };
|
|
3335
3646
|
const sdExtended = await sd.extend(config);
|