@digdir/designsystemet 1.0.4 → 1.0.5
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 +586 -563
- package/dist/src/index.js +136 -120
- 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 +327 -570
- package/dist/src/tokens/create/generators/$designsystemet.js +6 -5
- package/dist/src/tokens/create/write.js +6 -5
- 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 +136 -121
- package/dist/src/tokens/index.js +136 -120
- package/dist/src/tokens/process/platform.js +1 -1
- 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 +172 -0
- package/dist/src/tokens/types.d.ts +4 -0
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/package.json +6 -5
|
@@ -4,7 +4,7 @@
|
|
|
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
|
|
@@ -2678,15 +2678,16 @@ var migrations_default = {
|
|
|
2678
2678
|
// src/tokens/build.ts
|
|
2679
2679
|
import path2 from "node:path";
|
|
2680
2680
|
import chalk6 from "chalk";
|
|
2681
|
+
import * as R23 from "ramda";
|
|
2681
2682
|
|
|
2682
|
-
// src/tokens/
|
|
2683
|
-
import * as
|
|
2684
|
-
import
|
|
2683
|
+
// src/tokens/process/theme.ts
|
|
2684
|
+
import * as R10 from "ramda";
|
|
2685
|
+
import chalk3 from "chalk";
|
|
2685
2686
|
|
|
2686
2687
|
// package.json
|
|
2687
2688
|
var package_default = {
|
|
2688
2689
|
name: "@digdir/designsystemet",
|
|
2689
|
-
version: "1.0.
|
|
2690
|
+
version: "1.0.5",
|
|
2690
2691
|
description: "CLI for Designsystemet",
|
|
2691
2692
|
author: "Designsystemet team",
|
|
2692
2693
|
engines: {
|
|
@@ -2726,11 +2727,12 @@ var package_default = {
|
|
|
2726
2727
|
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
2727
2728
|
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
2728
2729
|
types: "tsc --noEmit",
|
|
2729
|
-
"test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens
|
|
2730
|
-
"test:tokens-create-config": "yarn designsystemet tokens create --config ./test-tokens
|
|
2731
|
-
"test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens
|
|
2730
|
+
"test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens/options --theme options --clean",
|
|
2731
|
+
"test:tokens-create-config": "yarn designsystemet tokens create --config ./test/test-tokens.config.json",
|
|
2732
|
+
"test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
|
|
2733
|
+
"test:tokens-build-config": "yarn designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
|
|
2732
2734
|
"test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
|
|
2733
|
-
"test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build",
|
|
2735
|
+
"test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build-config",
|
|
2734
2736
|
test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
|
|
2735
2737
|
"internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
|
|
2736
2738
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
@@ -2773,378 +2775,121 @@ var package_default = {
|
|
|
2773
2775
|
}
|
|
2774
2776
|
};
|
|
2775
2777
|
|
|
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 = {}));
|
|
2778
|
+
// src/tokens/process/theme.ts
|
|
2779
|
+
var defaultFileHeader = `build: v${package_default.version}`;
|
|
2780
|
+
var createThemeCSSFiles = ({
|
|
2781
|
+
processedBuilds,
|
|
2782
|
+
fileHeader: fileHeader2 = defaultFileHeader
|
|
2783
|
+
}) => {
|
|
2784
|
+
const groupedByTheme = {};
|
|
2785
|
+
for (const [_, buildResults] of Object.entries(R10.dissoc("types", processedBuilds))) {
|
|
2786
|
+
for (const buildResult of buildResults) {
|
|
2787
|
+
const themeName = buildResult.permutation.theme;
|
|
2788
|
+
const newOutputs = buildResult.formatted;
|
|
2789
|
+
if (R10.isNotEmpty(newOutputs)) {
|
|
2790
|
+
const currentOutputs = groupedByTheme[themeName] ?? [];
|
|
2791
|
+
groupedByTheme[themeName] = R10.concat(currentOutputs, newOutputs);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
const sortOrder = [
|
|
2796
|
+
"color-scheme/light",
|
|
2797
|
+
"typography/secondary",
|
|
2798
|
+
"semantic",
|
|
2799
|
+
"color-scheme/dark",
|
|
2800
|
+
"color-scheme/contrast",
|
|
2801
|
+
"typography/primary",
|
|
2802
|
+
"color/"
|
|
2803
|
+
];
|
|
2804
|
+
const sortByDefinedOrder = R10.sortBy((file) => {
|
|
2805
|
+
const filePath = file.destination || "";
|
|
2806
|
+
const sortIndex = sortOrder.findIndex((sortElement) => {
|
|
2807
|
+
if (sortElement.endsWith("/")) {
|
|
2808
|
+
return filePath.includes(sortElement);
|
|
2809
|
+
}
|
|
2810
|
+
return filePath.includes(`${sortElement}.css`);
|
|
2811
|
+
});
|
|
2812
|
+
if (sortIndex === -1) {
|
|
2813
|
+
console.error(
|
|
2814
|
+
chalk3.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
|
|
2815
|
+
);
|
|
2816
|
+
console.log(
|
|
2817
|
+
chalk3.dim(
|
|
2818
|
+
`
|
|
2819
|
+
The section will currently be added to the end of the entry file, but the exact
|
|
2820
|
+
order may change due to nondeterminism.`.trim()
|
|
2821
|
+
)
|
|
2822
|
+
);
|
|
2823
|
+
return Infinity;
|
|
2824
|
+
}
|
|
2825
|
+
return sortIndex;
|
|
2826
|
+
});
|
|
2827
|
+
const header = `@charset "UTF-8";
|
|
2852
2828
|
|
|
2853
|
-
|
|
2854
|
-
var TokenSetStatus;
|
|
2855
|
-
(function(TokenSetStatus2) {
|
|
2856
|
-
TokenSetStatus2["DISABLED"] = "disabled";
|
|
2857
|
-
TokenSetStatus2["SOURCE"] = "source";
|
|
2858
|
-
TokenSetStatus2["ENABLED"] = "enabled";
|
|
2859
|
-
})(TokenSetStatus || (TokenSetStatus = {}));
|
|
2829
|
+
@layer ds.theme, ds.base, ds.utilities, ds.components;
|
|
2860
2830
|
|
|
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 = {}));
|
|
2831
|
+
/*
|
|
2832
|
+
${fileHeader2}
|
|
2833
|
+
*/
|
|
2891
2834
|
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
(
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2835
|
+
`;
|
|
2836
|
+
const sortAlphabetically = R10.sort(R10.ascend((x) => x.destination || ""));
|
|
2837
|
+
const pickOutputs = R10.map(R10.view(R10.lensProp("output")));
|
|
2838
|
+
const themeCSSFile = R10.pipe(
|
|
2839
|
+
sortAlphabetically,
|
|
2840
|
+
sortByDefinedOrder,
|
|
2841
|
+
pickOutputs,
|
|
2842
|
+
R10.join("\n"),
|
|
2843
|
+
(content) => header + content
|
|
2844
|
+
);
|
|
2845
|
+
const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
|
|
2846
|
+
destination: `${theme}.css`,
|
|
2847
|
+
output: themeCSSFile(files)
|
|
2848
|
+
}));
|
|
2849
|
+
return themeCSSFiles;
|
|
2850
|
+
};
|
|
2899
2851
|
|
|
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 = {}));
|
|
2852
|
+
// src/tokens/process/platform.ts
|
|
2853
|
+
import chalk5 from "chalk";
|
|
2854
|
+
import * as R22 from "ramda";
|
|
2855
|
+
import StyleDictionary2 from "style-dictionary";
|
|
2912
2856
|
|
|
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 = {}));
|
|
2857
|
+
// src/tokens/types.ts
|
|
2858
|
+
var colorCategories = {
|
|
2859
|
+
main: "main",
|
|
2860
|
+
support: "support"
|
|
2861
|
+
};
|
|
2924
2862
|
|
|
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 = {}));
|
|
2863
|
+
// src/tokens/process/configs.ts
|
|
2864
|
+
import { register } from "@tokens-studio/sd-transforms";
|
|
2865
|
+
import * as R21 from "ramda";
|
|
2866
|
+
import StyleDictionary from "style-dictionary";
|
|
2938
2867
|
|
|
2939
|
-
// src/tokens/
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2868
|
+
// src/tokens/utils.ts
|
|
2869
|
+
import * as R11 from "ramda";
|
|
2870
|
+
var mapToLowerCase = R11.map(R11.toLower);
|
|
2871
|
+
var hasAnyTruth = R11.any(R11.equals(true));
|
|
2872
|
+
var getType = (token) => (token.$type ?? token.type) || "";
|
|
2873
|
+
var getValue = (token) => token.$value ?? token.value;
|
|
2874
|
+
var typeEquals = R11.curry((types, token) => {
|
|
2875
|
+
if (R11.isNil(token)) {
|
|
2876
|
+
return false;
|
|
2877
|
+
}
|
|
2878
|
+
return R11.includes(R11.toLower(getType(token)), R11.map(R11.toLower, Array.isArray(types) ? types : [types]));
|
|
2879
|
+
});
|
|
2880
|
+
var pathStartsWithOneOf = R11.curry((paths, token) => {
|
|
2881
|
+
if (R11.isNil(token)) {
|
|
2882
|
+
return false;
|
|
2883
|
+
}
|
|
2884
|
+
const tokenPath = mapToLowerCase(token.path);
|
|
2885
|
+
const matchPathsStartingWith = R11.map((path5) => R11.startsWith([path5], tokenPath), mapToLowerCase(paths));
|
|
2886
|
+
return hasAnyTruth(matchPathsStartingWith);
|
|
2887
|
+
});
|
|
2888
|
+
function isSemanticToken(token) {
|
|
2889
|
+
return token.filePath.includes("semantic/");
|
|
2947
2890
|
}
|
|
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);
|
|
2891
|
+
function isSemanticColorToken(token, color) {
|
|
2892
|
+
return token.filePath.includes("semantic/") && R11.startsWith(["color", color], token.path);
|
|
3148
2893
|
}
|
|
3149
2894
|
function isGlobalColorToken(token) {
|
|
3150
2895
|
return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
|
|
@@ -3153,7 +2898,7 @@ function isColorCategoryToken(token, category) {
|
|
|
3153
2898
|
if (!category) {
|
|
3154
2899
|
return ["main", "support"].some((c) => isColorCategoryToken(token, c));
|
|
3155
2900
|
}
|
|
3156
|
-
return
|
|
2901
|
+
return R11.startsWith(["color", category], token.path);
|
|
3157
2902
|
}
|
|
3158
2903
|
var isDigit = (s) => /^\d+$/.test(s);
|
|
3159
2904
|
function traverseObj(obj, fn) {
|
|
@@ -3169,7 +2914,7 @@ function traverseObj(obj, fn) {
|
|
|
3169
2914
|
return obj;
|
|
3170
2915
|
}
|
|
3171
2916
|
function inlineTokens(shouldInline, tokens) {
|
|
3172
|
-
const [inlineableTokens, otherTokens] =
|
|
2917
|
+
const [inlineableTokens, otherTokens] = R11.partition(shouldInline, tokens);
|
|
3173
2918
|
return otherTokens.map((token) => {
|
|
3174
2919
|
let transformed = getValue(token.original);
|
|
3175
2920
|
for (const ref of inlineableTokens) {
|
|
@@ -3178,16 +2923,16 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
3178
2923
|
transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
|
|
3179
2924
|
}
|
|
3180
2925
|
}
|
|
3181
|
-
const tokenWithInlinedRefs =
|
|
2926
|
+
const tokenWithInlinedRefs = R11.set(R11.lensPath(["original", "$value"]), transformed, token);
|
|
3182
2927
|
return tokenWithInlinedRefs;
|
|
3183
2928
|
});
|
|
3184
2929
|
}
|
|
3185
2930
|
|
|
3186
2931
|
// src/tokens/process/configs/color.ts
|
|
3187
|
-
import * as
|
|
2932
|
+
import * as R16 from "ramda";
|
|
3188
2933
|
|
|
3189
2934
|
// src/tokens/process/formats/css/color.ts
|
|
3190
|
-
import * as
|
|
2935
|
+
import * as R12 from "ramda";
|
|
3191
2936
|
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
3192
2937
|
var prefersColorScheme = (colorScheme2, content) => `
|
|
3193
2938
|
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
@@ -3211,8 +2956,8 @@ var colorScheme = {
|
|
|
3211
2956
|
color-scheme: ${colorScheme_};
|
|
3212
2957
|
` : "";
|
|
3213
2958
|
const filteredAllTokens = allTokens.filter(
|
|
3214
|
-
|
|
3215
|
-
|
|
2959
|
+
R12.allPass([
|
|
2960
|
+
R12.anyPass([
|
|
3216
2961
|
// Include semantic tokens in the output
|
|
3217
2962
|
isSemanticToken,
|
|
3218
2963
|
// Include global color tokens
|
|
@@ -3228,7 +2973,7 @@ ${formattedTokens}
|
|
|
3228
2973
|
${colorSchemeProperty}}
|
|
3229
2974
|
`;
|
|
3230
2975
|
const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
|
|
3231
|
-
const body =
|
|
2976
|
+
const body = R12.isNotNil(layer) ? `@layer ${layer} {
|
|
3232
2977
|
${selector} ${content} ${autoSelectorContent}
|
|
3233
2978
|
}
|
|
3234
2979
|
` : `${selector} ${content} ${autoSelectorContent}
|
|
@@ -3241,7 +2986,7 @@ var colorCategory = {
|
|
|
3241
2986
|
format: async ({ dictionary, file, options, platform }) => {
|
|
3242
2987
|
const { outputReferences, usesDtcg } = options;
|
|
3243
2988
|
const { selector, layer } = platform;
|
|
3244
|
-
const format =
|
|
2989
|
+
const format = R12.compose(
|
|
3245
2990
|
createPropertyFormatter({
|
|
3246
2991
|
outputReferences,
|
|
3247
2992
|
dictionary,
|
|
@@ -3262,7 +3007,7 @@ var colorCategory = {
|
|
|
3262
3007
|
${formattedTokens}
|
|
3263
3008
|
}
|
|
3264
3009
|
`;
|
|
3265
|
-
const body =
|
|
3010
|
+
const body = R12.isNotNil(layer) ? `@layer ${layer} {
|
|
3266
3011
|
${selector} ${content}
|
|
3267
3012
|
}
|
|
3268
3013
|
` : `${selector} ${content}
|
|
@@ -3272,12 +3017,12 @@ ${selector} ${content}
|
|
|
3272
3017
|
};
|
|
3273
3018
|
|
|
3274
3019
|
// src/tokens/process/formats/css/semantic.ts
|
|
3275
|
-
import * as
|
|
3020
|
+
import * as R13 from "ramda";
|
|
3276
3021
|
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
3277
3022
|
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
3278
3023
|
var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
|
|
3279
3024
|
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
3280
|
-
var isInlineTokens =
|
|
3025
|
+
var isInlineTokens = R13.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
3281
3026
|
var overrideSizingFormula = (format, token) => {
|
|
3282
3027
|
const [name, value] = format(token).split(":");
|
|
3283
3028
|
const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
|
|
@@ -3289,7 +3034,7 @@ var overrideSizingFormula = (format, token) => {
|
|
|
3289
3034
|
};
|
|
3290
3035
|
};
|
|
3291
3036
|
var formatSizingTokens = (format, tokens) => {
|
|
3292
|
-
const { round, calc } =
|
|
3037
|
+
const { round, calc } = R13.reduce(
|
|
3293
3038
|
(acc, token) => {
|
|
3294
3039
|
const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
|
|
3295
3040
|
return {
|
|
@@ -3319,17 +3064,17 @@ var semantic = {
|
|
|
3319
3064
|
usesDtcg
|
|
3320
3065
|
});
|
|
3321
3066
|
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
3322
|
-
const filteredTokens =
|
|
3323
|
-
const [sizingTokens, restTokens] =
|
|
3067
|
+
const filteredTokens = R13.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
|
|
3068
|
+
const [sizingTokens, restTokens] = R13.partition(
|
|
3324
3069
|
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
3325
3070
|
filteredTokens
|
|
3326
3071
|
);
|
|
3327
|
-
const formattedTokens = [
|
|
3072
|
+
const formattedTokens = [R13.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
|
|
3328
3073
|
const content = `{
|
|
3329
3074
|
${formattedTokens.join("\n")}
|
|
3330
3075
|
}
|
|
3331
3076
|
`;
|
|
3332
|
-
const body =
|
|
3077
|
+
const body = R13.isNotNil(layer) ? `@layer ${layer} {
|
|
3333
3078
|
${selector} ${content}
|
|
3334
3079
|
}
|
|
3335
3080
|
` : `${selector} ${content}
|
|
@@ -3339,11 +3084,11 @@ ${selector} ${content}
|
|
|
3339
3084
|
};
|
|
3340
3085
|
|
|
3341
3086
|
// src/tokens/process/formats/css/typography.ts
|
|
3342
|
-
import * as
|
|
3087
|
+
import * as R14 from "ramda";
|
|
3343
3088
|
import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
|
|
3344
|
-
var typographyFontFamilyPredicate =
|
|
3345
|
-
|
|
3346
|
-
|
|
3089
|
+
var typographyFontFamilyPredicate = R14.allPass([
|
|
3090
|
+
R14.pathSatisfies(R14.includes("typography"), ["path"]),
|
|
3091
|
+
R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
|
|
3347
3092
|
]);
|
|
3348
3093
|
var typography = {
|
|
3349
3094
|
name: "ds/css-typography",
|
|
@@ -3356,12 +3101,12 @@ var typography = {
|
|
|
3356
3101
|
format: "css",
|
|
3357
3102
|
usesDtcg
|
|
3358
3103
|
});
|
|
3359
|
-
const filteredTokens =
|
|
3360
|
-
const formattedTokens =
|
|
3104
|
+
const filteredTokens = R14.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
3105
|
+
const formattedTokens = R14.pipe(R14.map(format), R14.join("\n"))(filteredTokens);
|
|
3361
3106
|
const content = selector ? `${selector} {
|
|
3362
3107
|
${formattedTokens}
|
|
3363
3108
|
}` : formattedTokens;
|
|
3364
|
-
const body =
|
|
3109
|
+
const body = R14.isNotNil(layer) ? `@layer ${layer} {
|
|
3365
3110
|
${content}
|
|
3366
3111
|
}` : content;
|
|
3367
3112
|
return body;
|
|
@@ -3378,8 +3123,8 @@ var formats = {
|
|
|
3378
3123
|
|
|
3379
3124
|
// src/tokens/process/transformers.ts
|
|
3380
3125
|
import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
|
|
3381
|
-
import * as
|
|
3382
|
-
var isPx =
|
|
3126
|
+
import * as R15 from "ramda";
|
|
3127
|
+
var isPx = R15.test(/\b\d+px\b/g);
|
|
3383
3128
|
var sizeRem = {
|
|
3384
3129
|
name: "ds/size/toRem",
|
|
3385
3130
|
type: "value",
|
|
@@ -3469,7 +3214,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
|
|
|
3469
3214
|
{
|
|
3470
3215
|
destination: `color-scheme/${colorScheme2}.css`,
|
|
3471
3216
|
format: formats.colorScheme.name,
|
|
3472
|
-
filter: (token) => typeEquals("color", token) && !
|
|
3217
|
+
filter: (token) => typeEquals("color", token) && !R16.startsWith(["global"], token.path)
|
|
3473
3218
|
}
|
|
3474
3219
|
],
|
|
3475
3220
|
options: {
|
|
@@ -3520,7 +3265,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
3520
3265
|
};
|
|
3521
3266
|
|
|
3522
3267
|
// src/tokens/process/configs/semantic.ts
|
|
3523
|
-
import * as
|
|
3268
|
+
import * as R17 from "ramda";
|
|
3524
3269
|
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
3525
3270
|
var semanticVariables = ({ theme }) => {
|
|
3526
3271
|
const selector = `:root`;
|
|
@@ -3543,8 +3288,8 @@ var semanticVariables = ({ theme }) => {
|
|
|
3543
3288
|
destination: `semantic.css`,
|
|
3544
3289
|
format: formats.semantic.name,
|
|
3545
3290
|
filter: (token) => {
|
|
3546
|
-
const isUwantedToken =
|
|
3547
|
-
const isPrivateToken =
|
|
3291
|
+
const isUwantedToken = R17.anyPass([R17.includes("primitives/global")])(token.filePath);
|
|
3292
|
+
const isPrivateToken = R17.includes("_", token.path);
|
|
3548
3293
|
const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
|
|
3549
3294
|
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
3550
3295
|
const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
@@ -3565,20 +3310,20 @@ var semanticVariables = ({ theme }) => {
|
|
|
3565
3310
|
};
|
|
3566
3311
|
|
|
3567
3312
|
// src/tokens/process/configs/storefront.ts
|
|
3568
|
-
import * as
|
|
3313
|
+
import * as R19 from "ramda";
|
|
3569
3314
|
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
3570
3315
|
|
|
3571
3316
|
// src/tokens/process/formats/js-tokens.ts
|
|
3572
|
-
import * as
|
|
3317
|
+
import * as R18 from "ramda";
|
|
3573
3318
|
import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
|
|
3574
|
-
var groupByType =
|
|
3575
|
-
var removeUnwatedTokens =
|
|
3576
|
-
|
|
3577
|
-
|
|
3319
|
+
var groupByType = R18.groupBy((token) => getType(token));
|
|
3320
|
+
var removeUnwatedTokens = R18.pipe(
|
|
3321
|
+
R18.reject((token) => isColorCategoryToken(token)),
|
|
3322
|
+
R18.reject((token) => R18.any((path5) => path5.startsWith("_"))(token.path))
|
|
3578
3323
|
);
|
|
3579
|
-
var dissocExtensions =
|
|
3580
|
-
var removeUnwatedProps =
|
|
3581
|
-
var toCssVarName =
|
|
3324
|
+
var dissocExtensions = R18.pipe(R18.dissoc("$extensions"), R18.dissocPath(["original", "$extensions"]));
|
|
3325
|
+
var removeUnwatedProps = R18.map((token) => dissocExtensions(token));
|
|
3326
|
+
var toCssVarName = R18.pipe(R18.split(":"), R18.head, R18.trim);
|
|
3582
3327
|
var jsTokens = {
|
|
3583
3328
|
name: "ds/js-tokens",
|
|
3584
3329
|
format: async ({ dictionary, file, options }) => {
|
|
@@ -3589,7 +3334,7 @@ var jsTokens = {
|
|
|
3589
3334
|
format: "css",
|
|
3590
3335
|
usesDtcg
|
|
3591
3336
|
});
|
|
3592
|
-
const formatTokens =
|
|
3337
|
+
const formatTokens = R18.map((token) => {
|
|
3593
3338
|
if (pathStartsWithOneOf(["size", "_size"], token)) {
|
|
3594
3339
|
const { calc, name } = overrideSizingFormula(format, token);
|
|
3595
3340
|
return {
|
|
@@ -3603,7 +3348,7 @@ var jsTokens = {
|
|
|
3603
3348
|
name: toCssVarName(format(token))
|
|
3604
3349
|
};
|
|
3605
3350
|
});
|
|
3606
|
-
const processTokens =
|
|
3351
|
+
const processTokens = R18.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens, groupByType);
|
|
3607
3352
|
const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
|
|
3608
3353
|
const content = Object.entries(tokens).map(
|
|
3609
3354
|
([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
|
|
@@ -3628,9 +3373,9 @@ var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
|
|
|
3628
3373
|
destination: `${colorScheme2}.ts`,
|
|
3629
3374
|
format: jsTokens.name,
|
|
3630
3375
|
filter: (token) => {
|
|
3631
|
-
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !
|
|
3376
|
+
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R19.includes("semantic", token.filePath))
|
|
3632
3377
|
return false;
|
|
3633
|
-
const isSemanticColor =
|
|
3378
|
+
const isSemanticColor = R19.includes("semantic", token.filePath) && typeEquals(["color"], token);
|
|
3634
3379
|
const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
|
|
3635
3380
|
return isSemanticColor || wantedTypes;
|
|
3636
3381
|
}
|
|
@@ -3695,68 +3440,231 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
3695
3440
|
};
|
|
3696
3441
|
};
|
|
3697
3442
|
|
|
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
|
-
|
|
3443
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
3444
|
+
var BoxShadowTypes;
|
|
3445
|
+
(function(BoxShadowTypes2) {
|
|
3446
|
+
BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
|
|
3447
|
+
BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
|
|
3448
|
+
})(BoxShadowTypes || (BoxShadowTypes = {}));
|
|
3449
|
+
|
|
3450
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
|
|
3451
|
+
var ColorModifierTypes;
|
|
3452
|
+
(function(ColorModifierTypes2) {
|
|
3453
|
+
ColorModifierTypes2["LIGHTEN"] = "lighten";
|
|
3454
|
+
ColorModifierTypes2["DARKEN"] = "darken";
|
|
3455
|
+
ColorModifierTypes2["MIX"] = "mix";
|
|
3456
|
+
ColorModifierTypes2["ALPHA"] = "alpha";
|
|
3457
|
+
})(ColorModifierTypes || (ColorModifierTypes = {}));
|
|
3458
|
+
|
|
3459
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
|
|
3460
|
+
var ColorSpaceTypes;
|
|
3461
|
+
(function(ColorSpaceTypes2) {
|
|
3462
|
+
ColorSpaceTypes2["LCH"] = "lch";
|
|
3463
|
+
ColorSpaceTypes2["SRGB"] = "srgb";
|
|
3464
|
+
ColorSpaceTypes2["P3"] = "p3";
|
|
3465
|
+
ColorSpaceTypes2["HSL"] = "hsl";
|
|
3466
|
+
})(ColorSpaceTypes || (ColorSpaceTypes = {}));
|
|
3467
|
+
|
|
3468
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/Properties.js
|
|
3469
|
+
var Properties;
|
|
3470
|
+
(function(Properties2) {
|
|
3471
|
+
Properties2["sizing"] = "sizing";
|
|
3472
|
+
Properties2["height"] = "height";
|
|
3473
|
+
Properties2["width"] = "width";
|
|
3474
|
+
Properties2["spacing"] = "spacing";
|
|
3475
|
+
Properties2["verticalPadding"] = "verticalPadding";
|
|
3476
|
+
Properties2["horizontalPadding"] = "horizontalPadding";
|
|
3477
|
+
Properties2["paddingTop"] = "paddingTop";
|
|
3478
|
+
Properties2["paddingRight"] = "paddingRight";
|
|
3479
|
+
Properties2["paddingBottom"] = "paddingBottom";
|
|
3480
|
+
Properties2["paddingLeft"] = "paddingLeft";
|
|
3481
|
+
Properties2["itemSpacing"] = "itemSpacing";
|
|
3482
|
+
Properties2["fill"] = "fill";
|
|
3483
|
+
Properties2["backgroundBlur"] = "backgroundBlur";
|
|
3484
|
+
Properties2["border"] = "border";
|
|
3485
|
+
Properties2["borderTop"] = "borderTop";
|
|
3486
|
+
Properties2["borderRight"] = "borderRight";
|
|
3487
|
+
Properties2["borderBottom"] = "borderBottom";
|
|
3488
|
+
Properties2["borderLeft"] = "borderLeft";
|
|
3489
|
+
Properties2["borderColor"] = "borderColor";
|
|
3490
|
+
Properties2["borderRadius"] = "borderRadius";
|
|
3491
|
+
Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
|
|
3492
|
+
Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
|
|
3493
|
+
Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
|
|
3494
|
+
Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
|
|
3495
|
+
Properties2["borderWidth"] = "borderWidth";
|
|
3496
|
+
Properties2["borderWidthTop"] = "borderWidthTop";
|
|
3497
|
+
Properties2["borderWidthRight"] = "borderWidthRight";
|
|
3498
|
+
Properties2["borderWidthBottom"] = "borderWidthBottom";
|
|
3499
|
+
Properties2["borderWidthLeft"] = "borderWidthLeft";
|
|
3500
|
+
Properties2["boxShadow"] = "boxShadow";
|
|
3501
|
+
Properties2["opacity"] = "opacity";
|
|
3502
|
+
Properties2["fontFamilies"] = "fontFamilies";
|
|
3503
|
+
Properties2["fontWeights"] = "fontWeights";
|
|
3504
|
+
Properties2["fontSizes"] = "fontSizes";
|
|
3505
|
+
Properties2["lineHeights"] = "lineHeights";
|
|
3506
|
+
Properties2["typography"] = "typography";
|
|
3507
|
+
Properties2["composition"] = "composition";
|
|
3508
|
+
Properties2["letterSpacing"] = "letterSpacing";
|
|
3509
|
+
Properties2["paragraphSpacing"] = "paragraphSpacing";
|
|
3510
|
+
Properties2["textCase"] = "textCase";
|
|
3511
|
+
Properties2["dimension"] = "dimension";
|
|
3512
|
+
Properties2["textDecoration"] = "textDecoration";
|
|
3513
|
+
Properties2["asset"] = "asset";
|
|
3514
|
+
Properties2["tokenValue"] = "tokenValue";
|
|
3515
|
+
Properties2["value"] = "value";
|
|
3516
|
+
Properties2["tokenName"] = "tokenName";
|
|
3517
|
+
Properties2["description"] = "description";
|
|
3518
|
+
})(Properties || (Properties = {}));
|
|
3519
|
+
|
|
3520
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
|
|
3521
|
+
var TokenSetStatus;
|
|
3522
|
+
(function(TokenSetStatus2) {
|
|
3523
|
+
TokenSetStatus2["DISABLED"] = "disabled";
|
|
3524
|
+
TokenSetStatus2["SOURCE"] = "source";
|
|
3525
|
+
TokenSetStatus2["ENABLED"] = "enabled";
|
|
3526
|
+
})(TokenSetStatus || (TokenSetStatus = {}));
|
|
3527
|
+
|
|
3528
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
|
|
3529
|
+
var TokenTypes;
|
|
3530
|
+
(function(TokenTypes2) {
|
|
3531
|
+
TokenTypes2["OTHER"] = "other";
|
|
3532
|
+
TokenTypes2["COLOR"] = "color";
|
|
3533
|
+
TokenTypes2["BORDER_RADIUS"] = "borderRadius";
|
|
3534
|
+
TokenTypes2["SIZING"] = "sizing";
|
|
3535
|
+
TokenTypes2["SPACING"] = "spacing";
|
|
3536
|
+
TokenTypes2["TEXT"] = "text";
|
|
3537
|
+
TokenTypes2["TYPOGRAPHY"] = "typography";
|
|
3538
|
+
TokenTypes2["OPACITY"] = "opacity";
|
|
3539
|
+
TokenTypes2["BORDER_WIDTH"] = "borderWidth";
|
|
3540
|
+
TokenTypes2["STROKE_STYLE"] = "strokeStyle";
|
|
3541
|
+
TokenTypes2["BOX_SHADOW"] = "boxShadow";
|
|
3542
|
+
TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
|
|
3543
|
+
TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
|
|
3544
|
+
TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
|
|
3545
|
+
TokenTypes2["FONT_SIZES"] = "fontSizes";
|
|
3546
|
+
TokenTypes2["LETTER_SPACING"] = "letterSpacing";
|
|
3547
|
+
TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
3548
|
+
TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
3549
|
+
TokenTypes2["TEXT_DECORATION"] = "textDecoration";
|
|
3550
|
+
TokenTypes2["TEXT_CASE"] = "textCase";
|
|
3551
|
+
TokenTypes2["COMPOSITION"] = "composition";
|
|
3552
|
+
TokenTypes2["DIMENSION"] = "dimension";
|
|
3553
|
+
TokenTypes2["BORDER"] = "border";
|
|
3554
|
+
TokenTypes2["ASSET"] = "asset";
|
|
3555
|
+
TokenTypes2["BOOLEAN"] = "boolean";
|
|
3556
|
+
TokenTypes2["NUMBER"] = "number";
|
|
3557
|
+
})(TokenTypes || (TokenTypes = {}));
|
|
3558
|
+
|
|
3559
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/BorderValues.js
|
|
3560
|
+
var BorderValues;
|
|
3561
|
+
(function(BorderValues2) {
|
|
3562
|
+
BorderValues2["BORDER_COLOR"] = "color";
|
|
3563
|
+
BorderValues2["BORDER_WIDTH"] = "width";
|
|
3564
|
+
BorderValues2["BORDER_STYLE"] = "style";
|
|
3565
|
+
})(BorderValues || (BorderValues = {}));
|
|
3566
|
+
|
|
3567
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
|
|
3568
|
+
var StrokeStyleValues;
|
|
3569
|
+
(function(StrokeStyleValues2) {
|
|
3570
|
+
StrokeStyleValues2["SOLID"] = "solid";
|
|
3571
|
+
StrokeStyleValues2["DASHED"] = "dashed";
|
|
3572
|
+
StrokeStyleValues2["DOTTED"] = "dotted";
|
|
3573
|
+
StrokeStyleValues2["DOUBLE"] = "double";
|
|
3574
|
+
StrokeStyleValues2["GROOVE"] = "groove";
|
|
3575
|
+
StrokeStyleValues2["RIDGE"] = "ridge";
|
|
3576
|
+
StrokeStyleValues2["OUTSET"] = "outset";
|
|
3577
|
+
StrokeStyleValues2["INSET"] = "inset";
|
|
3578
|
+
})(StrokeStyleValues || (StrokeStyleValues = {}));
|
|
3579
|
+
|
|
3580
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
|
|
3581
|
+
var BoxShadowValues;
|
|
3582
|
+
(function(BoxShadowValues2) {
|
|
3583
|
+
BoxShadowValues2["TYPE"] = "type";
|
|
3584
|
+
BoxShadowValues2["COLOR"] = "color";
|
|
3585
|
+
BoxShadowValues2["X"] = "x";
|
|
3586
|
+
BoxShadowValues2["Y"] = "y";
|
|
3587
|
+
BoxShadowValues2["BLUR"] = "blur";
|
|
3588
|
+
BoxShadowValues2["SPREAD"] = "spread";
|
|
3589
|
+
BoxShadowValues2["BLEND_MODE"] = "blendMode";
|
|
3590
|
+
})(BoxShadowValues || (BoxShadowValues = {}));
|
|
3591
|
+
|
|
3592
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
|
|
3593
|
+
var TypographyValues;
|
|
3594
|
+
(function(TypographyValues2) {
|
|
3595
|
+
TypographyValues2["FONT_FAMILY"] = "fontFamily";
|
|
3596
|
+
TypographyValues2["FONT_WEIGHT"] = "fontWeight";
|
|
3597
|
+
TypographyValues2["LINE_HEIGHT"] = "lineHeight";
|
|
3598
|
+
TypographyValues2["FONT_SIZE"] = "fontSize";
|
|
3599
|
+
TypographyValues2["LETTER_SPACING"] = "letterSpacing";
|
|
3600
|
+
TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
3601
|
+
TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
3602
|
+
TypographyValues2["TEXT_DECORATION"] = "textDecoration";
|
|
3603
|
+
TypographyValues2["TEXT_CASE"] = "textCase";
|
|
3604
|
+
})(TypographyValues || (TypographyValues = {}));
|
|
3605
|
+
|
|
3606
|
+
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
3607
|
+
import chalk4 from "chalk";
|
|
3608
|
+
import { kebabCase } from "change-case";
|
|
3609
|
+
import * as R20 from "ramda";
|
|
3610
|
+
var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
3611
|
+
const verboseLogging = buildOptions?.verbose;
|
|
3612
|
+
const grouped$themes = groupThemes(processed$themes);
|
|
3613
|
+
const permutations = permutateThemes(grouped$themes);
|
|
3614
|
+
const ALL_DEPENDENT_ON = ["theme"];
|
|
3615
|
+
const keys3 = R20.keys(grouped$themes);
|
|
3616
|
+
const nonDependentKeys = keys3.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
3617
|
+
if (verboseLogging) {
|
|
3618
|
+
console.log(chalk4.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
3619
|
+
console.log(chalk4.cyan(` (ignoring permutations for ${nonDependentKeys})`));
|
|
3620
|
+
}
|
|
3621
|
+
return permutations.filter((val) => {
|
|
3622
|
+
const filters = nonDependentKeys.map((x) => val.permutation[x] === grouped$themes[x][0].name);
|
|
3623
|
+
return filters.every((x) => x);
|
|
3624
|
+
});
|
|
3625
|
+
};
|
|
3626
|
+
var processed = Symbol("Type brand for ProcessedThemeObject");
|
|
3627
|
+
function isProcessed(theme) {
|
|
3628
|
+
return Boolean(theme[processed]);
|
|
3629
|
+
}
|
|
3630
|
+
function processThemeObject(theme) {
|
|
3631
|
+
if (isProcessed(theme)) {
|
|
3632
|
+
return theme;
|
|
3633
|
+
}
|
|
3634
|
+
const result = { ...theme, [processed]: true };
|
|
3635
|
+
if (result.group) {
|
|
3636
|
+
result.group = kebabCase(result.group);
|
|
3637
|
+
}
|
|
3638
|
+
result.name = kebabCase(result.name);
|
|
3639
|
+
return result;
|
|
3640
|
+
}
|
|
3641
|
+
function groupThemes(themes) {
|
|
3642
|
+
const groups = {};
|
|
3643
|
+
for (const rawTheme of themes) {
|
|
3644
|
+
const theme = processThemeObject(rawTheme);
|
|
3645
|
+
if (theme.group) {
|
|
3646
|
+
const groupKey = theme.group;
|
|
3647
|
+
groups[groupKey] = [...groups[groupKey] ?? [], theme];
|
|
3648
|
+
} else {
|
|
3649
|
+
throw new Error(
|
|
3650
|
+
`Theme ${theme.name} does not have a group property, which is required for multi-dimensional theming.`
|
|
3651
|
+
);
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
return groups;
|
|
3655
|
+
}
|
|
3656
|
+
var hasUnknownProps = R20.pipe(R20.values, R20.none(R20.equals("unknown")), R20.not);
|
|
3657
|
+
function permutateThemes(groups) {
|
|
3658
|
+
const separator = "_";
|
|
3659
|
+
const permutations = cartesian(Object.values(groups));
|
|
3660
|
+
const permutatedThemes = permutations.map((perm) => {
|
|
3661
|
+
const permutatedTheme = perm.reduce(
|
|
3662
|
+
(acc, theme) => {
|
|
3663
|
+
const { group, name, selectedTokenSets } = theme;
|
|
3756
3664
|
let updatedPermutation = acc.permutation;
|
|
3757
3665
|
if (group) {
|
|
3758
|
-
const groupProp =
|
|
3759
|
-
updatedPermutation =
|
|
3666
|
+
const groupProp = R20.lensProp(group);
|
|
3667
|
+
updatedPermutation = R20.set(groupProp, name, updatedPermutation);
|
|
3760
3668
|
}
|
|
3761
3669
|
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
3762
3670
|
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
@@ -3840,7 +3748,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
3840
3748
|
obj.filePath = tokenSet;
|
|
3841
3749
|
}
|
|
3842
3750
|
});
|
|
3843
|
-
tokenSource.tokens =
|
|
3751
|
+
tokenSource.tokens = R21.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
|
|
3844
3752
|
}
|
|
3845
3753
|
}
|
|
3846
3754
|
} else {
|
|
@@ -3927,19 +3835,19 @@ var buildConfigs = {
|
|
|
3927
3835
|
// },
|
|
3928
3836
|
};
|
|
3929
3837
|
async function processPlatform(options) {
|
|
3930
|
-
const {
|
|
3838
|
+
const { process: process2, $themes } = options;
|
|
3931
3839
|
const platform = "css";
|
|
3932
3840
|
const tokenSets = process2 === "format" ? options.tokenSets : void 0;
|
|
3933
3841
|
const tokensDir = process2 === "build" ? options.tokensDir : void 0;
|
|
3934
3842
|
buildOptions = options;
|
|
3935
|
-
const processed$themes = $themes.map(processThemeObject).filter((theme) =>
|
|
3843
|
+
const processed$themes = $themes.map(processThemeObject).filter((theme) => R22.not(theme.group === "size" && theme.name !== "medium"));
|
|
3936
3844
|
const customColors = getCustomColors(processed$themes);
|
|
3937
3845
|
if (!buildOptions.rootColor) {
|
|
3938
|
-
const firstMainColor =
|
|
3846
|
+
const firstMainColor = R22.head(customColors);
|
|
3939
3847
|
buildOptions.rootColor = firstMainColor;
|
|
3940
|
-
console.log(`Using first main color; ${
|
|
3848
|
+
console.log(`Using first main color; ${chalk5.blue(firstMainColor)}, as ${chalk5.green(`":root"`)} color`);
|
|
3941
3849
|
}
|
|
3942
|
-
const buildAndSdConfigs =
|
|
3850
|
+
const buildAndSdConfigs = R22.map((buildConfig) => {
|
|
3943
3851
|
const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
|
|
3944
3852
|
tokensDir,
|
|
3945
3853
|
tokenSets
|
|
@@ -3971,19 +3879,19 @@ async function processPlatform(options) {
|
|
|
3971
3879
|
types: [initResult]
|
|
3972
3880
|
};
|
|
3973
3881
|
try {
|
|
3974
|
-
for (const [buildName, { buildConfig, sdConfigs }] of
|
|
3882
|
+
for (const [buildName, { buildConfig, sdConfigs }] of R22.toPairs(buildAndSdConfigs)) {
|
|
3975
3883
|
if (!(buildConfig.enabled?.() ?? true)) {
|
|
3976
3884
|
continue;
|
|
3977
3885
|
}
|
|
3978
3886
|
if (sdConfigs.length > 0) {
|
|
3979
3887
|
console.log(`
|
|
3980
|
-
\u{1F371} Building ${
|
|
3888
|
+
\u{1F371} Building ${chalk5.green(buildConfig.name ?? buildName)}`);
|
|
3981
3889
|
const results = await Promise.all(
|
|
3982
3890
|
sdConfigs.map(async (sdConfig) => {
|
|
3983
3891
|
const { config, permutation } = sdConfig;
|
|
3984
3892
|
const modes = ["theme", ...buildConfig.dimensions];
|
|
3985
3893
|
const modeMessage = modes.map((x) => permutation[x]).join(" - ");
|
|
3986
|
-
const logMessage =
|
|
3894
|
+
const logMessage = R22.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
|
|
3987
3895
|
console.log(logMessage);
|
|
3988
3896
|
const sdOptions = { cache: true };
|
|
3989
3897
|
const sdExtended = await sd.extend(config);
|
|
@@ -4015,7 +3923,7 @@ async function processPlatform(options) {
|
|
|
4015
3923
|
}
|
|
4016
3924
|
async function createColorTypeDeclaration(colors2) {
|
|
4017
3925
|
console.log(`
|
|
4018
|
-
\u{1F371} Building ${
|
|
3926
|
+
\u{1F371} Building ${chalk5.green("type declarations")}`);
|
|
4019
3927
|
const typeDeclaration = `
|
|
4020
3928
|
import type {} from '@digdir/designsystemet-react/colors';
|
|
4021
3929
|
|
|
@@ -4028,70 +3936,6 @@ ${colors2.map((color) => ` ${color}: never;`).join("\n")}
|
|
|
4028
3936
|
return typeDeclaration;
|
|
4029
3937
|
}
|
|
4030
3938
|
|
|
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
3939
|
// src/tokens/build.ts
|
|
4096
3940
|
async function write(files, outDir, dry) {
|
|
4097
3941
|
for (const { destination, output } of files) {
|
|
@@ -4108,6 +3952,12 @@ var buildTokens = async (options) => {
|
|
|
4108
3952
|
const outDir = path2.resolve(options.outDir);
|
|
4109
3953
|
const tokensDir = path2.resolve(options.tokensDir);
|
|
4110
3954
|
const $themes = JSON.parse(await readFile(`${tokensDir}/$themes.json`));
|
|
3955
|
+
let $designsystemet;
|
|
3956
|
+
try {
|
|
3957
|
+
const $designsystemetContent = await readFile(`${tokensDir}/$designsystemet.json`);
|
|
3958
|
+
$designsystemet = JSON.parse($designsystemetContent);
|
|
3959
|
+
} catch (error) {
|
|
3960
|
+
}
|
|
4111
3961
|
console.log(`
|
|
4112
3962
|
\u{1F3D7}\uFE0F Start building tokens in ${chalk6.green(tokensDir)}`);
|
|
4113
3963
|
const processedBuilds = await processPlatform({
|
|
@@ -4125,7 +3975,12 @@ var buildTokens = async (options) => {
|
|
|
4125
3975
|
for (const { formatted } of processedBuilds.types) {
|
|
4126
3976
|
await write(formatted, outDir, options.dry);
|
|
4127
3977
|
}
|
|
4128
|
-
|
|
3978
|
+
const fileHeader2 = R23.join("")([
|
|
3979
|
+
defaultFileHeader,
|
|
3980
|
+
$designsystemet ? `
|
|
3981
|
+
design-tokens: v${$designsystemet.version} ` : ""
|
|
3982
|
+
]);
|
|
3983
|
+
await write(createThemeCSSFiles({ processedBuilds, fileHeader: fileHeader2 }), outDir, options.dry);
|
|
4129
3984
|
console.log(`
|
|
4130
3985
|
\u2705 Finished building tokens!`);
|
|
4131
3986
|
return processedBuilds;
|
|
@@ -4134,7 +3989,7 @@ var buildTokens = async (options) => {
|
|
|
4134
3989
|
// src/tokens/create/write.ts
|
|
4135
3990
|
import path3 from "node:path";
|
|
4136
3991
|
import chalk7 from "chalk";
|
|
4137
|
-
import * as
|
|
3992
|
+
import * as R24 from "ramda";
|
|
4138
3993
|
|
|
4139
3994
|
// src/tokens/create/generators/$designsystemet.ts
|
|
4140
3995
|
function generate$Designsystemet() {
|
|
@@ -4171,6 +4026,174 @@ function generate$Metadata(schemes, themes, colors2) {
|
|
|
4171
4026
|
};
|
|
4172
4027
|
}
|
|
4173
4028
|
|
|
4029
|
+
// src/tokens/create/generators/$themes.ts
|
|
4030
|
+
var capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
|
|
4031
|
+
async function createHash(text, algo = "SHA-1") {
|
|
4032
|
+
const crypto = globalThis.crypto;
|
|
4033
|
+
return Array.from(
|
|
4034
|
+
new Uint8Array(await crypto.subtle.digest(algo, new TextEncoder().encode(text))),
|
|
4035
|
+
(byte) => byte.toString(16).padStart(2, "0")
|
|
4036
|
+
).join("");
|
|
4037
|
+
}
|
|
4038
|
+
async function generate$Themes(colorSchemes, themes, colors2) {
|
|
4039
|
+
return [
|
|
4040
|
+
...generateSizeGroup(),
|
|
4041
|
+
...await generateThemesGroup(themes),
|
|
4042
|
+
...generateTypographyGroup(themes),
|
|
4043
|
+
...generateColorSchemesGroup(colorSchemes, themes),
|
|
4044
|
+
generateSemanticGroup(),
|
|
4045
|
+
...await generateColorGroup("main", colors2),
|
|
4046
|
+
...await generateColorGroup("support", colors2)
|
|
4047
|
+
];
|
|
4048
|
+
}
|
|
4049
|
+
function generateSizeGroup() {
|
|
4050
|
+
return [
|
|
4051
|
+
{
|
|
4052
|
+
id: "8b2c8cc86611a34b135cb22948666779361fd729",
|
|
4053
|
+
name: "medium",
|
|
4054
|
+
$figmaStyleReferences: {},
|
|
4055
|
+
selectedTokenSets: {
|
|
4056
|
+
"primitives/modes/size/medium": TokenSetStatus.SOURCE,
|
|
4057
|
+
"primitives/modes/size/global": TokenSetStatus.ENABLED,
|
|
4058
|
+
"primitives/modes/typography/size/medium": TokenSetStatus.ENABLED
|
|
4059
|
+
},
|
|
4060
|
+
$figmaCollectionId: "VariableCollectionId:36248:20757",
|
|
4061
|
+
$figmaModeId: "41630:1",
|
|
4062
|
+
group: "Size"
|
|
4063
|
+
},
|
|
4064
|
+
{
|
|
4065
|
+
id: "d49b9eebeb48a4f165a74b7261733d0a73370f0e",
|
|
4066
|
+
name: "large",
|
|
4067
|
+
$figmaStyleReferences: {},
|
|
4068
|
+
selectedTokenSets: {
|
|
4069
|
+
"primitives/modes/size/large": TokenSetStatus.SOURCE,
|
|
4070
|
+
"primitives/modes/size/global": TokenSetStatus.ENABLED,
|
|
4071
|
+
"primitives/modes/typography/size/large": TokenSetStatus.ENABLED
|
|
4072
|
+
},
|
|
4073
|
+
$figmaCollectionId: "VariableCollectionId:36248:20757",
|
|
4074
|
+
$figmaModeId: "41630:2",
|
|
4075
|
+
group: "Size"
|
|
4076
|
+
},
|
|
4077
|
+
{
|
|
4078
|
+
id: "fb11567729c298ca37c9da4e3a27716a23480824",
|
|
4079
|
+
name: "small",
|
|
4080
|
+
$figmaStyleReferences: {},
|
|
4081
|
+
selectedTokenSets: {
|
|
4082
|
+
"primitives/modes/size/small": TokenSetStatus.SOURCE,
|
|
4083
|
+
"primitives/modes/size/global": TokenSetStatus.ENABLED,
|
|
4084
|
+
"primitives/modes/typography/size/small": TokenSetStatus.ENABLED
|
|
4085
|
+
},
|
|
4086
|
+
$figmaCollectionId: "VariableCollectionId:36248:20757",
|
|
4087
|
+
$figmaModeId: "41630:3",
|
|
4088
|
+
group: "Size"
|
|
4089
|
+
}
|
|
4090
|
+
];
|
|
4091
|
+
}
|
|
4092
|
+
var colorSchemeDefaults = {
|
|
4093
|
+
light: {
|
|
4094
|
+
name: "Light",
|
|
4095
|
+
selectedTokenSets: {},
|
|
4096
|
+
id: "0daa3ca0b427b9349da7e7dc00101b5668972926",
|
|
4097
|
+
$figmaCollectionId: "VariableCollectionId:34811:5472",
|
|
4098
|
+
$figmaModeId: "34811:0"
|
|
4099
|
+
},
|
|
4100
|
+
dark: {
|
|
4101
|
+
name: "Dark",
|
|
4102
|
+
selectedTokenSets: {},
|
|
4103
|
+
id: "9ebd8aed52afbffc17e2666e8b4653a53498b257",
|
|
4104
|
+
$figmaCollectionId: "VariableCollectionId:34811:5472",
|
|
4105
|
+
$figmaModeId: "34811:1"
|
|
4106
|
+
},
|
|
4107
|
+
contrast: {
|
|
4108
|
+
name: "Contrast",
|
|
4109
|
+
selectedTokenSets: {},
|
|
4110
|
+
id: "9ebd8aed52afbffc17e2666e8b4653a53498b123",
|
|
4111
|
+
$figmaCollectionId: "VariableCollectionId:34811:5472",
|
|
4112
|
+
$figmaModeId: "34811:2"
|
|
4113
|
+
}
|
|
4114
|
+
};
|
|
4115
|
+
function generateColorSchemesGroup(colorSchemes, themes) {
|
|
4116
|
+
return colorSchemes.map(
|
|
4117
|
+
(scheme) => ({
|
|
4118
|
+
...colorSchemeDefaults[scheme],
|
|
4119
|
+
selectedTokenSets: Object.fromEntries([
|
|
4120
|
+
[`primitives/modes/color-scheme/${scheme}/global`, TokenSetStatus.ENABLED],
|
|
4121
|
+
...themes.map((theme) => [`primitives/modes/color-scheme/${scheme}/${theme}`, TokenSetStatus.ENABLED])
|
|
4122
|
+
]),
|
|
4123
|
+
group: "Color scheme"
|
|
4124
|
+
})
|
|
4125
|
+
);
|
|
4126
|
+
}
|
|
4127
|
+
async function generateThemesGroup(themes) {
|
|
4128
|
+
return Promise.all(
|
|
4129
|
+
themes.map(
|
|
4130
|
+
async (theme, index) => ({
|
|
4131
|
+
id: await createHash(theme),
|
|
4132
|
+
$figmaCollectionId: "VariableCollectionId:36528:61712",
|
|
4133
|
+
$figmaModeId: `40960:${index + 6}`,
|
|
4134
|
+
// Start on 6 in Token Studio and Community file for some reason
|
|
4135
|
+
name: theme,
|
|
4136
|
+
selectedTokenSets: {
|
|
4137
|
+
[`themes/${theme}`]: TokenSetStatus.ENABLED
|
|
4138
|
+
},
|
|
4139
|
+
group: "Theme"
|
|
4140
|
+
})
|
|
4141
|
+
)
|
|
4142
|
+
);
|
|
4143
|
+
}
|
|
4144
|
+
function generateSemanticGroup() {
|
|
4145
|
+
return {
|
|
4146
|
+
id: "541629445ef90ad5363f9e88f52a1ccb617e6f84",
|
|
4147
|
+
name: "Semantic",
|
|
4148
|
+
selectedTokenSets: {
|
|
4149
|
+
"semantic/style": TokenSetStatus.ENABLED,
|
|
4150
|
+
"semantic/color": TokenSetStatus.ENABLED,
|
|
4151
|
+
"primitives/globals": TokenSetStatus.SOURCE
|
|
4152
|
+
},
|
|
4153
|
+
$figmaCollectionId: "VariableCollectionId:34811:5976",
|
|
4154
|
+
$figmaModeId: "34811:5",
|
|
4155
|
+
group: "Semantic"
|
|
4156
|
+
};
|
|
4157
|
+
}
|
|
4158
|
+
async function generateColorGroup(group, colors2) {
|
|
4159
|
+
return Promise.all(
|
|
4160
|
+
Object.entries(colors2[group]).map(
|
|
4161
|
+
async ([color]) => ({
|
|
4162
|
+
id: await createHash(`${group}-${color}`),
|
|
4163
|
+
name: color,
|
|
4164
|
+
selectedTokenSets: {
|
|
4165
|
+
[`semantic/modes/${group}-color/${color}`]: TokenSetStatus.ENABLED
|
|
4166
|
+
},
|
|
4167
|
+
group: `${capitalize(group)} color`
|
|
4168
|
+
})
|
|
4169
|
+
)
|
|
4170
|
+
);
|
|
4171
|
+
}
|
|
4172
|
+
function generateTypographyGroup(themes) {
|
|
4173
|
+
return [
|
|
4174
|
+
{
|
|
4175
|
+
id: "368d753fcac4455f289500eaa42e70dc0a03522f",
|
|
4176
|
+
$figmaCollectionId: "VariableCollectionId:36248:20769",
|
|
4177
|
+
$figmaModeId: "36248:2",
|
|
4178
|
+
name: "Primary",
|
|
4179
|
+
selectedTokenSets: Object.fromEntries(
|
|
4180
|
+
themes.map((theme) => [`primitives/modes/typography/primary/${theme}`, TokenSetStatus.ENABLED])
|
|
4181
|
+
),
|
|
4182
|
+
group: "Typography"
|
|
4183
|
+
},
|
|
4184
|
+
{
|
|
4185
|
+
id: "264b8bd1d40b364e1ea3acf09e49795ddd4c513c",
|
|
4186
|
+
$figmaCollectionId: "VariableCollectionId:36248:20769",
|
|
4187
|
+
$figmaModeId: "36248:3",
|
|
4188
|
+
name: "Secondary",
|
|
4189
|
+
selectedTokenSets: Object.fromEntries(
|
|
4190
|
+
themes.map((theme) => [`primitives/modes/typography/secondary/${theme}`, TokenSetStatus.ENABLED])
|
|
4191
|
+
),
|
|
4192
|
+
group: "Typography"
|
|
4193
|
+
}
|
|
4194
|
+
];
|
|
4195
|
+
}
|
|
4196
|
+
|
|
4174
4197
|
// src/tokens/create/write.ts
|
|
4175
4198
|
var stringify = (data) => JSON.stringify(data, null, 2);
|
|
4176
4199
|
var writeTokens = async (options) => {
|
|
@@ -4193,12 +4216,12 @@ var writeTokens = async (options) => {
|
|
|
4193
4216
|
}
|
|
4194
4217
|
} catch (error) {
|
|
4195
4218
|
}
|
|
4196
|
-
const concatThemeNames =
|
|
4197
|
-
|
|
4198
|
-
|
|
4219
|
+
const concatThemeNames = R24.pipe(
|
|
4220
|
+
R24.filter((obj) => R24.toLower(obj.group || "") === "theme"),
|
|
4221
|
+
R24.map(R24.prop("name")),
|
|
4199
4222
|
// New theme is added to the end of the list so we keep the same order from config and Token Studio
|
|
4200
|
-
|
|
4201
|
-
|
|
4223
|
+
R24.append(themeName),
|
|
4224
|
+
R24.uniq
|
|
4202
4225
|
);
|
|
4203
4226
|
const themes = concatThemeNames(themeObjects);
|
|
4204
4227
|
console.log(`
|
|
@@ -4275,15 +4298,15 @@ function makeTokenCommands() {
|
|
|
4275
4298
|
const propsFromJson = configFile?.config;
|
|
4276
4299
|
if (propsFromJson) {
|
|
4277
4300
|
const themeColors = Object.values(propsFromJson?.themes ?? {}).map(
|
|
4278
|
-
(x) => /* @__PURE__ */ new Set([...
|
|
4301
|
+
(x) => /* @__PURE__ */ new Set([...R25.keys(x.colors.main), ...R25.keys(x.colors.support)])
|
|
4279
4302
|
);
|
|
4280
|
-
if (!
|
|
4303
|
+
if (!R25.all(R25.equals(R25.__, themeColors[0]), themeColors)) {
|
|
4281
4304
|
console.error(
|
|
4282
4305
|
chalk8.redBright(
|
|
4283
4306
|
`In config ${configFile.path}, all themes must have the same custom color names, but we found:`
|
|
4284
4307
|
)
|
|
4285
4308
|
);
|
|
4286
|
-
const themeNames =
|
|
4309
|
+
const themeNames = R25.keys(propsFromJson.themes ?? {});
|
|
4287
4310
|
themeColors.forEach((colors2, index) => {
|
|
4288
4311
|
const colorNames = Array.from(colors2);
|
|
4289
4312
|
console.log(` - ${themeNames[index]}: ${colorNames.join(", ")}`);
|
|
@@ -4292,7 +4315,7 @@ function makeTokenCommands() {
|
|
|
4292
4315
|
process.exit(1);
|
|
4293
4316
|
}
|
|
4294
4317
|
}
|
|
4295
|
-
const noUndefined =
|
|
4318
|
+
const noUndefined = R25.reject(R25.isNil);
|
|
4296
4319
|
const getThemeOptions = (optionGetter) => noUndefined({
|
|
4297
4320
|
colors: noUndefined({
|
|
4298
4321
|
main: optionGetter(cmd, "mainColors"),
|
|
@@ -4307,10 +4330,10 @@ function makeTokenCommands() {
|
|
|
4307
4330
|
const unvalidatedConfig = noUndefined({
|
|
4308
4331
|
outDir: propsFromJson?.outDir ?? getCliOption(cmd, "outDir"),
|
|
4309
4332
|
clean: propsFromJson?.clean ?? getCliOption(cmd, "clean"),
|
|
4310
|
-
themes: propsFromJson?.themes ?
|
|
4333
|
+
themes: propsFromJson?.themes ? R25.map((jsonThemeValues) => {
|
|
4311
4334
|
const defaultThemeValues = getThemeOptions(getDefaultCliOption);
|
|
4312
4335
|
const cliThemeValues = getThemeOptions(getSuppliedCliOption);
|
|
4313
|
-
return
|
|
4336
|
+
return R25.mergeDeepRight(defaultThemeValues, R25.mergeDeepRight(jsonThemeValues, cliThemeValues));
|
|
4314
4337
|
}, propsFromJson.themes) : (
|
|
4315
4338
|
// If there are no themes specified in the JSON config, we use both explicit
|
|
4316
4339
|
// and default theme options from the CLI.
|