@digdir/designsystemet 1.0.4 → 1.0.6
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/LICENSE +7 -0
- package/dist/bin/designsystemet.js +623 -593
- package/dist/src/colors/index.js +32 -0
- package/dist/src/colors/theme.js +1 -0
- package/dist/src/colors/utils.d.ts +13 -0
- package/dist/src/colors/utils.d.ts.map +1 -1
- package/dist/src/colors/utils.js +32 -0
- package/dist/src/config.js +1 -0
- package/dist/src/index.js +196 -142
- package/dist/src/scripts/createJsonSchema.js +39 -38
- package/dist/src/scripts/update-design-tokens.js +1 -0
- package/dist/src/tokens/build.d.ts.map +1 -1
- package/dist/src/tokens/build.js +353 -590
- package/dist/src/tokens/create/generators/$designsystemet.js +22 -19
- package/dist/src/tokens/create/generators/$themes.js +10 -10
- package/dist/src/tokens/create/generators/color.js +1 -0
- package/dist/src/tokens/create/write.js +32 -29
- package/dist/src/tokens/create.js +1 -0
- package/dist/src/tokens/format.d.ts +4 -5
- package/dist/src/tokens/format.d.ts.map +1 -1
- package/dist/src/tokens/format.js +165 -143
- package/dist/src/tokens/index.js +165 -142
- package/dist/src/tokens/process/configs/color.js +26 -22
- package/dist/src/tokens/process/configs/semantic.js +16 -12
- package/dist/src/tokens/process/configs/shared.js +16 -12
- package/dist/src/tokens/process/configs/storefront.js +16 -12
- package/dist/src/tokens/process/configs/typography.js +16 -12
- package/dist/src/tokens/process/configs.js +26 -22
- package/dist/src/tokens/process/formats/css/color.js +16 -12
- package/dist/src/tokens/process/formats/css/semantic.js +16 -12
- package/dist/src/tokens/process/formats/css.js +16 -12
- package/dist/src/tokens/process/formats/js-tokens.js +16 -12
- package/dist/src/tokens/process/platform.js +27 -23
- package/dist/src/tokens/process/theme.d.ts +27 -0
- package/dist/src/tokens/process/theme.d.ts.map +1 -0
- package/dist/src/tokens/process/theme.js +174 -0
- package/dist/src/tokens/process/transformers.js +16 -12
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +26 -22
- package/dist/src/tokens/types.d.ts +4 -0
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/utils.d.ts +2 -2
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +16 -12
- package/package.json +31 -28
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
import path4 from "node:path";
|
|
5
5
|
import { Argument, createCommand, program } from "@commander-js/extra-typings";
|
|
6
6
|
import chalk8 from "chalk";
|
|
7
|
-
import * as
|
|
7
|
+
import * as R25 from "ramda";
|
|
8
8
|
import { fromError } from "zod-validation-error";
|
|
9
9
|
|
|
10
10
|
// src/colors/utils.ts
|
|
11
11
|
import chroma from "chroma-js";
|
|
12
|
+
import Colorjs from "colorjs.io";
|
|
12
13
|
import { Hsluv } from "hsluv";
|
|
13
14
|
var getLuminanceFromLightness = (lightness) => {
|
|
14
15
|
const conv = new Hsluv();
|
|
@@ -2678,19 +2679,20 @@ var migrations_default = {
|
|
|
2678
2679
|
// src/tokens/build.ts
|
|
2679
2680
|
import path2 from "node:path";
|
|
2680
2681
|
import chalk6 from "chalk";
|
|
2682
|
+
import * as R23 from "ramda";
|
|
2681
2683
|
|
|
2682
|
-
// src/tokens/
|
|
2683
|
-
import * as
|
|
2684
|
-
import
|
|
2684
|
+
// src/tokens/process/theme.ts
|
|
2685
|
+
import * as R10 from "ramda";
|
|
2686
|
+
import chalk3 from "chalk";
|
|
2685
2687
|
|
|
2686
2688
|
// package.json
|
|
2687
2689
|
var package_default = {
|
|
2688
2690
|
name: "@digdir/designsystemet",
|
|
2689
|
-
version: "1.0.
|
|
2691
|
+
version: "1.0.6",
|
|
2690
2692
|
description: "CLI for Designsystemet",
|
|
2691
2693
|
author: "Designsystemet team",
|
|
2692
2694
|
engines: {
|
|
2693
|
-
node: ">=22.
|
|
2695
|
+
node: ">=22.15.0"
|
|
2694
2696
|
},
|
|
2695
2697
|
repository: {
|
|
2696
2698
|
type: "git",
|
|
@@ -2720,431 +2722,181 @@ var package_default = {
|
|
|
2720
2722
|
},
|
|
2721
2723
|
scripts: {
|
|
2722
2724
|
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
2723
|
-
"build:tokens": "
|
|
2725
|
+
"build:tokens": "pnpm run designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
|
|
2724
2726
|
"build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
|
|
2725
|
-
build: "tsup &&
|
|
2727
|
+
build: "tsup && pnpm build:types && pnpm build:json-schema",
|
|
2726
2728
|
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
2727
2729
|
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
2728
2730
|
types: "tsc --noEmit",
|
|
2729
|
-
"test:tokens-create-options":
|
|
2730
|
-
"test:tokens-create-config": "
|
|
2731
|
-
"test:tokens-build": "
|
|
2732
|
-
"test:tokens-
|
|
2733
|
-
"test:tokens-create-and-build-
|
|
2734
|
-
|
|
2735
|
-
"
|
|
2731
|
+
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./test-tokens/options --theme options --clean',
|
|
2732
|
+
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./test/test-tokens.config.json",
|
|
2733
|
+
"test:tokens-build": "pnpm run designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
|
|
2734
|
+
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
|
|
2735
|
+
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
2736
|
+
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
2737
|
+
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
2738
|
+
"internal:tokens-create": "pnpm run designsystemet tokens create --config ./internal.config.json",
|
|
2736
2739
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
2737
|
-
"update:design-tokens": "
|
|
2738
|
-
verify: "
|
|
2740
|
+
"update:design-tokens": "pnpm internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
|
|
2741
|
+
verify: "pnpm test && pnpm update:template && pnpm update:design-tokens"
|
|
2739
2742
|
},
|
|
2740
2743
|
dependencies: {
|
|
2741
2744
|
"@commander-js/extra-typings": "^13.1.0",
|
|
2742
|
-
"@tokens-studio/sd-transforms": "1.
|
|
2745
|
+
"@tokens-studio/sd-transforms": "1.3.0",
|
|
2743
2746
|
"apca-w3": "^0.1.9",
|
|
2744
2747
|
chalk: "^5.4.1",
|
|
2745
2748
|
"change-case": "^5.4.4",
|
|
2746
2749
|
"chroma-js": "^3.1.2",
|
|
2750
|
+
"colorjs.io": "^0.6.0-alpha.1",
|
|
2747
2751
|
commander: "^13.1.0",
|
|
2748
2752
|
"fast-glob": "^3.3.3",
|
|
2749
2753
|
hsluv: "^1.0.1",
|
|
2750
2754
|
"object-hash": "^3.0.0",
|
|
2751
2755
|
postcss: "^8.5.3",
|
|
2752
2756
|
ramda: "^0.30.1",
|
|
2753
|
-
"style-dictionary": "^4.
|
|
2754
|
-
zod: "^3.24.
|
|
2757
|
+
"style-dictionary": "^4.4.0",
|
|
2758
|
+
zod: "^3.24.4",
|
|
2755
2759
|
"zod-validation-error": "^3.4.0"
|
|
2756
2760
|
},
|
|
2757
2761
|
devDependencies: {
|
|
2762
|
+
"@tokens-studio/types": "0.5.2",
|
|
2758
2763
|
"@types/apca-w3": "^0.1.3",
|
|
2759
2764
|
"@types/chroma-js": "^3.1.1",
|
|
2760
2765
|
"@types/fs-extra": "^11.0.4",
|
|
2761
2766
|
"@types/glob": "^8.1.0",
|
|
2762
2767
|
"@types/jscodeshift": "^0.12.0",
|
|
2763
|
-
"@types/node": "^22.
|
|
2768
|
+
"@types/node": "^22.15.3",
|
|
2764
2769
|
"@types/object-hash": "^3.0.6",
|
|
2765
2770
|
"@types/ramda": "^0.30.2",
|
|
2766
2771
|
"fs-extra": "^11.3.0",
|
|
2767
2772
|
"ts-toolbelt": "^9.6.0",
|
|
2768
2773
|
tslib: "^2.8.1",
|
|
2769
2774
|
tsup: "^8.4.0",
|
|
2770
|
-
tsx: "^4.19.
|
|
2771
|
-
typescript: "^5.8.
|
|
2775
|
+
tsx: "^4.19.4",
|
|
2776
|
+
typescript: "^5.8.3",
|
|
2772
2777
|
"zod-to-json-schema": "^3.24.5"
|
|
2773
2778
|
}
|
|
2774
2779
|
};
|
|
2775
2780
|
|
|
2776
|
-
//
|
|
2777
|
-
var
|
|
2778
|
-
(
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
})
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
}
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
|
|
2827
|
-
Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
|
|
2828
|
-
Properties2["borderWidth"] = "borderWidth";
|
|
2829
|
-
Properties2["borderWidthTop"] = "borderWidthTop";
|
|
2830
|
-
Properties2["borderWidthRight"] = "borderWidthRight";
|
|
2831
|
-
Properties2["borderWidthBottom"] = "borderWidthBottom";
|
|
2832
|
-
Properties2["borderWidthLeft"] = "borderWidthLeft";
|
|
2833
|
-
Properties2["boxShadow"] = "boxShadow";
|
|
2834
|
-
Properties2["opacity"] = "opacity";
|
|
2835
|
-
Properties2["fontFamilies"] = "fontFamilies";
|
|
2836
|
-
Properties2["fontWeights"] = "fontWeights";
|
|
2837
|
-
Properties2["fontSizes"] = "fontSizes";
|
|
2838
|
-
Properties2["lineHeights"] = "lineHeights";
|
|
2839
|
-
Properties2["typography"] = "typography";
|
|
2840
|
-
Properties2["composition"] = "composition";
|
|
2841
|
-
Properties2["letterSpacing"] = "letterSpacing";
|
|
2842
|
-
Properties2["paragraphSpacing"] = "paragraphSpacing";
|
|
2843
|
-
Properties2["textCase"] = "textCase";
|
|
2844
|
-
Properties2["dimension"] = "dimension";
|
|
2845
|
-
Properties2["textDecoration"] = "textDecoration";
|
|
2846
|
-
Properties2["asset"] = "asset";
|
|
2847
|
-
Properties2["tokenValue"] = "tokenValue";
|
|
2848
|
-
Properties2["value"] = "value";
|
|
2849
|
-
Properties2["tokenName"] = "tokenName";
|
|
2850
|
-
Properties2["description"] = "description";
|
|
2851
|
-
})(Properties || (Properties = {}));
|
|
2781
|
+
// src/tokens/process/theme.ts
|
|
2782
|
+
var defaultFileHeader = `build: v${package_default.version}`;
|
|
2783
|
+
var createThemeCSSFiles = ({
|
|
2784
|
+
processedBuilds,
|
|
2785
|
+
fileHeader: fileHeader2 = defaultFileHeader
|
|
2786
|
+
}) => {
|
|
2787
|
+
const groupedByTheme = {};
|
|
2788
|
+
for (const [_, buildResults] of Object.entries(R10.dissoc("types", processedBuilds))) {
|
|
2789
|
+
for (const buildResult of buildResults) {
|
|
2790
|
+
const themeName = buildResult.permutation.theme;
|
|
2791
|
+
const newOutputs = buildResult.formatted;
|
|
2792
|
+
if (R10.isNotEmpty(newOutputs)) {
|
|
2793
|
+
const currentOutputs = groupedByTheme[themeName] ?? [];
|
|
2794
|
+
groupedByTheme[themeName] = R10.concat(currentOutputs, newOutputs);
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
const sortOrder = [
|
|
2799
|
+
"color-scheme/light",
|
|
2800
|
+
"typography/secondary",
|
|
2801
|
+
"semantic",
|
|
2802
|
+
"color-scheme/dark",
|
|
2803
|
+
"color-scheme/contrast",
|
|
2804
|
+
"typography/primary",
|
|
2805
|
+
"color/"
|
|
2806
|
+
];
|
|
2807
|
+
const sortByDefinedOrder = R10.sortBy((file) => {
|
|
2808
|
+
const filePath = file.destination || "";
|
|
2809
|
+
const sortIndex = sortOrder.findIndex((sortElement) => {
|
|
2810
|
+
if (sortElement.endsWith("/")) {
|
|
2811
|
+
return filePath.includes(sortElement);
|
|
2812
|
+
}
|
|
2813
|
+
return filePath.includes(`${sortElement}.css`);
|
|
2814
|
+
});
|
|
2815
|
+
if (sortIndex === -1) {
|
|
2816
|
+
console.error(
|
|
2817
|
+
chalk3.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
|
|
2818
|
+
);
|
|
2819
|
+
console.log(
|
|
2820
|
+
chalk3.dim(
|
|
2821
|
+
`
|
|
2822
|
+
The section will currently be added to the end of the entry file, but the exact
|
|
2823
|
+
order may change due to nondeterminism.`.trim()
|
|
2824
|
+
)
|
|
2825
|
+
);
|
|
2826
|
+
return Infinity;
|
|
2827
|
+
}
|
|
2828
|
+
return sortIndex;
|
|
2829
|
+
});
|
|
2830
|
+
const header = `@charset "UTF-8";
|
|
2852
2831
|
|
|
2853
|
-
|
|
2854
|
-
var TokenSetStatus;
|
|
2855
|
-
(function(TokenSetStatus2) {
|
|
2856
|
-
TokenSetStatus2["DISABLED"] = "disabled";
|
|
2857
|
-
TokenSetStatus2["SOURCE"] = "source";
|
|
2858
|
-
TokenSetStatus2["ENABLED"] = "enabled";
|
|
2859
|
-
})(TokenSetStatus || (TokenSetStatus = {}));
|
|
2832
|
+
@layer ds.theme, ds.base, ds.utilities, ds.components;
|
|
2860
2833
|
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
TokenTypes2["OTHER"] = "other";
|
|
2865
|
-
TokenTypes2["COLOR"] = "color";
|
|
2866
|
-
TokenTypes2["BORDER_RADIUS"] = "borderRadius";
|
|
2867
|
-
TokenTypes2["SIZING"] = "sizing";
|
|
2868
|
-
TokenTypes2["SPACING"] = "spacing";
|
|
2869
|
-
TokenTypes2["TEXT"] = "text";
|
|
2870
|
-
TokenTypes2["TYPOGRAPHY"] = "typography";
|
|
2871
|
-
TokenTypes2["OPACITY"] = "opacity";
|
|
2872
|
-
TokenTypes2["BORDER_WIDTH"] = "borderWidth";
|
|
2873
|
-
TokenTypes2["STROKE_STYLE"] = "strokeStyle";
|
|
2874
|
-
TokenTypes2["BOX_SHADOW"] = "boxShadow";
|
|
2875
|
-
TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
|
|
2876
|
-
TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
|
|
2877
|
-
TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
|
|
2878
|
-
TokenTypes2["FONT_SIZES"] = "fontSizes";
|
|
2879
|
-
TokenTypes2["LETTER_SPACING"] = "letterSpacing";
|
|
2880
|
-
TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
2881
|
-
TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
2882
|
-
TokenTypes2["TEXT_DECORATION"] = "textDecoration";
|
|
2883
|
-
TokenTypes2["TEXT_CASE"] = "textCase";
|
|
2884
|
-
TokenTypes2["COMPOSITION"] = "composition";
|
|
2885
|
-
TokenTypes2["DIMENSION"] = "dimension";
|
|
2886
|
-
TokenTypes2["BORDER"] = "border";
|
|
2887
|
-
TokenTypes2["ASSET"] = "asset";
|
|
2888
|
-
TokenTypes2["BOOLEAN"] = "boolean";
|
|
2889
|
-
TokenTypes2["NUMBER"] = "number";
|
|
2890
|
-
})(TokenTypes || (TokenTypes = {}));
|
|
2834
|
+
/*
|
|
2835
|
+
${fileHeader2}
|
|
2836
|
+
*/
|
|
2891
2837
|
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
(
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2838
|
+
`;
|
|
2839
|
+
const sortAlphabetically = R10.sort(R10.ascend((x) => x.destination || ""));
|
|
2840
|
+
const pickOutputs = R10.map(R10.view(R10.lensProp("output")));
|
|
2841
|
+
const themeCSSFile = R10.pipe(
|
|
2842
|
+
sortAlphabetically,
|
|
2843
|
+
sortByDefinedOrder,
|
|
2844
|
+
pickOutputs,
|
|
2845
|
+
R10.join("\n"),
|
|
2846
|
+
(content) => header + content
|
|
2847
|
+
);
|
|
2848
|
+
const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
|
|
2849
|
+
destination: `${theme}.css`,
|
|
2850
|
+
output: themeCSSFile(files)
|
|
2851
|
+
}));
|
|
2852
|
+
return themeCSSFiles;
|
|
2853
|
+
};
|
|
2899
2854
|
|
|
2900
|
-
//
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
StrokeStyleValues2["DASHED"] = "dashed";
|
|
2905
|
-
StrokeStyleValues2["DOTTED"] = "dotted";
|
|
2906
|
-
StrokeStyleValues2["DOUBLE"] = "double";
|
|
2907
|
-
StrokeStyleValues2["GROOVE"] = "groove";
|
|
2908
|
-
StrokeStyleValues2["RIDGE"] = "ridge";
|
|
2909
|
-
StrokeStyleValues2["OUTSET"] = "outset";
|
|
2910
|
-
StrokeStyleValues2["INSET"] = "inset";
|
|
2911
|
-
})(StrokeStyleValues || (StrokeStyleValues = {}));
|
|
2855
|
+
// src/tokens/process/platform.ts
|
|
2856
|
+
import chalk5 from "chalk";
|
|
2857
|
+
import * as R22 from "ramda";
|
|
2858
|
+
import StyleDictionary2 from "style-dictionary";
|
|
2912
2859
|
|
|
2913
|
-
//
|
|
2914
|
-
var
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
BoxShadowValues2["X"] = "x";
|
|
2919
|
-
BoxShadowValues2["Y"] = "y";
|
|
2920
|
-
BoxShadowValues2["BLUR"] = "blur";
|
|
2921
|
-
BoxShadowValues2["SPREAD"] = "spread";
|
|
2922
|
-
BoxShadowValues2["BLEND_MODE"] = "blendMode";
|
|
2923
|
-
})(BoxShadowValues || (BoxShadowValues = {}));
|
|
2860
|
+
// src/tokens/types.ts
|
|
2861
|
+
var colorCategories = {
|
|
2862
|
+
main: "main",
|
|
2863
|
+
support: "support"
|
|
2864
|
+
};
|
|
2924
2865
|
|
|
2925
|
-
//
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
TypographyValues2["FONT_WEIGHT"] = "fontWeight";
|
|
2930
|
-
TypographyValues2["LINE_HEIGHT"] = "lineHeight";
|
|
2931
|
-
TypographyValues2["FONT_SIZE"] = "fontSize";
|
|
2932
|
-
TypographyValues2["LETTER_SPACING"] = "letterSpacing";
|
|
2933
|
-
TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
2934
|
-
TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
2935
|
-
TypographyValues2["TEXT_DECORATION"] = "textDecoration";
|
|
2936
|
-
TypographyValues2["TEXT_CASE"] = "textCase";
|
|
2937
|
-
})(TypographyValues || (TypographyValues = {}));
|
|
2866
|
+
// src/tokens/process/configs.ts
|
|
2867
|
+
import { register } from "@tokens-studio/sd-transforms";
|
|
2868
|
+
import * as R21 from "ramda";
|
|
2869
|
+
import StyleDictionary from "style-dictionary";
|
|
2938
2870
|
|
|
2939
|
-
// src/tokens/
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2871
|
+
// src/tokens/utils.ts
|
|
2872
|
+
import * as R11 from "ramda";
|
|
2873
|
+
var mapToLowerCase = R11.map(R11.toLower);
|
|
2874
|
+
var hasAnyTruth = R11.any(R11.equals(true));
|
|
2875
|
+
var getType = (token) => (token.$type ?? token.type) || "";
|
|
2876
|
+
var getValue = (token) => token.$value ?? token.value;
|
|
2877
|
+
var typeEquals = R11.curry(
|
|
2878
|
+
(types, token) => {
|
|
2879
|
+
if (R11.isNil(token)) {
|
|
2880
|
+
return false;
|
|
2881
|
+
}
|
|
2882
|
+
return R11.includes(R11.toLower(getType(token)), R11.map(R11.toLower, Array.isArray(types) ? types : [types]));
|
|
2883
|
+
}
|
|
2884
|
+
);
|
|
2885
|
+
var pathStartsWithOneOf = R11.curry(
|
|
2886
|
+
(paths, token) => {
|
|
2887
|
+
if (R11.isNil(token)) {
|
|
2888
|
+
return false;
|
|
2889
|
+
}
|
|
2890
|
+
const tokenPath = mapToLowerCase(token.path);
|
|
2891
|
+
const matchPathsStartingWith = R11.map((path5) => R11.startsWith([path5], tokenPath), mapToLowerCase(paths));
|
|
2892
|
+
return hasAnyTruth(matchPathsStartingWith);
|
|
2893
|
+
}
|
|
2894
|
+
);
|
|
2895
|
+
function isSemanticToken(token) {
|
|
2896
|
+
return token.filePath.includes("semantic/");
|
|
2947
2897
|
}
|
|
2948
|
-
|
|
2949
|
-
return [
|
|
2950
|
-
...generateSizeGroup(),
|
|
2951
|
-
...await generateThemesGroup(themes),
|
|
2952
|
-
...generateTypographyGroup(themes),
|
|
2953
|
-
...generateColorSchemesGroup(colorSchemes, themes),
|
|
2954
|
-
generateSemanticGroup(),
|
|
2955
|
-
...await generateColorGroup("main", colors2),
|
|
2956
|
-
...await generateColorGroup("support", colors2)
|
|
2957
|
-
];
|
|
2958
|
-
}
|
|
2959
|
-
function generateSizeGroup() {
|
|
2960
|
-
return [
|
|
2961
|
-
{
|
|
2962
|
-
id: "8b2c8cc86611a34b135cb22948666779361fd729",
|
|
2963
|
-
name: "medium",
|
|
2964
|
-
$figmaStyleReferences: {},
|
|
2965
|
-
selectedTokenSets: {
|
|
2966
|
-
"primitives/modes/size/medium": TokenSetStatus.SOURCE,
|
|
2967
|
-
"primitives/modes/size/global": TokenSetStatus.ENABLED,
|
|
2968
|
-
"primitives/modes/typography/size/medium": TokenSetStatus.ENABLED
|
|
2969
|
-
},
|
|
2970
|
-
$figmaCollectionId: "VariableCollectionId:36248:20757",
|
|
2971
|
-
$figmaModeId: "41630:1",
|
|
2972
|
-
group: "Size"
|
|
2973
|
-
},
|
|
2974
|
-
{
|
|
2975
|
-
id: "d49b9eebeb48a4f165a74b7261733d0a73370f0e",
|
|
2976
|
-
name: "large",
|
|
2977
|
-
$figmaStyleReferences: {},
|
|
2978
|
-
selectedTokenSets: {
|
|
2979
|
-
"primitives/modes/size/large": TokenSetStatus.SOURCE,
|
|
2980
|
-
"primitives/modes/size/global": TokenSetStatus.ENABLED,
|
|
2981
|
-
"primitives/modes/typography/size/large": TokenSetStatus.ENABLED
|
|
2982
|
-
},
|
|
2983
|
-
$figmaCollectionId: "VariableCollectionId:36248:20757",
|
|
2984
|
-
$figmaModeId: "41630:2",
|
|
2985
|
-
group: "Size"
|
|
2986
|
-
},
|
|
2987
|
-
{
|
|
2988
|
-
id: "fb11567729c298ca37c9da4e3a27716a23480824",
|
|
2989
|
-
name: "small",
|
|
2990
|
-
$figmaStyleReferences: {},
|
|
2991
|
-
selectedTokenSets: {
|
|
2992
|
-
"primitives/modes/size/small": TokenSetStatus.SOURCE,
|
|
2993
|
-
"primitives/modes/size/global": TokenSetStatus.ENABLED,
|
|
2994
|
-
"primitives/modes/typography/size/small": TokenSetStatus.ENABLED
|
|
2995
|
-
},
|
|
2996
|
-
$figmaCollectionId: "VariableCollectionId:36248:20757",
|
|
2997
|
-
$figmaModeId: "41630:3",
|
|
2998
|
-
group: "Size"
|
|
2999
|
-
}
|
|
3000
|
-
];
|
|
3001
|
-
}
|
|
3002
|
-
var colorSchemeDefaults = {
|
|
3003
|
-
light: {
|
|
3004
|
-
name: "Light",
|
|
3005
|
-
selectedTokenSets: {},
|
|
3006
|
-
id: "0daa3ca0b427b9349da7e7dc00101b5668972926",
|
|
3007
|
-
$figmaCollectionId: "VariableCollectionId:34811:5472",
|
|
3008
|
-
$figmaModeId: "34811:0"
|
|
3009
|
-
},
|
|
3010
|
-
dark: {
|
|
3011
|
-
name: "Dark",
|
|
3012
|
-
selectedTokenSets: {},
|
|
3013
|
-
id: "9ebd8aed52afbffc17e2666e8b4653a53498b257",
|
|
3014
|
-
$figmaCollectionId: "VariableCollectionId:34811:5472",
|
|
3015
|
-
$figmaModeId: "34811:1"
|
|
3016
|
-
},
|
|
3017
|
-
contrast: {
|
|
3018
|
-
name: "Contrast",
|
|
3019
|
-
selectedTokenSets: {},
|
|
3020
|
-
id: "9ebd8aed52afbffc17e2666e8b4653a53498b123",
|
|
3021
|
-
$figmaCollectionId: "VariableCollectionId:34811:5472",
|
|
3022
|
-
$figmaModeId: "34811:2"
|
|
3023
|
-
}
|
|
3024
|
-
};
|
|
3025
|
-
function generateColorSchemesGroup(colorSchemes, themes) {
|
|
3026
|
-
return colorSchemes.map(
|
|
3027
|
-
(scheme) => ({
|
|
3028
|
-
...colorSchemeDefaults[scheme],
|
|
3029
|
-
selectedTokenSets: Object.fromEntries([
|
|
3030
|
-
[`primitives/modes/color-scheme/${scheme}/global`, TokenSetStatus.ENABLED],
|
|
3031
|
-
...themes.map((theme) => [`primitives/modes/color-scheme/${scheme}/${theme}`, TokenSetStatus.ENABLED])
|
|
3032
|
-
]),
|
|
3033
|
-
group: "Color scheme"
|
|
3034
|
-
})
|
|
3035
|
-
);
|
|
3036
|
-
}
|
|
3037
|
-
async function generateThemesGroup(themes) {
|
|
3038
|
-
return Promise.all(
|
|
3039
|
-
themes.map(
|
|
3040
|
-
async (theme, index) => ({
|
|
3041
|
-
id: await createHash(theme),
|
|
3042
|
-
$figmaCollectionId: "VariableCollectionId:36528:61712",
|
|
3043
|
-
$figmaModeId: `40960:${index + 6}`,
|
|
3044
|
-
// Start on 6 in Token Studio and Community file for some reason
|
|
3045
|
-
name: theme,
|
|
3046
|
-
selectedTokenSets: {
|
|
3047
|
-
[`themes/${theme}`]: TokenSetStatus.ENABLED
|
|
3048
|
-
},
|
|
3049
|
-
group: "Theme"
|
|
3050
|
-
})
|
|
3051
|
-
)
|
|
3052
|
-
);
|
|
3053
|
-
}
|
|
3054
|
-
function generateSemanticGroup() {
|
|
3055
|
-
return {
|
|
3056
|
-
id: "541629445ef90ad5363f9e88f52a1ccb617e6f84",
|
|
3057
|
-
name: "Semantic",
|
|
3058
|
-
selectedTokenSets: {
|
|
3059
|
-
"semantic/style": TokenSetStatus.ENABLED,
|
|
3060
|
-
"semantic/color": TokenSetStatus.ENABLED,
|
|
3061
|
-
"primitives/globals": TokenSetStatus.SOURCE
|
|
3062
|
-
},
|
|
3063
|
-
$figmaCollectionId: "VariableCollectionId:34811:5976",
|
|
3064
|
-
$figmaModeId: "34811:5",
|
|
3065
|
-
group: "Semantic"
|
|
3066
|
-
};
|
|
3067
|
-
}
|
|
3068
|
-
async function generateColorGroup(group, colors2) {
|
|
3069
|
-
return Promise.all(
|
|
3070
|
-
Object.entries(colors2[group]).map(
|
|
3071
|
-
async ([color]) => ({
|
|
3072
|
-
id: await createHash(`${group}-${color}`),
|
|
3073
|
-
name: color,
|
|
3074
|
-
selectedTokenSets: {
|
|
3075
|
-
[`semantic/modes/${group}-color/${color}`]: TokenSetStatus.ENABLED
|
|
3076
|
-
},
|
|
3077
|
-
group: `${capitalize(group)} color`
|
|
3078
|
-
})
|
|
3079
|
-
)
|
|
3080
|
-
);
|
|
3081
|
-
}
|
|
3082
|
-
function generateTypographyGroup(themes) {
|
|
3083
|
-
return [
|
|
3084
|
-
{
|
|
3085
|
-
id: "368d753fcac4455f289500eaa42e70dc0a03522f",
|
|
3086
|
-
$figmaCollectionId: "VariableCollectionId:36248:20769",
|
|
3087
|
-
$figmaModeId: "36248:2",
|
|
3088
|
-
name: "Primary",
|
|
3089
|
-
selectedTokenSets: Object.fromEntries(
|
|
3090
|
-
themes.map((theme) => [`primitives/modes/typography/primary/${theme}`, TokenSetStatus.ENABLED])
|
|
3091
|
-
),
|
|
3092
|
-
group: "Typography"
|
|
3093
|
-
},
|
|
3094
|
-
{
|
|
3095
|
-
id: "264b8bd1d40b364e1ea3acf09e49795ddd4c513c",
|
|
3096
|
-
$figmaCollectionId: "VariableCollectionId:36248:20769",
|
|
3097
|
-
$figmaModeId: "36248:3",
|
|
3098
|
-
name: "Secondary",
|
|
3099
|
-
selectedTokenSets: Object.fromEntries(
|
|
3100
|
-
themes.map((theme) => [`primitives/modes/typography/secondary/${theme}`, TokenSetStatus.ENABLED])
|
|
3101
|
-
),
|
|
3102
|
-
group: "Typography"
|
|
3103
|
-
}
|
|
3104
|
-
];
|
|
3105
|
-
}
|
|
3106
|
-
|
|
3107
|
-
// src/tokens/process/platform.ts
|
|
3108
|
-
import chalk4 from "chalk";
|
|
3109
|
-
import * as R21 from "ramda";
|
|
3110
|
-
import StyleDictionary2 from "style-dictionary";
|
|
3111
|
-
|
|
3112
|
-
// src/tokens/types.ts
|
|
3113
|
-
var colorCategories = {
|
|
3114
|
-
main: "main",
|
|
3115
|
-
support: "support"
|
|
3116
|
-
};
|
|
3117
|
-
|
|
3118
|
-
// src/tokens/process/configs.ts
|
|
3119
|
-
import { register } from "@tokens-studio/sd-transforms";
|
|
3120
|
-
import * as R20 from "ramda";
|
|
3121
|
-
import StyleDictionary from "style-dictionary";
|
|
3122
|
-
|
|
3123
|
-
// src/tokens/utils.ts
|
|
3124
|
-
import * as R10 from "ramda";
|
|
3125
|
-
var mapToLowerCase = R10.map(R10.toLower);
|
|
3126
|
-
var hasAnyTruth = R10.any(R10.equals(true));
|
|
3127
|
-
var getType = (token) => (token.$type ?? token.type) || "";
|
|
3128
|
-
var getValue = (token) => token.$value ?? token.value;
|
|
3129
|
-
var typeEquals = R10.curry((types, token) => {
|
|
3130
|
-
if (R10.isNil(token)) {
|
|
3131
|
-
return false;
|
|
3132
|
-
}
|
|
3133
|
-
return R10.includes(R10.toLower(getType(token)), R10.map(R10.toLower, Array.isArray(types) ? types : [types]));
|
|
3134
|
-
});
|
|
3135
|
-
var pathStartsWithOneOf = R10.curry((paths, token) => {
|
|
3136
|
-
if (R10.isNil(token)) {
|
|
3137
|
-
return false;
|
|
3138
|
-
}
|
|
3139
|
-
const tokenPath = mapToLowerCase(token.path);
|
|
3140
|
-
const matchPathsStartingWith = R10.map((path5) => R10.startsWith([path5], tokenPath), mapToLowerCase(paths));
|
|
3141
|
-
return hasAnyTruth(matchPathsStartingWith);
|
|
3142
|
-
});
|
|
3143
|
-
function isSemanticToken(token) {
|
|
3144
|
-
return token.filePath.includes("semantic/");
|
|
3145
|
-
}
|
|
3146
|
-
function isSemanticColorToken(token, color) {
|
|
3147
|
-
return token.filePath.includes("semantic/") && R10.startsWith(["color", color], token.path);
|
|
2898
|
+
function isSemanticColorToken(token, color) {
|
|
2899
|
+
return token.filePath.includes("semantic/") && R11.startsWith(["color", color], token.path);
|
|
3148
2900
|
}
|
|
3149
2901
|
function isGlobalColorToken(token) {
|
|
3150
2902
|
return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
|
|
@@ -3153,7 +2905,7 @@ function isColorCategoryToken(token, category) {
|
|
|
3153
2905
|
if (!category) {
|
|
3154
2906
|
return ["main", "support"].some((c) => isColorCategoryToken(token, c));
|
|
3155
2907
|
}
|
|
3156
|
-
return
|
|
2908
|
+
return R11.startsWith(["color", category], token.path);
|
|
3157
2909
|
}
|
|
3158
2910
|
var isDigit = (s) => /^\d+$/.test(s);
|
|
3159
2911
|
function traverseObj(obj, fn) {
|
|
@@ -3169,7 +2921,7 @@ function traverseObj(obj, fn) {
|
|
|
3169
2921
|
return obj;
|
|
3170
2922
|
}
|
|
3171
2923
|
function inlineTokens(shouldInline, tokens) {
|
|
3172
|
-
const [inlineableTokens, otherTokens] =
|
|
2924
|
+
const [inlineableTokens, otherTokens] = R11.partition(shouldInline, tokens);
|
|
3173
2925
|
return otherTokens.map((token) => {
|
|
3174
2926
|
let transformed = getValue(token.original);
|
|
3175
2927
|
for (const ref of inlineableTokens) {
|
|
@@ -3178,16 +2930,16 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
3178
2930
|
transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
|
|
3179
2931
|
}
|
|
3180
2932
|
}
|
|
3181
|
-
const tokenWithInlinedRefs =
|
|
2933
|
+
const tokenWithInlinedRefs = R11.set(R11.lensPath(["original", "$value"]), transformed, token);
|
|
3182
2934
|
return tokenWithInlinedRefs;
|
|
3183
2935
|
});
|
|
3184
2936
|
}
|
|
3185
2937
|
|
|
3186
2938
|
// src/tokens/process/configs/color.ts
|
|
3187
|
-
import * as
|
|
2939
|
+
import * as R16 from "ramda";
|
|
3188
2940
|
|
|
3189
2941
|
// src/tokens/process/formats/css/color.ts
|
|
3190
|
-
import * as
|
|
2942
|
+
import * as R12 from "ramda";
|
|
3191
2943
|
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
3192
2944
|
var prefersColorScheme = (colorScheme2, content) => `
|
|
3193
2945
|
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
@@ -3211,8 +2963,8 @@ var colorScheme = {
|
|
|
3211
2963
|
color-scheme: ${colorScheme_};
|
|
3212
2964
|
` : "";
|
|
3213
2965
|
const filteredAllTokens = allTokens.filter(
|
|
3214
|
-
|
|
3215
|
-
|
|
2966
|
+
R12.allPass([
|
|
2967
|
+
R12.anyPass([
|
|
3216
2968
|
// Include semantic tokens in the output
|
|
3217
2969
|
isSemanticToken,
|
|
3218
2970
|
// Include global color tokens
|
|
@@ -3228,7 +2980,7 @@ ${formattedTokens}
|
|
|
3228
2980
|
${colorSchemeProperty}}
|
|
3229
2981
|
`;
|
|
3230
2982
|
const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
|
|
3231
|
-
const body =
|
|
2983
|
+
const body = R12.isNotNil(layer) ? `@layer ${layer} {
|
|
3232
2984
|
${selector} ${content} ${autoSelectorContent}
|
|
3233
2985
|
}
|
|
3234
2986
|
` : `${selector} ${content} ${autoSelectorContent}
|
|
@@ -3241,7 +2993,7 @@ var colorCategory = {
|
|
|
3241
2993
|
format: async ({ dictionary, file, options, platform }) => {
|
|
3242
2994
|
const { outputReferences, usesDtcg } = options;
|
|
3243
2995
|
const { selector, layer } = platform;
|
|
3244
|
-
const format =
|
|
2996
|
+
const format = R12.compose(
|
|
3245
2997
|
createPropertyFormatter({
|
|
3246
2998
|
outputReferences,
|
|
3247
2999
|
dictionary,
|
|
@@ -3262,7 +3014,7 @@ var colorCategory = {
|
|
|
3262
3014
|
${formattedTokens}
|
|
3263
3015
|
}
|
|
3264
3016
|
`;
|
|
3265
|
-
const body =
|
|
3017
|
+
const body = R12.isNotNil(layer) ? `@layer ${layer} {
|
|
3266
3018
|
${selector} ${content}
|
|
3267
3019
|
}
|
|
3268
3020
|
` : `${selector} ${content}
|
|
@@ -3272,12 +3024,12 @@ ${selector} ${content}
|
|
|
3272
3024
|
};
|
|
3273
3025
|
|
|
3274
3026
|
// src/tokens/process/formats/css/semantic.ts
|
|
3275
|
-
import * as
|
|
3027
|
+
import * as R13 from "ramda";
|
|
3276
3028
|
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
3277
3029
|
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
3278
3030
|
var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
|
|
3279
3031
|
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
3280
|
-
var isInlineTokens =
|
|
3032
|
+
var isInlineTokens = R13.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
3281
3033
|
var overrideSizingFormula = (format, token) => {
|
|
3282
3034
|
const [name, value] = format(token).split(":");
|
|
3283
3035
|
const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
|
|
@@ -3289,7 +3041,7 @@ var overrideSizingFormula = (format, token) => {
|
|
|
3289
3041
|
};
|
|
3290
3042
|
};
|
|
3291
3043
|
var formatSizingTokens = (format, tokens) => {
|
|
3292
|
-
const { round, calc } =
|
|
3044
|
+
const { round, calc } = R13.reduce(
|
|
3293
3045
|
(acc, token) => {
|
|
3294
3046
|
const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
|
|
3295
3047
|
return {
|
|
@@ -3319,17 +3071,17 @@ var semantic = {
|
|
|
3319
3071
|
usesDtcg
|
|
3320
3072
|
});
|
|
3321
3073
|
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
3322
|
-
const filteredTokens =
|
|
3323
|
-
const [sizingTokens, restTokens] =
|
|
3074
|
+
const filteredTokens = R13.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
|
|
3075
|
+
const [sizingTokens, restTokens] = R13.partition(
|
|
3324
3076
|
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
3325
3077
|
filteredTokens
|
|
3326
3078
|
);
|
|
3327
|
-
const formattedTokens = [
|
|
3079
|
+
const formattedTokens = [R13.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
|
|
3328
3080
|
const content = `{
|
|
3329
3081
|
${formattedTokens.join("\n")}
|
|
3330
3082
|
}
|
|
3331
3083
|
`;
|
|
3332
|
-
const body =
|
|
3084
|
+
const body = R13.isNotNil(layer) ? `@layer ${layer} {
|
|
3333
3085
|
${selector} ${content}
|
|
3334
3086
|
}
|
|
3335
3087
|
` : `${selector} ${content}
|
|
@@ -3339,11 +3091,11 @@ ${selector} ${content}
|
|
|
3339
3091
|
};
|
|
3340
3092
|
|
|
3341
3093
|
// src/tokens/process/formats/css/typography.ts
|
|
3342
|
-
import * as
|
|
3094
|
+
import * as R14 from "ramda";
|
|
3343
3095
|
import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
|
|
3344
|
-
var typographyFontFamilyPredicate =
|
|
3345
|
-
|
|
3346
|
-
|
|
3096
|
+
var typographyFontFamilyPredicate = R14.allPass([
|
|
3097
|
+
R14.pathSatisfies(R14.includes("typography"), ["path"]),
|
|
3098
|
+
R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
|
|
3347
3099
|
]);
|
|
3348
3100
|
var typography = {
|
|
3349
3101
|
name: "ds/css-typography",
|
|
@@ -3356,12 +3108,12 @@ var typography = {
|
|
|
3356
3108
|
format: "css",
|
|
3357
3109
|
usesDtcg
|
|
3358
3110
|
});
|
|
3359
|
-
const filteredTokens =
|
|
3360
|
-
const formattedTokens =
|
|
3111
|
+
const filteredTokens = R14.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
3112
|
+
const formattedTokens = R14.pipe(R14.map(format), R14.join("\n"))(filteredTokens);
|
|
3361
3113
|
const content = selector ? `${selector} {
|
|
3362
3114
|
${formattedTokens}
|
|
3363
3115
|
}` : formattedTokens;
|
|
3364
|
-
const body =
|
|
3116
|
+
const body = R14.isNotNil(layer) ? `@layer ${layer} {
|
|
3365
3117
|
${content}
|
|
3366
3118
|
}` : content;
|
|
3367
3119
|
return body;
|
|
@@ -3378,8 +3130,8 @@ var formats = {
|
|
|
3378
3130
|
|
|
3379
3131
|
// src/tokens/process/transformers.ts
|
|
3380
3132
|
import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
|
|
3381
|
-
import * as
|
|
3382
|
-
var isPx =
|
|
3133
|
+
import * as R15 from "ramda";
|
|
3134
|
+
var isPx = R15.test(/\b\d+px\b/g);
|
|
3383
3135
|
var sizeRem = {
|
|
3384
3136
|
name: "ds/size/toRem",
|
|
3385
3137
|
type: "value",
|
|
@@ -3469,7 +3221,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
|
|
|
3469
3221
|
{
|
|
3470
3222
|
destination: `color-scheme/${colorScheme2}.css`,
|
|
3471
3223
|
format: formats.colorScheme.name,
|
|
3472
|
-
filter: (token) => typeEquals("color", token) && !
|
|
3224
|
+
filter: (token) => typeEquals("color", token) && !R16.startsWith(["global"], token.path)
|
|
3473
3225
|
}
|
|
3474
3226
|
],
|
|
3475
3227
|
options: {
|
|
@@ -3520,7 +3272,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
3520
3272
|
};
|
|
3521
3273
|
|
|
3522
3274
|
// src/tokens/process/configs/semantic.ts
|
|
3523
|
-
import * as
|
|
3275
|
+
import * as R17 from "ramda";
|
|
3524
3276
|
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
3525
3277
|
var semanticVariables = ({ theme }) => {
|
|
3526
3278
|
const selector = `:root`;
|
|
@@ -3543,8 +3295,8 @@ var semanticVariables = ({ theme }) => {
|
|
|
3543
3295
|
destination: `semantic.css`,
|
|
3544
3296
|
format: formats.semantic.name,
|
|
3545
3297
|
filter: (token) => {
|
|
3546
|
-
const isUwantedToken =
|
|
3547
|
-
const isPrivateToken =
|
|
3298
|
+
const isUwantedToken = R17.anyPass([R17.includes("primitives/global")])(token.filePath);
|
|
3299
|
+
const isPrivateToken = R17.includes("_", token.path);
|
|
3548
3300
|
const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
|
|
3549
3301
|
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
3550
3302
|
const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
@@ -3565,20 +3317,20 @@ var semanticVariables = ({ theme }) => {
|
|
|
3565
3317
|
};
|
|
3566
3318
|
|
|
3567
3319
|
// src/tokens/process/configs/storefront.ts
|
|
3568
|
-
import * as
|
|
3320
|
+
import * as R19 from "ramda";
|
|
3569
3321
|
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
3570
3322
|
|
|
3571
3323
|
// src/tokens/process/formats/js-tokens.ts
|
|
3572
|
-
import * as
|
|
3324
|
+
import * as R18 from "ramda";
|
|
3573
3325
|
import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
|
|
3574
|
-
var groupByType =
|
|
3575
|
-
var removeUnwatedTokens =
|
|
3576
|
-
|
|
3577
|
-
|
|
3326
|
+
var groupByType = R18.groupBy((token) => getType(token));
|
|
3327
|
+
var removeUnwatedTokens = R18.pipe(
|
|
3328
|
+
R18.reject((token) => isColorCategoryToken(token)),
|
|
3329
|
+
R18.reject((token) => R18.any((path5) => path5.startsWith("_"))(token.path))
|
|
3578
3330
|
);
|
|
3579
|
-
var dissocExtensions =
|
|
3580
|
-
var removeUnwatedProps =
|
|
3581
|
-
var toCssVarName =
|
|
3331
|
+
var dissocExtensions = R18.pipe(R18.dissoc("$extensions"), R18.dissocPath(["original", "$extensions"]));
|
|
3332
|
+
var removeUnwatedProps = R18.map((token) => dissocExtensions(token));
|
|
3333
|
+
var toCssVarName = R18.pipe(R18.split(":"), R18.head, R18.trim);
|
|
3582
3334
|
var jsTokens = {
|
|
3583
3335
|
name: "ds/js-tokens",
|
|
3584
3336
|
format: async ({ dictionary, file, options }) => {
|
|
@@ -3589,7 +3341,7 @@ var jsTokens = {
|
|
|
3589
3341
|
format: "css",
|
|
3590
3342
|
usesDtcg
|
|
3591
3343
|
});
|
|
3592
|
-
const formatTokens =
|
|
3344
|
+
const formatTokens = R18.map((token) => {
|
|
3593
3345
|
if (pathStartsWithOneOf(["size", "_size"], token)) {
|
|
3594
3346
|
const { calc, name } = overrideSizingFormula(format, token);
|
|
3595
3347
|
return {
|
|
@@ -3603,7 +3355,7 @@ var jsTokens = {
|
|
|
3603
3355
|
name: toCssVarName(format(token))
|
|
3604
3356
|
};
|
|
3605
3357
|
});
|
|
3606
|
-
const processTokens =
|
|
3358
|
+
const processTokens = R18.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens, groupByType);
|
|
3607
3359
|
const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
|
|
3608
3360
|
const content = Object.entries(tokens).map(
|
|
3609
3361
|
([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
|
|
@@ -3628,9 +3380,9 @@ var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
|
|
|
3628
3380
|
destination: `${colorScheme2}.ts`,
|
|
3629
3381
|
format: jsTokens.name,
|
|
3630
3382
|
filter: (token) => {
|
|
3631
|
-
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !
|
|
3383
|
+
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R19.includes("semantic", token.filePath))
|
|
3632
3384
|
return false;
|
|
3633
|
-
const isSemanticColor =
|
|
3385
|
+
const isSemanticColor = R19.includes("semantic", token.filePath) && typeEquals(["color"], token);
|
|
3634
3386
|
const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
|
|
3635
3387
|
return isSemanticColor || wantedTypes;
|
|
3636
3388
|
}
|
|
@@ -3695,82 +3447,245 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
3695
3447
|
};
|
|
3696
3448
|
};
|
|
3697
3449
|
|
|
3698
|
-
//
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
}
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3450
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
3451
|
+
var BoxShadowTypes;
|
|
3452
|
+
(function(BoxShadowTypes2) {
|
|
3453
|
+
BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
|
|
3454
|
+
BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
|
|
3455
|
+
})(BoxShadowTypes || (BoxShadowTypes = {}));
|
|
3456
|
+
|
|
3457
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
|
|
3458
|
+
var ColorModifierTypes;
|
|
3459
|
+
(function(ColorModifierTypes2) {
|
|
3460
|
+
ColorModifierTypes2["LIGHTEN"] = "lighten";
|
|
3461
|
+
ColorModifierTypes2["DARKEN"] = "darken";
|
|
3462
|
+
ColorModifierTypes2["MIX"] = "mix";
|
|
3463
|
+
ColorModifierTypes2["ALPHA"] = "alpha";
|
|
3464
|
+
})(ColorModifierTypes || (ColorModifierTypes = {}));
|
|
3465
|
+
|
|
3466
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
|
|
3467
|
+
var ColorSpaceTypes;
|
|
3468
|
+
(function(ColorSpaceTypes2) {
|
|
3469
|
+
ColorSpaceTypes2["LCH"] = "lch";
|
|
3470
|
+
ColorSpaceTypes2["SRGB"] = "srgb";
|
|
3471
|
+
ColorSpaceTypes2["P3"] = "p3";
|
|
3472
|
+
ColorSpaceTypes2["HSL"] = "hsl";
|
|
3473
|
+
})(ColorSpaceTypes || (ColorSpaceTypes = {}));
|
|
3474
|
+
|
|
3475
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js
|
|
3476
|
+
var Properties;
|
|
3477
|
+
(function(Properties2) {
|
|
3478
|
+
Properties2["sizing"] = "sizing";
|
|
3479
|
+
Properties2["height"] = "height";
|
|
3480
|
+
Properties2["width"] = "width";
|
|
3481
|
+
Properties2["spacing"] = "spacing";
|
|
3482
|
+
Properties2["verticalPadding"] = "verticalPadding";
|
|
3483
|
+
Properties2["horizontalPadding"] = "horizontalPadding";
|
|
3484
|
+
Properties2["paddingTop"] = "paddingTop";
|
|
3485
|
+
Properties2["paddingRight"] = "paddingRight";
|
|
3486
|
+
Properties2["paddingBottom"] = "paddingBottom";
|
|
3487
|
+
Properties2["paddingLeft"] = "paddingLeft";
|
|
3488
|
+
Properties2["itemSpacing"] = "itemSpacing";
|
|
3489
|
+
Properties2["fill"] = "fill";
|
|
3490
|
+
Properties2["backgroundBlur"] = "backgroundBlur";
|
|
3491
|
+
Properties2["border"] = "border";
|
|
3492
|
+
Properties2["borderTop"] = "borderTop";
|
|
3493
|
+
Properties2["borderRight"] = "borderRight";
|
|
3494
|
+
Properties2["borderBottom"] = "borderBottom";
|
|
3495
|
+
Properties2["borderLeft"] = "borderLeft";
|
|
3496
|
+
Properties2["borderColor"] = "borderColor";
|
|
3497
|
+
Properties2["borderRadius"] = "borderRadius";
|
|
3498
|
+
Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
|
|
3499
|
+
Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
|
|
3500
|
+
Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
|
|
3501
|
+
Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
|
|
3502
|
+
Properties2["borderWidth"] = "borderWidth";
|
|
3503
|
+
Properties2["borderWidthTop"] = "borderWidthTop";
|
|
3504
|
+
Properties2["borderWidthRight"] = "borderWidthRight";
|
|
3505
|
+
Properties2["borderWidthBottom"] = "borderWidthBottom";
|
|
3506
|
+
Properties2["borderWidthLeft"] = "borderWidthLeft";
|
|
3507
|
+
Properties2["boxShadow"] = "boxShadow";
|
|
3508
|
+
Properties2["opacity"] = "opacity";
|
|
3509
|
+
Properties2["fontFamilies"] = "fontFamilies";
|
|
3510
|
+
Properties2["fontWeights"] = "fontWeights";
|
|
3511
|
+
Properties2["fontSizes"] = "fontSizes";
|
|
3512
|
+
Properties2["lineHeights"] = "lineHeights";
|
|
3513
|
+
Properties2["typography"] = "typography";
|
|
3514
|
+
Properties2["composition"] = "composition";
|
|
3515
|
+
Properties2["letterSpacing"] = "letterSpacing";
|
|
3516
|
+
Properties2["paragraphSpacing"] = "paragraphSpacing";
|
|
3517
|
+
Properties2["textCase"] = "textCase";
|
|
3518
|
+
Properties2["dimension"] = "dimension";
|
|
3519
|
+
Properties2["textDecoration"] = "textDecoration";
|
|
3520
|
+
Properties2["asset"] = "asset";
|
|
3521
|
+
Properties2["tokenValue"] = "tokenValue";
|
|
3522
|
+
Properties2["value"] = "value";
|
|
3523
|
+
Properties2["tokenName"] = "tokenName";
|
|
3524
|
+
Properties2["description"] = "description";
|
|
3525
|
+
})(Properties || (Properties = {}));
|
|
3526
|
+
|
|
3527
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
|
|
3528
|
+
var TokenSetStatus;
|
|
3529
|
+
(function(TokenSetStatus2) {
|
|
3530
|
+
TokenSetStatus2["DISABLED"] = "disabled";
|
|
3531
|
+
TokenSetStatus2["SOURCE"] = "source";
|
|
3532
|
+
TokenSetStatus2["ENABLED"] = "enabled";
|
|
3533
|
+
})(TokenSetStatus || (TokenSetStatus = {}));
|
|
3534
|
+
|
|
3535
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
|
|
3536
|
+
var TokenTypes;
|
|
3537
|
+
(function(TokenTypes2) {
|
|
3538
|
+
TokenTypes2["OTHER"] = "other";
|
|
3539
|
+
TokenTypes2["COLOR"] = "color";
|
|
3540
|
+
TokenTypes2["BORDER_RADIUS"] = "borderRadius";
|
|
3541
|
+
TokenTypes2["SIZING"] = "sizing";
|
|
3542
|
+
TokenTypes2["SPACING"] = "spacing";
|
|
3543
|
+
TokenTypes2["TEXT"] = "text";
|
|
3544
|
+
TokenTypes2["TYPOGRAPHY"] = "typography";
|
|
3545
|
+
TokenTypes2["OPACITY"] = "opacity";
|
|
3546
|
+
TokenTypes2["BORDER_WIDTH"] = "borderWidth";
|
|
3547
|
+
TokenTypes2["STROKE_STYLE"] = "strokeStyle";
|
|
3548
|
+
TokenTypes2["BOX_SHADOW"] = "boxShadow";
|
|
3549
|
+
TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
|
|
3550
|
+
TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
|
|
3551
|
+
TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
|
|
3552
|
+
TokenTypes2["FONT_SIZES"] = "fontSizes";
|
|
3553
|
+
TokenTypes2["LETTER_SPACING"] = "letterSpacing";
|
|
3554
|
+
TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
3555
|
+
TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
3556
|
+
TokenTypes2["TEXT_DECORATION"] = "textDecoration";
|
|
3557
|
+
TokenTypes2["TEXT_CASE"] = "textCase";
|
|
3558
|
+
TokenTypes2["COMPOSITION"] = "composition";
|
|
3559
|
+
TokenTypes2["DIMENSION"] = "dimension";
|
|
3560
|
+
TokenTypes2["BORDER"] = "border";
|
|
3561
|
+
TokenTypes2["ASSET"] = "asset";
|
|
3562
|
+
TokenTypes2["BOOLEAN"] = "boolean";
|
|
3563
|
+
TokenTypes2["NUMBER"] = "number";
|
|
3564
|
+
})(TokenTypes || (TokenTypes = {}));
|
|
3565
|
+
|
|
3566
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js
|
|
3567
|
+
var BorderValues;
|
|
3568
|
+
(function(BorderValues2) {
|
|
3569
|
+
BorderValues2["BORDER_COLOR"] = "color";
|
|
3570
|
+
BorderValues2["BORDER_WIDTH"] = "width";
|
|
3571
|
+
BorderValues2["BORDER_STYLE"] = "style";
|
|
3572
|
+
})(BorderValues || (BorderValues = {}));
|
|
3573
|
+
|
|
3574
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
|
|
3575
|
+
var StrokeStyleValues;
|
|
3576
|
+
(function(StrokeStyleValues2) {
|
|
3577
|
+
StrokeStyleValues2["SOLID"] = "solid";
|
|
3578
|
+
StrokeStyleValues2["DASHED"] = "dashed";
|
|
3579
|
+
StrokeStyleValues2["DOTTED"] = "dotted";
|
|
3580
|
+
StrokeStyleValues2["DOUBLE"] = "double";
|
|
3581
|
+
StrokeStyleValues2["GROOVE"] = "groove";
|
|
3582
|
+
StrokeStyleValues2["RIDGE"] = "ridge";
|
|
3583
|
+
StrokeStyleValues2["OUTSET"] = "outset";
|
|
3584
|
+
StrokeStyleValues2["INSET"] = "inset";
|
|
3585
|
+
})(StrokeStyleValues || (StrokeStyleValues = {}));
|
|
3586
|
+
|
|
3587
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
|
|
3588
|
+
var BoxShadowValues;
|
|
3589
|
+
(function(BoxShadowValues2) {
|
|
3590
|
+
BoxShadowValues2["TYPE"] = "type";
|
|
3591
|
+
BoxShadowValues2["COLOR"] = "color";
|
|
3592
|
+
BoxShadowValues2["X"] = "x";
|
|
3593
|
+
BoxShadowValues2["Y"] = "y";
|
|
3594
|
+
BoxShadowValues2["BLUR"] = "blur";
|
|
3595
|
+
BoxShadowValues2["SPREAD"] = "spread";
|
|
3596
|
+
BoxShadowValues2["BLEND_MODE"] = "blendMode";
|
|
3597
|
+
})(BoxShadowValues || (BoxShadowValues = {}));
|
|
3598
|
+
|
|
3599
|
+
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
|
|
3600
|
+
var TypographyValues;
|
|
3601
|
+
(function(TypographyValues2) {
|
|
3602
|
+
TypographyValues2["FONT_FAMILY"] = "fontFamily";
|
|
3603
|
+
TypographyValues2["FONT_WEIGHT"] = "fontWeight";
|
|
3604
|
+
TypographyValues2["LINE_HEIGHT"] = "lineHeight";
|
|
3605
|
+
TypographyValues2["FONT_SIZE"] = "fontSize";
|
|
3606
|
+
TypographyValues2["LETTER_SPACING"] = "letterSpacing";
|
|
3607
|
+
TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
3608
|
+
TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
3609
|
+
TypographyValues2["TEXT_DECORATION"] = "textDecoration";
|
|
3610
|
+
TypographyValues2["TEXT_CASE"] = "textCase";
|
|
3611
|
+
})(TypographyValues || (TypographyValues = {}));
|
|
3612
|
+
|
|
3613
|
+
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
3614
|
+
import chalk4 from "chalk";
|
|
3615
|
+
import { kebabCase } from "change-case";
|
|
3616
|
+
import * as R20 from "ramda";
|
|
3617
|
+
var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
3618
|
+
const verboseLogging = buildOptions?.verbose;
|
|
3619
|
+
const grouped$themes = groupThemes(processed$themes);
|
|
3620
|
+
const permutations = permutateThemes(grouped$themes);
|
|
3621
|
+
const ALL_DEPENDENT_ON = ["theme"];
|
|
3622
|
+
const keys3 = R20.keys(grouped$themes);
|
|
3623
|
+
const nonDependentKeys = keys3.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
3624
|
+
if (verboseLogging) {
|
|
3625
|
+
console.log(chalk4.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
3626
|
+
console.log(chalk4.cyan(` (ignoring permutations for ${nonDependentKeys})`));
|
|
3627
|
+
}
|
|
3628
|
+
return permutations.filter((val) => {
|
|
3629
|
+
const filters = nonDependentKeys.map((x) => val.permutation[x] === grouped$themes[x][0].name);
|
|
3630
|
+
return filters.every((x) => x);
|
|
3631
|
+
});
|
|
3632
|
+
};
|
|
3633
|
+
var processed = Symbol("Type brand for ProcessedThemeObject");
|
|
3634
|
+
function isProcessed(theme) {
|
|
3635
|
+
return Boolean(theme[processed]);
|
|
3636
|
+
}
|
|
3637
|
+
function processThemeObject(theme) {
|
|
3638
|
+
if (isProcessed(theme)) {
|
|
3639
|
+
return theme;
|
|
3640
|
+
}
|
|
3641
|
+
const result = { ...theme, [processed]: true };
|
|
3642
|
+
if (result.group) {
|
|
3643
|
+
result.group = kebabCase(result.group);
|
|
3644
|
+
}
|
|
3645
|
+
result.name = kebabCase(result.name);
|
|
3646
|
+
return result;
|
|
3647
|
+
}
|
|
3648
|
+
function groupThemes(themes) {
|
|
3649
|
+
const groups = {};
|
|
3650
|
+
for (const rawTheme of themes) {
|
|
3651
|
+
const theme = processThemeObject(rawTheme);
|
|
3652
|
+
if (theme.group) {
|
|
3653
|
+
const groupKey = theme.group;
|
|
3654
|
+
groups[groupKey] = [...groups[groupKey] ?? [], theme];
|
|
3655
|
+
} else {
|
|
3656
|
+
throw new Error(
|
|
3657
|
+
`Theme ${theme.name} does not have a group property, which is required for multi-dimensional theming.`
|
|
3658
|
+
);
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
return groups;
|
|
3662
|
+
}
|
|
3663
|
+
var hasUnknownProps = R20.pipe(R20.values, R20.none(R20.equals("unknown")), R20.not);
|
|
3664
|
+
function permutateThemes(groups) {
|
|
3665
|
+
const separator = "_";
|
|
3666
|
+
const permutations = cartesian(Object.values(groups));
|
|
3667
|
+
const permutatedThemes = permutations.map((perm) => {
|
|
3668
|
+
const permutatedTheme = perm.reduce(
|
|
3669
|
+
(acc, theme) => {
|
|
3670
|
+
const { group, name, selectedTokenSets } = theme;
|
|
3671
|
+
let updatedPermutation = acc.permutation;
|
|
3672
|
+
if (group) {
|
|
3673
|
+
const groupProp = R20.lensProp(group);
|
|
3674
|
+
updatedPermutation = R20.set(groupProp, name, updatedPermutation);
|
|
3675
|
+
}
|
|
3676
|
+
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
3677
|
+
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
3678
|
+
return {
|
|
3679
|
+
permutation: updatedPermutation,
|
|
3680
|
+
name: updatedName,
|
|
3681
|
+
selectedTokenSets: sets
|
|
3682
|
+
};
|
|
3683
|
+
},
|
|
3684
|
+
{
|
|
3685
|
+
name: "",
|
|
3686
|
+
selectedTokenSets: [],
|
|
3687
|
+
permutation: {
|
|
3688
|
+
"color-scheme": "unknown",
|
|
3774
3689
|
"main-color": "unknown",
|
|
3775
3690
|
"support-color": "unknown",
|
|
3776
3691
|
theme: "unknown",
|
|
@@ -3840,7 +3755,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
3840
3755
|
obj.filePath = tokenSet;
|
|
3841
3756
|
}
|
|
3842
3757
|
});
|
|
3843
|
-
tokenSource.tokens =
|
|
3758
|
+
tokenSource.tokens = R21.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
|
|
3844
3759
|
}
|
|
3845
3760
|
}
|
|
3846
3761
|
} else {
|
|
@@ -3927,19 +3842,19 @@ var buildConfigs = {
|
|
|
3927
3842
|
// },
|
|
3928
3843
|
};
|
|
3929
3844
|
async function processPlatform(options) {
|
|
3930
|
-
const {
|
|
3845
|
+
const { process: process2, $themes } = options;
|
|
3931
3846
|
const platform = "css";
|
|
3932
3847
|
const tokenSets = process2 === "format" ? options.tokenSets : void 0;
|
|
3933
3848
|
const tokensDir = process2 === "build" ? options.tokensDir : void 0;
|
|
3934
3849
|
buildOptions = options;
|
|
3935
|
-
const processed$themes = $themes.map(processThemeObject).filter((theme) =>
|
|
3850
|
+
const processed$themes = $themes.map(processThemeObject).filter((theme) => R22.not(theme.group === "size" && theme.name !== "medium"));
|
|
3936
3851
|
const customColors = getCustomColors(processed$themes);
|
|
3937
3852
|
if (!buildOptions.rootColor) {
|
|
3938
|
-
const firstMainColor =
|
|
3853
|
+
const firstMainColor = R22.head(customColors);
|
|
3939
3854
|
buildOptions.rootColor = firstMainColor;
|
|
3940
|
-
console.log(`Using first main color; ${
|
|
3855
|
+
console.log(`Using first main color; ${chalk5.blue(firstMainColor)}, as ${chalk5.green(`":root"`)} color`);
|
|
3941
3856
|
}
|
|
3942
|
-
const buildAndSdConfigs =
|
|
3857
|
+
const buildAndSdConfigs = R22.map((buildConfig) => {
|
|
3943
3858
|
const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
|
|
3944
3859
|
tokensDir,
|
|
3945
3860
|
tokenSets
|
|
@@ -3971,19 +3886,19 @@ async function processPlatform(options) {
|
|
|
3971
3886
|
types: [initResult]
|
|
3972
3887
|
};
|
|
3973
3888
|
try {
|
|
3974
|
-
for (const [buildName, { buildConfig, sdConfigs }] of
|
|
3889
|
+
for (const [buildName, { buildConfig, sdConfigs }] of R22.toPairs(buildAndSdConfigs)) {
|
|
3975
3890
|
if (!(buildConfig.enabled?.() ?? true)) {
|
|
3976
3891
|
continue;
|
|
3977
3892
|
}
|
|
3978
3893
|
if (sdConfigs.length > 0) {
|
|
3979
3894
|
console.log(`
|
|
3980
|
-
\u{1F371} Building ${
|
|
3895
|
+
\u{1F371} Building ${chalk5.green(buildConfig.name ?? buildName)}`);
|
|
3981
3896
|
const results = await Promise.all(
|
|
3982
3897
|
sdConfigs.map(async (sdConfig) => {
|
|
3983
3898
|
const { config, permutation } = sdConfig;
|
|
3984
3899
|
const modes = ["theme", ...buildConfig.dimensions];
|
|
3985
3900
|
const modeMessage = modes.map((x) => permutation[x]).join(" - ");
|
|
3986
|
-
const logMessage =
|
|
3901
|
+
const logMessage = R22.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
|
|
3987
3902
|
console.log(logMessage);
|
|
3988
3903
|
const sdOptions = { cache: true };
|
|
3989
3904
|
const sdExtended = await sd.extend(config);
|
|
@@ -4015,7 +3930,7 @@ async function processPlatform(options) {
|
|
|
4015
3930
|
}
|
|
4016
3931
|
async function createColorTypeDeclaration(colors2) {
|
|
4017
3932
|
console.log(`
|
|
4018
|
-
\u{1F371} Building ${
|
|
3933
|
+
\u{1F371} Building ${chalk5.green("type declarations")}`);
|
|
4019
3934
|
const typeDeclaration = `
|
|
4020
3935
|
import type {} from '@digdir/designsystemet-react/colors';
|
|
4021
3936
|
|
|
@@ -4028,70 +3943,6 @@ ${colors2.map((color) => ` ${color}: never;`).join("\n")}
|
|
|
4028
3943
|
return typeDeclaration;
|
|
4029
3944
|
}
|
|
4030
3945
|
|
|
4031
|
-
// src/tokens/format.ts
|
|
4032
|
-
var createThemeCSSFiles = (processedBuilds) => {
|
|
4033
|
-
const groupedByTheme = {};
|
|
4034
|
-
for (const [_, buildResults] of Object.entries(R22.dissoc("types", processedBuilds))) {
|
|
4035
|
-
for (const buildResult of buildResults) {
|
|
4036
|
-
const previous = groupedByTheme[buildResult.permutation.theme] ?? [];
|
|
4037
|
-
groupedByTheme[buildResult.permutation.theme] = R22.concat(previous, buildResult.formatted);
|
|
4038
|
-
}
|
|
4039
|
-
}
|
|
4040
|
-
const sortOrder = [
|
|
4041
|
-
"color-scheme/light",
|
|
4042
|
-
"typography/secondary",
|
|
4043
|
-
"semantic",
|
|
4044
|
-
"color-scheme/dark",
|
|
4045
|
-
"color-scheme/contrast",
|
|
4046
|
-
"typography/primary",
|
|
4047
|
-
"color/"
|
|
4048
|
-
];
|
|
4049
|
-
const sortByDefinedOrder = R22.sortBy((file) => {
|
|
4050
|
-
const filePath = file.destination || "";
|
|
4051
|
-
const sortIndex = sortOrder.findIndex((sortElement) => {
|
|
4052
|
-
if (sortElement.endsWith("/")) {
|
|
4053
|
-
return filePath.includes(sortElement);
|
|
4054
|
-
}
|
|
4055
|
-
return filePath.includes(`${sortElement}.css`);
|
|
4056
|
-
});
|
|
4057
|
-
if (sortIndex === -1) {
|
|
4058
|
-
console.error(
|
|
4059
|
-
chalk5.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
|
|
4060
|
-
);
|
|
4061
|
-
console.log(
|
|
4062
|
-
chalk5.dim(
|
|
4063
|
-
`
|
|
4064
|
-
The section will currently be added to the end of the entry file, but the exact
|
|
4065
|
-
order may change due to nondeterminism.`.trim()
|
|
4066
|
-
)
|
|
4067
|
-
);
|
|
4068
|
-
return Infinity;
|
|
4069
|
-
}
|
|
4070
|
-
return sortIndex;
|
|
4071
|
-
});
|
|
4072
|
-
const header = `@charset "UTF-8";
|
|
4073
|
-
|
|
4074
|
-
@layer ds.theme, ds.base, ds.utilities, ds.components;
|
|
4075
|
-
|
|
4076
|
-
/* This file is generated by ${package_default.name}@${package_default.version} */
|
|
4077
|
-
|
|
4078
|
-
`;
|
|
4079
|
-
const sortAlphabetically = R22.sort(R22.ascend((x) => x.destination || ""));
|
|
4080
|
-
const pickOutputs = R22.map(R22.view(R22.lensProp("output")));
|
|
4081
|
-
const themeCSSFile = R22.pipe(
|
|
4082
|
-
sortAlphabetically,
|
|
4083
|
-
sortByDefinedOrder,
|
|
4084
|
-
pickOutputs,
|
|
4085
|
-
R22.join("\n"),
|
|
4086
|
-
(content) => header + content
|
|
4087
|
-
);
|
|
4088
|
-
const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
|
|
4089
|
-
destination: `${theme}.css`,
|
|
4090
|
-
output: themeCSSFile(files)
|
|
4091
|
-
}));
|
|
4092
|
-
return themeCSSFiles;
|
|
4093
|
-
};
|
|
4094
|
-
|
|
4095
3946
|
// src/tokens/build.ts
|
|
4096
3947
|
async function write(files, outDir, dry) {
|
|
4097
3948
|
for (const { destination, output } of files) {
|
|
@@ -4108,6 +3959,12 @@ var buildTokens = async (options) => {
|
|
|
4108
3959
|
const outDir = path2.resolve(options.outDir);
|
|
4109
3960
|
const tokensDir = path2.resolve(options.tokensDir);
|
|
4110
3961
|
const $themes = JSON.parse(await readFile(`${tokensDir}/$themes.json`));
|
|
3962
|
+
let $designsystemet;
|
|
3963
|
+
try {
|
|
3964
|
+
const $designsystemetContent = await readFile(`${tokensDir}/$designsystemet.json`);
|
|
3965
|
+
$designsystemet = JSON.parse($designsystemetContent);
|
|
3966
|
+
} catch (error) {
|
|
3967
|
+
}
|
|
4111
3968
|
console.log(`
|
|
4112
3969
|
\u{1F3D7}\uFE0F Start building tokens in ${chalk6.green(tokensDir)}`);
|
|
4113
3970
|
const processedBuilds = await processPlatform({
|
|
@@ -4125,7 +3982,12 @@ var buildTokens = async (options) => {
|
|
|
4125
3982
|
for (const { formatted } of processedBuilds.types) {
|
|
4126
3983
|
await write(formatted, outDir, options.dry);
|
|
4127
3984
|
}
|
|
4128
|
-
|
|
3985
|
+
const fileHeader2 = R23.join("")([
|
|
3986
|
+
defaultFileHeader,
|
|
3987
|
+
$designsystemet ? `
|
|
3988
|
+
design-tokens: v${$designsystemet.version} ` : ""
|
|
3989
|
+
]);
|
|
3990
|
+
await write(createThemeCSSFiles({ processedBuilds, fileHeader: fileHeader2 }), outDir, options.dry);
|
|
4129
3991
|
console.log(`
|
|
4130
3992
|
\u2705 Finished building tokens!`);
|
|
4131
3993
|
return processedBuilds;
|
|
@@ -4134,7 +3996,7 @@ var buildTokens = async (options) => {
|
|
|
4134
3996
|
// src/tokens/create/write.ts
|
|
4135
3997
|
import path3 from "node:path";
|
|
4136
3998
|
import chalk7 from "chalk";
|
|
4137
|
-
import * as
|
|
3999
|
+
import * as R24 from "ramda";
|
|
4138
4000
|
|
|
4139
4001
|
// src/tokens/create/generators/$designsystemet.ts
|
|
4140
4002
|
function generate$Designsystemet() {
|
|
@@ -4171,6 +4033,174 @@ function generate$Metadata(schemes, themes, colors2) {
|
|
|
4171
4033
|
};
|
|
4172
4034
|
}
|
|
4173
4035
|
|
|
4036
|
+
// src/tokens/create/generators/$themes.ts
|
|
4037
|
+
var capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
|
|
4038
|
+
async function createHash(text, algo = "SHA-1") {
|
|
4039
|
+
const crypto = globalThis.crypto;
|
|
4040
|
+
return Array.from(
|
|
4041
|
+
new Uint8Array(await crypto.subtle.digest(algo, new TextEncoder().encode(text))),
|
|
4042
|
+
(byte) => byte.toString(16).padStart(2, "0")
|
|
4043
|
+
).join("");
|
|
4044
|
+
}
|
|
4045
|
+
async function generate$Themes(colorSchemes, themes, colors2) {
|
|
4046
|
+
return [
|
|
4047
|
+
...generateSizeGroup(),
|
|
4048
|
+
...await generateThemesGroup(themes),
|
|
4049
|
+
...generateTypographyGroup(themes),
|
|
4050
|
+
...generateColorSchemesGroup(colorSchemes, themes),
|
|
4051
|
+
generateSemanticGroup(),
|
|
4052
|
+
...await generateColorGroup("main", colors2),
|
|
4053
|
+
...await generateColorGroup("support", colors2)
|
|
4054
|
+
];
|
|
4055
|
+
}
|
|
4056
|
+
function generateSizeGroup() {
|
|
4057
|
+
return [
|
|
4058
|
+
{
|
|
4059
|
+
id: "8b2c8cc86611a34b135cb22948666779361fd729",
|
|
4060
|
+
name: "medium",
|
|
4061
|
+
$figmaStyleReferences: {},
|
|
4062
|
+
selectedTokenSets: {
|
|
4063
|
+
"primitives/modes/size/medium": TokenSetStatus.SOURCE,
|
|
4064
|
+
"primitives/modes/size/global": TokenSetStatus.ENABLED,
|
|
4065
|
+
"primitives/modes/typography/size/medium": TokenSetStatus.ENABLED
|
|
4066
|
+
},
|
|
4067
|
+
$figmaCollectionId: "VariableCollectionId:36248:20757",
|
|
4068
|
+
$figmaModeId: "41630:1",
|
|
4069
|
+
group: "Size"
|
|
4070
|
+
},
|
|
4071
|
+
{
|
|
4072
|
+
id: "d49b9eebeb48a4f165a74b7261733d0a73370f0e",
|
|
4073
|
+
name: "large",
|
|
4074
|
+
$figmaStyleReferences: {},
|
|
4075
|
+
selectedTokenSets: {
|
|
4076
|
+
"primitives/modes/size/large": TokenSetStatus.SOURCE,
|
|
4077
|
+
"primitives/modes/size/global": TokenSetStatus.ENABLED,
|
|
4078
|
+
"primitives/modes/typography/size/large": TokenSetStatus.ENABLED
|
|
4079
|
+
},
|
|
4080
|
+
$figmaCollectionId: "VariableCollectionId:36248:20757",
|
|
4081
|
+
$figmaModeId: "41630:2",
|
|
4082
|
+
group: "Size"
|
|
4083
|
+
},
|
|
4084
|
+
{
|
|
4085
|
+
id: "fb11567729c298ca37c9da4e3a27716a23480824",
|
|
4086
|
+
name: "small",
|
|
4087
|
+
$figmaStyleReferences: {},
|
|
4088
|
+
selectedTokenSets: {
|
|
4089
|
+
"primitives/modes/size/small": TokenSetStatus.SOURCE,
|
|
4090
|
+
"primitives/modes/size/global": TokenSetStatus.ENABLED,
|
|
4091
|
+
"primitives/modes/typography/size/small": TokenSetStatus.ENABLED
|
|
4092
|
+
},
|
|
4093
|
+
$figmaCollectionId: "VariableCollectionId:36248:20757",
|
|
4094
|
+
$figmaModeId: "41630:3",
|
|
4095
|
+
group: "Size"
|
|
4096
|
+
}
|
|
4097
|
+
];
|
|
4098
|
+
}
|
|
4099
|
+
var colorSchemeDefaults = {
|
|
4100
|
+
light: {
|
|
4101
|
+
name: "Light",
|
|
4102
|
+
selectedTokenSets: {},
|
|
4103
|
+
id: "0daa3ca0b427b9349da7e7dc00101b5668972926",
|
|
4104
|
+
$figmaCollectionId: "VariableCollectionId:34811:5472",
|
|
4105
|
+
$figmaModeId: "34811:0"
|
|
4106
|
+
},
|
|
4107
|
+
dark: {
|
|
4108
|
+
name: "Dark",
|
|
4109
|
+
selectedTokenSets: {},
|
|
4110
|
+
id: "9ebd8aed52afbffc17e2666e8b4653a53498b257",
|
|
4111
|
+
$figmaCollectionId: "VariableCollectionId:34811:5472",
|
|
4112
|
+
$figmaModeId: "34811:1"
|
|
4113
|
+
},
|
|
4114
|
+
contrast: {
|
|
4115
|
+
name: "Contrast",
|
|
4116
|
+
selectedTokenSets: {},
|
|
4117
|
+
id: "9ebd8aed52afbffc17e2666e8b4653a53498b123",
|
|
4118
|
+
$figmaCollectionId: "VariableCollectionId:34811:5472",
|
|
4119
|
+
$figmaModeId: "34811:2"
|
|
4120
|
+
}
|
|
4121
|
+
};
|
|
4122
|
+
function generateColorSchemesGroup(colorSchemes, themes) {
|
|
4123
|
+
return colorSchemes.map(
|
|
4124
|
+
(scheme) => ({
|
|
4125
|
+
...colorSchemeDefaults[scheme],
|
|
4126
|
+
selectedTokenSets: Object.fromEntries([
|
|
4127
|
+
[`primitives/modes/color-scheme/${scheme}/global`, TokenSetStatus.ENABLED],
|
|
4128
|
+
...themes.map((theme) => [`primitives/modes/color-scheme/${scheme}/${theme}`, TokenSetStatus.ENABLED])
|
|
4129
|
+
]),
|
|
4130
|
+
group: "Color scheme"
|
|
4131
|
+
})
|
|
4132
|
+
);
|
|
4133
|
+
}
|
|
4134
|
+
async function generateThemesGroup(themes) {
|
|
4135
|
+
return Promise.all(
|
|
4136
|
+
themes.map(
|
|
4137
|
+
async (theme, index) => ({
|
|
4138
|
+
id: await createHash(theme),
|
|
4139
|
+
$figmaCollectionId: "VariableCollectionId:36528:61712",
|
|
4140
|
+
$figmaModeId: `40960:${index + 6}`,
|
|
4141
|
+
// Start on 6 in Token Studio and Community file for some reason
|
|
4142
|
+
name: theme,
|
|
4143
|
+
selectedTokenSets: {
|
|
4144
|
+
[`themes/${theme}`]: TokenSetStatus.ENABLED
|
|
4145
|
+
},
|
|
4146
|
+
group: "Theme"
|
|
4147
|
+
})
|
|
4148
|
+
)
|
|
4149
|
+
);
|
|
4150
|
+
}
|
|
4151
|
+
function generateSemanticGroup() {
|
|
4152
|
+
return {
|
|
4153
|
+
id: "541629445ef90ad5363f9e88f52a1ccb617e6f84",
|
|
4154
|
+
name: "Semantic",
|
|
4155
|
+
selectedTokenSets: {
|
|
4156
|
+
"semantic/style": TokenSetStatus.ENABLED,
|
|
4157
|
+
"semantic/color": TokenSetStatus.ENABLED,
|
|
4158
|
+
"primitives/globals": TokenSetStatus.SOURCE
|
|
4159
|
+
},
|
|
4160
|
+
$figmaCollectionId: "VariableCollectionId:34811:5976",
|
|
4161
|
+
$figmaModeId: "34811:5",
|
|
4162
|
+
group: "Semantic"
|
|
4163
|
+
};
|
|
4164
|
+
}
|
|
4165
|
+
async function generateColorGroup(group, colors2) {
|
|
4166
|
+
return Promise.all(
|
|
4167
|
+
Object.entries(colors2[group]).map(
|
|
4168
|
+
async ([color]) => ({
|
|
4169
|
+
id: await createHash(`${group}-${color}`),
|
|
4170
|
+
name: color,
|
|
4171
|
+
selectedTokenSets: {
|
|
4172
|
+
[`semantic/modes/${group}-color/${color}`]: TokenSetStatus.ENABLED
|
|
4173
|
+
},
|
|
4174
|
+
group: `${capitalize(group)} color`
|
|
4175
|
+
})
|
|
4176
|
+
)
|
|
4177
|
+
);
|
|
4178
|
+
}
|
|
4179
|
+
function generateTypographyGroup(themes) {
|
|
4180
|
+
return [
|
|
4181
|
+
{
|
|
4182
|
+
id: "368d753fcac4455f289500eaa42e70dc0a03522f",
|
|
4183
|
+
$figmaCollectionId: "VariableCollectionId:36248:20769",
|
|
4184
|
+
$figmaModeId: "36248:2",
|
|
4185
|
+
name: "Primary",
|
|
4186
|
+
selectedTokenSets: Object.fromEntries(
|
|
4187
|
+
themes.map((theme) => [`primitives/modes/typography/primary/${theme}`, TokenSetStatus.ENABLED])
|
|
4188
|
+
),
|
|
4189
|
+
group: "Typography"
|
|
4190
|
+
},
|
|
4191
|
+
{
|
|
4192
|
+
id: "264b8bd1d40b364e1ea3acf09e49795ddd4c513c",
|
|
4193
|
+
$figmaCollectionId: "VariableCollectionId:36248:20769",
|
|
4194
|
+
$figmaModeId: "36248:3",
|
|
4195
|
+
name: "Secondary",
|
|
4196
|
+
selectedTokenSets: Object.fromEntries(
|
|
4197
|
+
themes.map((theme) => [`primitives/modes/typography/secondary/${theme}`, TokenSetStatus.ENABLED])
|
|
4198
|
+
),
|
|
4199
|
+
group: "Typography"
|
|
4200
|
+
}
|
|
4201
|
+
];
|
|
4202
|
+
}
|
|
4203
|
+
|
|
4174
4204
|
// src/tokens/create/write.ts
|
|
4175
4205
|
var stringify = (data) => JSON.stringify(data, null, 2);
|
|
4176
4206
|
var writeTokens = async (options) => {
|
|
@@ -4193,12 +4223,12 @@ var writeTokens = async (options) => {
|
|
|
4193
4223
|
}
|
|
4194
4224
|
} catch (error) {
|
|
4195
4225
|
}
|
|
4196
|
-
const concatThemeNames =
|
|
4197
|
-
|
|
4198
|
-
|
|
4226
|
+
const concatThemeNames = R24.pipe(
|
|
4227
|
+
R24.filter((obj) => R24.toLower(obj.group || "") === "theme"),
|
|
4228
|
+
R24.map(R24.prop("name")),
|
|
4199
4229
|
// New theme is added to the end of the list so we keep the same order from config and Token Studio
|
|
4200
|
-
|
|
4201
|
-
|
|
4230
|
+
R24.append(themeName),
|
|
4231
|
+
R24.uniq
|
|
4202
4232
|
);
|
|
4203
4233
|
const themes = concatThemeNames(themeObjects);
|
|
4204
4234
|
console.log(`
|
|
@@ -4275,15 +4305,15 @@ function makeTokenCommands() {
|
|
|
4275
4305
|
const propsFromJson = configFile?.config;
|
|
4276
4306
|
if (propsFromJson) {
|
|
4277
4307
|
const themeColors = Object.values(propsFromJson?.themes ?? {}).map(
|
|
4278
|
-
(x) => /* @__PURE__ */ new Set([...
|
|
4308
|
+
(x) => /* @__PURE__ */ new Set([...R25.keys(x.colors.main), ...R25.keys(x.colors.support)])
|
|
4279
4309
|
);
|
|
4280
|
-
if (!
|
|
4310
|
+
if (!R25.all(R25.equals(R25.__, themeColors[0]), themeColors)) {
|
|
4281
4311
|
console.error(
|
|
4282
4312
|
chalk8.redBright(
|
|
4283
4313
|
`In config ${configFile.path}, all themes must have the same custom color names, but we found:`
|
|
4284
4314
|
)
|
|
4285
4315
|
);
|
|
4286
|
-
const themeNames =
|
|
4316
|
+
const themeNames = R25.keys(propsFromJson.themes ?? {});
|
|
4287
4317
|
themeColors.forEach((colors2, index) => {
|
|
4288
4318
|
const colorNames = Array.from(colors2);
|
|
4289
4319
|
console.log(` - ${themeNames[index]}: ${colorNames.join(", ")}`);
|
|
@@ -4292,7 +4322,7 @@ function makeTokenCommands() {
|
|
|
4292
4322
|
process.exit(1);
|
|
4293
4323
|
}
|
|
4294
4324
|
}
|
|
4295
|
-
const noUndefined =
|
|
4325
|
+
const noUndefined = R25.reject(R25.isNil);
|
|
4296
4326
|
const getThemeOptions = (optionGetter) => noUndefined({
|
|
4297
4327
|
colors: noUndefined({
|
|
4298
4328
|
main: optionGetter(cmd, "mainColors"),
|
|
@@ -4307,10 +4337,10 @@ function makeTokenCommands() {
|
|
|
4307
4337
|
const unvalidatedConfig = noUndefined({
|
|
4308
4338
|
outDir: propsFromJson?.outDir ?? getCliOption(cmd, "outDir"),
|
|
4309
4339
|
clean: propsFromJson?.clean ?? getCliOption(cmd, "clean"),
|
|
4310
|
-
themes: propsFromJson?.themes ?
|
|
4340
|
+
themes: propsFromJson?.themes ? R25.map((jsonThemeValues) => {
|
|
4311
4341
|
const defaultThemeValues = getThemeOptions(getDefaultCliOption);
|
|
4312
4342
|
const cliThemeValues = getThemeOptions(getSuppliedCliOption);
|
|
4313
|
-
return
|
|
4343
|
+
return R25.mergeDeepRight(defaultThemeValues, R25.mergeDeepRight(jsonThemeValues, cliThemeValues));
|
|
4314
4344
|
}, propsFromJson.themes) : (
|
|
4315
4345
|
// If there are no themes specified in the JSON config, we use both explicit
|
|
4316
4346
|
// and default theme options from the CLI.
|