@digdir/designsystemet 0.0.0-deps-tsdown-20260421103939
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/README.md +115 -0
- package/configs/test-tokens.config.json +82 -0
- package/dist/bin/config.d.ts +12 -0
- package/dist/bin/config.d.ts.map +1 -0
- package/dist/bin/config.js +58 -0
- package/dist/bin/designsystemet.d.ts +3 -0
- package/dist/bin/designsystemet.d.ts.map +1 -0
- package/dist/bin/designsystemet.js +156 -0
- package/dist/bin/options.d.ts +21 -0
- package/dist/bin/options.d.ts.map +1 -0
- package/dist/bin/options.js +23 -0
- package/dist/config.schema.json +209 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js +9 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js +8 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js +13 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js +10 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js +10 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js +53 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js +14 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js +9 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js +32 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js +15 -0
- package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/types/index.js +11 -0
- package/dist/package.js +5 -0
- package/dist/src/colors/colorMetadata.d.ts +56 -0
- package/dist/src/colors/colorMetadata.d.ts.map +1 -0
- package/dist/src/colors/colorMetadata.js +259 -0
- package/dist/src/colors/index.d.ts +5 -0
- package/dist/src/colors/index.d.ts.map +1 -0
- package/dist/src/colors/index.js +5 -0
- package/dist/src/colors/theme.d.ts +30 -0
- package/dist/src/colors/theme.d.ts.map +1 -0
- package/dist/src/colors/theme.js +111 -0
- package/dist/src/colors/types.d.ts +69 -0
- package/dist/src/colors/types.d.ts.map +1 -0
- package/dist/src/colors/types.js +24 -0
- package/dist/src/colors/utils.d.ts +128 -0
- package/dist/src/colors/utils.d.ts.map +1 -0
- package/dist/src/colors/utils.js +244 -0
- package/dist/src/config.d.ts +181 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +118 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +10 -0
- package/dist/src/migrations/beta-to-v1.d.ts +3 -0
- package/dist/src/migrations/beta-to-v1.d.ts.map +1 -0
- package/dist/src/migrations/beta-to-v1.js +340 -0
- package/dist/src/migrations/codemods/css/plugins.d.ts +6 -0
- package/dist/src/migrations/codemods/css/plugins.d.ts.map +1 -0
- package/dist/src/migrations/codemods/css/plugins.js +35 -0
- package/dist/src/migrations/codemods/css/run.d.ts +8 -0
- package/dist/src/migrations/codemods/css/run.d.ts.map +1 -0
- package/dist/src/migrations/codemods/css/run.js +23 -0
- package/dist/src/migrations/color-rename-next49.d.ts +3 -0
- package/dist/src/migrations/color-rename-next49.d.ts.map +1 -0
- package/dist/src/migrations/color-rename-next49.js +46 -0
- package/dist/src/migrations/index.d.ts +6 -0
- package/dist/src/migrations/index.d.ts.map +1 -0
- package/dist/src/migrations/index.js +9 -0
- package/dist/src/scripts/createJsonSchema.d.ts +2 -0
- package/dist/src/scripts/createJsonSchema.d.ts.map +1 -0
- package/dist/src/scripts/update-preview-tokens.d.ts +3 -0
- package/dist/src/scripts/update-preview-tokens.d.ts.map +1 -0
- package/dist/src/tokens/build.d.ts +4 -0
- package/dist/src/tokens/build.d.ts.map +1 -0
- package/dist/src/tokens/build.js +41 -0
- package/dist/src/tokens/create/files.d.ts +11 -0
- package/dist/src/tokens/create/files.d.ts.map +1 -0
- package/dist/src/tokens/create/files.js +44 -0
- package/dist/src/tokens/create/generators/$designsystemet.d.ts +5 -0
- package/dist/src/tokens/create/generators/$designsystemet.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/$designsystemet.js +10 -0
- package/dist/src/tokens/create/generators/$metadata.d.ts +8 -0
- package/dist/src/tokens/create/generators/$metadata.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/$metadata.js +19 -0
- package/dist/src/tokens/create/generators/$themes.d.ts +27 -0
- package/dist/src/tokens/create/generators/$themes.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/$themes.js +158 -0
- package/dist/src/tokens/create/generators/primitives/color-scheme.d.ts +5 -0
- package/dist/src/tokens/create/generators/primitives/color-scheme.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/primitives/color-scheme.js +71 -0
- package/dist/src/tokens/create/generators/primitives/globals.d.ts +3 -0
- package/dist/src/tokens/create/generators/primitives/globals.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/primitives/globals.js +142 -0
- package/dist/src/tokens/create/generators/primitives/size.d.ts +4 -0
- package/dist/src/tokens/create/generators/primitives/size.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/primitives/size.js +147 -0
- package/dist/src/tokens/create/generators/primitives/typography.d.ts +4 -0
- package/dist/src/tokens/create/generators/primitives/typography.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/primitives/typography.js +216 -0
- package/dist/src/tokens/create/generators/semantic/color-modes.d.ts +8 -0
- package/dist/src/tokens/create/generators/semantic/color-modes.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/semantic/color-modes.js +26 -0
- package/dist/src/tokens/create/generators/semantic/color.d.ts +5 -0
- package/dist/src/tokens/create/generators/semantic/color.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/semantic/color.js +46 -0
- package/dist/src/tokens/create/generators/semantic/style.d.ts +3 -0
- package/dist/src/tokens/create/generators/semantic/style.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/semantic/style.js +381 -0
- package/dist/src/tokens/create/generators/themes/theme.d.ts +3 -0
- package/dist/src/tokens/create/generators/themes/theme.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/themes/theme.js +112 -0
- package/dist/src/tokens/create.d.ts +21 -0
- package/dist/src/tokens/create.d.ts.map +1 -0
- package/dist/src/tokens/create.js +47 -0
- package/dist/src/tokens/format.d.ts +15 -0
- package/dist/src/tokens/format.d.ts.map +1 -0
- package/dist/src/tokens/format.js +41 -0
- package/dist/src/tokens/generate-config.d.ts +10 -0
- package/dist/src/tokens/generate-config.d.ts.map +1 -0
- package/dist/src/tokens/generate-config.js +178 -0
- package/dist/src/tokens/index.d.ts +4 -0
- package/dist/src/tokens/index.d.ts.map +1 -0
- package/dist/src/tokens/index.js +3 -0
- package/dist/src/tokens/process/configs/color.d.ts +12 -0
- package/dist/src/tokens/process/configs/color.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/color.js +51 -0
- package/dist/src/tokens/process/configs/semantic.d.ts +3 -0
- package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/semantic.js +47 -0
- package/dist/src/tokens/process/configs/shared.d.ts +10 -0
- package/dist/src/tokens/process/configs/shared.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/shared.js +19 -0
- package/dist/src/tokens/process/configs/size-mode.d.ts +3 -0
- package/dist/src/tokens/process/configs/size-mode.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/size-mode.js +28 -0
- package/dist/src/tokens/process/configs/size.d.ts +3 -0
- package/dist/src/tokens/process/configs/size.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/size.js +34 -0
- package/dist/src/tokens/process/configs/type-scale.d.ts +3 -0
- package/dist/src/tokens/process/configs/type-scale.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/type-scale.js +49 -0
- package/dist/src/tokens/process/configs/typography.d.ts +3 -0
- package/dist/src/tokens/process/configs/typography.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/typography.js +64 -0
- package/dist/src/tokens/process/configs.d.ts +20 -0
- package/dist/src/tokens/process/configs.d.ts.map +1 -0
- package/dist/src/tokens/process/configs.js +90 -0
- package/dist/src/tokens/process/formats/css/color.d.ts +4 -0
- package/dist/src/tokens/process/formats/css/color.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/color.js +63 -0
- package/dist/src/tokens/process/formats/css/semantic.d.ts +3 -0
- package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/semantic.js +29 -0
- package/dist/src/tokens/process/formats/css/size-mode.d.ts +4 -0
- package/dist/src/tokens/process/formats/css/size-mode.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/size-mode.js +50 -0
- package/dist/src/tokens/process/formats/css/size.d.ts +21 -0
- package/dist/src/tokens/process/formats/css/size.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/size.js +93 -0
- package/dist/src/tokens/process/formats/css/type-scale.d.ts +3 -0
- package/dist/src/tokens/process/formats/css/type-scale.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/type-scale.js +55 -0
- package/dist/src/tokens/process/formats/css/typography.d.ts +3 -0
- package/dist/src/tokens/process/formats/css/typography.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/typography.js +29 -0
- package/dist/src/tokens/process/formats/css.d.ts +11 -0
- package/dist/src/tokens/process/formats/css.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css.js +18 -0
- package/dist/src/tokens/process/output/declarations.d.ts +5 -0
- package/dist/src/tokens/process/output/declarations.d.ts.map +1 -0
- package/dist/src/tokens/process/output/declarations.js +38 -0
- package/dist/src/tokens/process/output/tailwind.d.ts +3 -0
- package/dist/src/tokens/process/output/tailwind.d.ts.map +1 -0
- package/dist/src/tokens/process/output/tailwind.js +45 -0
- package/dist/src/tokens/process/output/theme.d.ts +27 -0
- package/dist/src/tokens/process/output/theme.d.ts.map +1 -0
- package/dist/src/tokens/process/output/theme.js +83 -0
- package/dist/src/tokens/process/platform.d.ts +106 -0
- package/dist/src/tokens/process/platform.d.ts.map +1 -0
- package/dist/src/tokens/process/platform.js +168 -0
- package/dist/src/tokens/process/transformers.d.ts +6 -0
- package/dist/src/tokens/process/transformers.d.ts.map +1 -0
- package/dist/src/tokens/process/transformers.js +54 -0
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts +36 -0
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts.map +1 -0
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +114 -0
- package/dist/src/tokens/process/utils/kebab-case.d.ts +5 -0
- package/dist/src/tokens/process/utils/kebab-case.d.ts.map +1 -0
- package/dist/src/tokens/process/utils/kebab-case.js +9 -0
- package/dist/src/tokens/types.d.ts +74 -0
- package/dist/src/tokens/types.d.ts.map +1 -0
- package/dist/src/tokens/types.js +7 -0
- package/dist/src/tokens/utils.d.ts +63 -0
- package/dist/src/tokens/utils.d.ts.map +1 -0
- package/dist/src/tokens/utils.js +121 -0
- package/dist/src/types.d.ts +6 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/utils/filesystem.d.ts +40 -0
- package/dist/src/utils/filesystem.d.ts.map +1 -0
- package/dist/src/utils/filesystem.js +115 -0
- package/package.json +87 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { baseColorNames } from "../../../../colors/colorMetadata.js";
|
|
2
|
+
import { semanticColorMap } from "../../../../colors/types.js";
|
|
3
|
+
import * as R from "ramda";
|
|
4
|
+
//#region src/tokens/create/generators/themes/theme.ts
|
|
5
|
+
const generateTheme = (colors, themeName, borderRadius) => {
|
|
6
|
+
const mainColorNames = Object.keys(colors.main);
|
|
7
|
+
const supportColorNames = Object.keys(colors.support);
|
|
8
|
+
const customColors = [
|
|
9
|
+
...mainColorNames,
|
|
10
|
+
"neutral",
|
|
11
|
+
...supportColorNames,
|
|
12
|
+
...baseColorNames
|
|
13
|
+
];
|
|
14
|
+
const themeColorTokens = Object.fromEntries(customColors.map((colorName) => [colorName, generateColorScaleTokens(colorName, themeName)]));
|
|
15
|
+
const { color: themeBaseFileColor, ...remainingThemeFile } = generateBase(themeName);
|
|
16
|
+
const themeFile = {
|
|
17
|
+
color: {
|
|
18
|
+
...themeColorTokens,
|
|
19
|
+
...themeBaseFileColor,
|
|
20
|
+
link: { visited: {
|
|
21
|
+
$type: "color",
|
|
22
|
+
$value: `{${themeName}.link.visited}`
|
|
23
|
+
} },
|
|
24
|
+
focus: {
|
|
25
|
+
"inner-color": {
|
|
26
|
+
$type: "color",
|
|
27
|
+
$value: `{${themeName}.focus.inner}`
|
|
28
|
+
},
|
|
29
|
+
"outer-color": {
|
|
30
|
+
$type: "color",
|
|
31
|
+
$value: `{${themeName}.focus.outer}`
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
...remainingThemeFile
|
|
36
|
+
};
|
|
37
|
+
const baseBorderRadius = R.lensPath([
|
|
38
|
+
"border-radius",
|
|
39
|
+
"base",
|
|
40
|
+
"$value"
|
|
41
|
+
]);
|
|
42
|
+
const updatedThemeFile = R.set(baseBorderRadius, String(borderRadius), themeFile);
|
|
43
|
+
return JSON.parse(JSON.stringify(updatedThemeFile, (key, value) => {
|
|
44
|
+
if (key === "$value") return value.replace("<theme>", themeName);
|
|
45
|
+
return value;
|
|
46
|
+
}, 2));
|
|
47
|
+
};
|
|
48
|
+
const generateBase = (themeName) => ({
|
|
49
|
+
color: {},
|
|
50
|
+
"font-family": {
|
|
51
|
+
$type: "fontFamilies",
|
|
52
|
+
$value: `{${themeName}.font-family}`
|
|
53
|
+
},
|
|
54
|
+
"font-weight": {
|
|
55
|
+
medium: {
|
|
56
|
+
$type: "fontWeights",
|
|
57
|
+
$value: `{${themeName}.font-weight.medium}`
|
|
58
|
+
},
|
|
59
|
+
semibold: {
|
|
60
|
+
$type: "fontWeights",
|
|
61
|
+
$value: `{${themeName}.font-weight.semibold}`
|
|
62
|
+
},
|
|
63
|
+
regular: {
|
|
64
|
+
$type: "fontWeights",
|
|
65
|
+
$value: `{${themeName}.font-weight.regular}`
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"border-radius": {
|
|
69
|
+
"1": {
|
|
70
|
+
$type: "dimension",
|
|
71
|
+
$value: "min({border-radius.base}*0.5,{border-radius.scale})"
|
|
72
|
+
},
|
|
73
|
+
"2": {
|
|
74
|
+
$type: "dimension",
|
|
75
|
+
$value: "min({border-radius.base},{border-radius.scale}*2)"
|
|
76
|
+
},
|
|
77
|
+
"3": {
|
|
78
|
+
$type: "dimension",
|
|
79
|
+
$value: "min({border-radius.base}*2,{border-radius.scale}*5)"
|
|
80
|
+
},
|
|
81
|
+
"4": {
|
|
82
|
+
$type: "dimension",
|
|
83
|
+
$value: "min({border-radius.base}*3,{border-radius.scale}*7)"
|
|
84
|
+
},
|
|
85
|
+
"5": {
|
|
86
|
+
$type: "dimension",
|
|
87
|
+
$value: "{border-radius.base}"
|
|
88
|
+
},
|
|
89
|
+
"6": {
|
|
90
|
+
$type: "dimension",
|
|
91
|
+
$value: "9999"
|
|
92
|
+
},
|
|
93
|
+
base: {
|
|
94
|
+
$type: "dimension",
|
|
95
|
+
$value: "4"
|
|
96
|
+
},
|
|
97
|
+
scale: {
|
|
98
|
+
$type: "dimension",
|
|
99
|
+
$value: "4"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const generateColorScaleTokens = (colorName, themeName) => {
|
|
104
|
+
const colorScale = {};
|
|
105
|
+
for (const [_, colorNumber] of R.toPairs(semanticColorMap)) colorScale[colorNumber] = {
|
|
106
|
+
$type: "color",
|
|
107
|
+
$value: `{${themeName}.${colorName}.${colorNumber}}`
|
|
108
|
+
};
|
|
109
|
+
return colorScale;
|
|
110
|
+
};
|
|
111
|
+
//#endregion
|
|
112
|
+
export { generateTheme };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Theme, TokenSets } from './types.js';
|
|
2
|
+
export declare const cliOptions: {
|
|
3
|
+
readonly outDir: "out-dir";
|
|
4
|
+
readonly clean: "clean";
|
|
5
|
+
readonly tailwind: "tailwind";
|
|
6
|
+
readonly theme: {
|
|
7
|
+
readonly colors: {
|
|
8
|
+
readonly main: "main-colors";
|
|
9
|
+
readonly support: "support-colors";
|
|
10
|
+
readonly neutral: "neutral-color";
|
|
11
|
+
};
|
|
12
|
+
readonly typography: {
|
|
13
|
+
readonly fontFamily: "font-family";
|
|
14
|
+
};
|
|
15
|
+
readonly borderRadius: "border-radius";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare const createTokens: (theme: Theme) => Promise<{
|
|
19
|
+
tokenSets: TokenSets;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/tokens/create.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAa,KAAK,EAAY,SAAS,EAAE,MAAM,YAAY,CAAC;AAExE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;CAeb,CAAC;AAEX,eAAO,MAAM,YAAY,GAAU,OAAO,KAAK;;EA4B9C,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { generateColorScheme } from "./create/generators/primitives/color-scheme.js";
|
|
2
|
+
import { generateGlobals } from "./create/generators/primitives/globals.js";
|
|
3
|
+
import { generateSize, generateSizeGlobal } from "./create/generators/primitives/size.js";
|
|
4
|
+
import { generateFontSizes, generateTypography } from "./create/generators/primitives/typography.js";
|
|
5
|
+
import { generateSemanticColors } from "./create/generators/semantic/color.js";
|
|
6
|
+
import { generateColorModes } from "./create/generators/semantic/color-modes.js";
|
|
7
|
+
import { generateSemanticStyle } from "./create/generators/semantic/style.js";
|
|
8
|
+
import { generateTheme } from "./create/generators/themes/theme.js";
|
|
9
|
+
//#region src/tokens/create.ts
|
|
10
|
+
const cliOptions = {
|
|
11
|
+
outDir: "out-dir",
|
|
12
|
+
clean: "clean",
|
|
13
|
+
tailwind: "tailwind",
|
|
14
|
+
theme: {
|
|
15
|
+
colors: {
|
|
16
|
+
main: "main-colors",
|
|
17
|
+
support: "support-colors",
|
|
18
|
+
neutral: "neutral-color"
|
|
19
|
+
},
|
|
20
|
+
typography: { fontFamily: "font-family" },
|
|
21
|
+
borderRadius: "border-radius"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const createTokens = async (theme) => {
|
|
25
|
+
const { colors, typography, name, borderRadius, overrides } = theme;
|
|
26
|
+
const colorSchemes = ["light", "dark"];
|
|
27
|
+
const sizeModes = [
|
|
28
|
+
"small",
|
|
29
|
+
"medium",
|
|
30
|
+
"large"
|
|
31
|
+
];
|
|
32
|
+
return { tokenSets: new Map([
|
|
33
|
+
["primitives/globals", generateGlobals()],
|
|
34
|
+
...sizeModes.map((size) => [`primitives/modes/size/${size}`, generateSize(size)]),
|
|
35
|
+
["primitives/modes/size/global", generateSizeGlobal()],
|
|
36
|
+
...sizeModes.map((size) => [`primitives/modes/typography/size/${size}`, generateFontSizes(size)]),
|
|
37
|
+
[`primitives/modes/typography/primary/${name}`, generateTypography(name, typography)],
|
|
38
|
+
[`primitives/modes/typography/secondary/${name}`, generateTypography(name, typography)],
|
|
39
|
+
...colorSchemes.flatMap((scheme) => [[`primitives/modes/color-scheme/${scheme}/${name}`, generateColorScheme(name, scheme, colors, overrides)]]),
|
|
40
|
+
[`themes/${name}`, generateTheme(colors, name, borderRadius)],
|
|
41
|
+
["semantic/color", generateSemanticColors(colors, name)],
|
|
42
|
+
...Object.entries(generateColorModes(colors, name)).flatMap(([mode, colors]) => Object.entries(colors).map(([key, colorSet]) => [`semantic/modes/${mode}/${key}`, colorSet])),
|
|
43
|
+
[`semantic/style`, generateSemanticStyle()]
|
|
44
|
+
]) };
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { cliOptions, createTokens };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FormatOptions } from './process/platform.js';
|
|
2
|
+
import type { Theme } from './types.js';
|
|
3
|
+
export declare const formatTokens: (options: Omit<FormatOptions, "type" | "buildTokenFormats">) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
4
|
+
export declare const formatTheme: (themeConfig: Theme) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
5
|
+
/**
|
|
6
|
+
* Formats a theme configuration into CSS.
|
|
7
|
+
*
|
|
8
|
+
* This function takes a `Theme` configuration object, processes it using the
|
|
9
|
+
* `formatTheme` function, and then generates CSS using the `createThemeCSS` function.
|
|
10
|
+
*
|
|
11
|
+
* @param themeConfig - The theme configuration object to be formatted.
|
|
12
|
+
* @returns A promise that resolves to the generated CSS string.
|
|
13
|
+
*/
|
|
14
|
+
export declare const formatThemeCSS: (themeConfig: Theme) => Promise<string>;
|
|
15
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/tokens/format.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAa,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnD,eAAO,MAAM,YAAY,GAAU,SAAS,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,mBAAmB,CAAC,2DAQ5F,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,aAAa,KAAK,2DAcnD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,aAAa,KAAK,oBAItD,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createTokens } from "./create.js";
|
|
2
|
+
import { processThemeObject } from "./process/utils/getMultidimensionalThemes.js";
|
|
3
|
+
import { processPlatform } from "./process/platform.js";
|
|
4
|
+
import { createThemeCSSFiles } from "./process/output/theme.js";
|
|
5
|
+
import { generate$Themes } from "./create/generators/$themes.js";
|
|
6
|
+
import * as R from "ramda";
|
|
7
|
+
//#region src/tokens/format.ts
|
|
8
|
+
const formatTokens = async (options) => {
|
|
9
|
+
return await processPlatform({
|
|
10
|
+
type: "format",
|
|
11
|
+
buildTokenFormats: {},
|
|
12
|
+
...options
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
const formatTheme = async (themeConfig) => {
|
|
16
|
+
const { tokenSets } = await createTokens(themeConfig);
|
|
17
|
+
return await formatTokens({
|
|
18
|
+
tokenSets,
|
|
19
|
+
processed$themes: (await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors, [
|
|
20
|
+
"small",
|
|
21
|
+
"medium",
|
|
22
|
+
"large"
|
|
23
|
+
])).map(processThemeObject),
|
|
24
|
+
verbose: false
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Formats a theme configuration into CSS.
|
|
29
|
+
*
|
|
30
|
+
* This function takes a `Theme` configuration object, processes it using the
|
|
31
|
+
* `formatTheme` function, and then generates CSS using the `createThemeCSS` function.
|
|
32
|
+
*
|
|
33
|
+
* @param themeConfig - The theme configuration object to be formatted.
|
|
34
|
+
* @returns A promise that resolves to the generated CSS string.
|
|
35
|
+
*/
|
|
36
|
+
const formatThemeCSS = async (themeConfig) => {
|
|
37
|
+
const themeCSSFiles = createThemeCSSFiles({ processedBuilds: await formatTheme(themeConfig) });
|
|
38
|
+
return R.head(themeCSSFiles)?.output ?? "";
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { formatTheme, formatThemeCSS, formatTokens };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CreateConfigSchema } from '../config.js';
|
|
2
|
+
export type GenerateConfigOptions = {
|
|
3
|
+
tokensDir: string;
|
|
4
|
+
outFile?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Generates a config file from existing design tokens
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateConfigFromTokens(options: GenerateConfigOptions): Promise<CreateConfigSchema>;
|
|
10
|
+
//# sourceMappingURL=generate-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-config.d.ts","sourceRoot":"","sources":["../../../src/tokens/generate-config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AA6MvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA6E1G"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { dsfs } from "../utils/filesystem.js";
|
|
2
|
+
import pc from "picocolors";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
//#region src/tokens/generate-config.ts
|
|
5
|
+
/**
|
|
6
|
+
* Reads a JSON file and returns its content as an object
|
|
7
|
+
*/
|
|
8
|
+
async function readJsonFile(filePath) {
|
|
9
|
+
try {
|
|
10
|
+
const content = await dsfs.readFile(filePath);
|
|
11
|
+
return JSON.parse(content);
|
|
12
|
+
} catch (err) {
|
|
13
|
+
throw new Error(`Failed to read token file at ${filePath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Extract the base hex color from a color scale (color.12)
|
|
18
|
+
*/
|
|
19
|
+
function extractBaseColor(colorScale) {
|
|
20
|
+
if ("12" in colorScale && typeof colorScale["12"] === "object" && "$value" in colorScale["12"]) {
|
|
21
|
+
const token = colorScale["12"];
|
|
22
|
+
if (token.$type === "color") return token.$value;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Discovers theme names from the primitives/modes/color-scheme/light/
|
|
28
|
+
*/
|
|
29
|
+
async function discoverThemes(tokensDir) {
|
|
30
|
+
const lightModePath = path.join(tokensDir, "themes");
|
|
31
|
+
try {
|
|
32
|
+
return (await dsfs.readdir(lightModePath)).filter((file) => file.endsWith(".json")).map((file) => file.replace(".json", ""));
|
|
33
|
+
} catch {
|
|
34
|
+
throw new Error(`Could not find themes. Make sure ${pc.blue(lightModePath)} exists and contains theme JSON files.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Reads token information for a specific theme from primitives/modes/color-scheme/light/<theme>.json
|
|
39
|
+
*/
|
|
40
|
+
async function readThemeTokens(tokensDir, themeName) {
|
|
41
|
+
return readJsonFile(path.join(tokensDir, "primitives", "modes", "color-scheme", "light", `${themeName}.json`));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Reads the theme configuration from themes/<theme>.json
|
|
45
|
+
*/
|
|
46
|
+
async function readThemeConfig(tokensDir, themeName) {
|
|
47
|
+
const themeConfigPath = path.join(tokensDir, "themes", `${themeName}.json`);
|
|
48
|
+
try {
|
|
49
|
+
return await readJsonFile(themeConfigPath);
|
|
50
|
+
} catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Extract border-radius base value from theme config
|
|
56
|
+
*/
|
|
57
|
+
function extractBorderRadius(themeConfig) {
|
|
58
|
+
if (!themeConfig || !("border-radius" in themeConfig)) return;
|
|
59
|
+
const borderRadius = themeConfig["border-radius"];
|
|
60
|
+
if ("base" in borderRadius && typeof borderRadius.base === "object" && "$value" in borderRadius.base) {
|
|
61
|
+
const token = borderRadius.base;
|
|
62
|
+
return Number(token.$value);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Extract font family from theme config
|
|
67
|
+
*/
|
|
68
|
+
function extractFontFamily(themeConfig) {
|
|
69
|
+
if (!themeConfig || !("font-family" in themeConfig)) return;
|
|
70
|
+
const fontFamily = themeConfig["font-family"];
|
|
71
|
+
if (typeof fontFamily === "object" && "$value" in fontFamily) {
|
|
72
|
+
const value = fontFamily.$value;
|
|
73
|
+
if (value.startsWith("{") && value.endsWith("}")) return;
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Reads the typography configuration from primitives/modes/typography/primary/<theme>.json
|
|
79
|
+
*/
|
|
80
|
+
async function readTypographyConfig(tokensDir, themeName) {
|
|
81
|
+
const typographyConfigPath = path.join(tokensDir, "primitives", "modes", "typography", "primary", `${themeName}.json`);
|
|
82
|
+
try {
|
|
83
|
+
return await readJsonFile(typographyConfigPath);
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Extract font family from typography primitives
|
|
90
|
+
*/
|
|
91
|
+
function extractFontFamilyFromPrimitives(typographyConfig, themeName) {
|
|
92
|
+
if (!typographyConfig) return;
|
|
93
|
+
const themeTypography = typographyConfig[themeName];
|
|
94
|
+
if (!themeTypography || !("font-family" in themeTypography)) return;
|
|
95
|
+
const fontFamily = themeTypography["font-family"];
|
|
96
|
+
if (typeof fontFamily === "object" && "$value" in fontFamily) return fontFamily.$value;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Categorizes colors into main, support, and neutral based on color names
|
|
100
|
+
*/
|
|
101
|
+
function categorizeColors(themeTokens, themeName) {
|
|
102
|
+
const main = {};
|
|
103
|
+
const support = {};
|
|
104
|
+
let neutral = null;
|
|
105
|
+
const builtInColors = [
|
|
106
|
+
"neutral",
|
|
107
|
+
"info",
|
|
108
|
+
"success",
|
|
109
|
+
"warning",
|
|
110
|
+
"danger"
|
|
111
|
+
];
|
|
112
|
+
const specialKeys = ["link"];
|
|
113
|
+
const themeColors = themeTokens[themeName];
|
|
114
|
+
if (!themeColors) return {
|
|
115
|
+
main,
|
|
116
|
+
support,
|
|
117
|
+
neutral
|
|
118
|
+
};
|
|
119
|
+
for (const [colorName, colorValue] of Object.entries(themeColors)) {
|
|
120
|
+
if (specialKeys.includes(colorName)) continue;
|
|
121
|
+
if (typeof colorValue === "object" && !("$value" in colorValue)) {
|
|
122
|
+
const baseColor = extractBaseColor(colorValue);
|
|
123
|
+
if (baseColor) if (colorName === "neutral") neutral = baseColor;
|
|
124
|
+
else if (builtInColors.includes(colorName)) {} else if (colorName === "accent") main[colorName] = baseColor;
|
|
125
|
+
else support[colorName] = baseColor;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
main,
|
|
130
|
+
support,
|
|
131
|
+
neutral
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Generates a config file from existing design tokens
|
|
136
|
+
*/
|
|
137
|
+
async function generateConfigFromTokens(options) {
|
|
138
|
+
const { tokensDir } = options;
|
|
139
|
+
console.log(`\nReading tokens from ${pc.blue(tokensDir)}`);
|
|
140
|
+
const themes = await discoverThemes(tokensDir);
|
|
141
|
+
if (themes.length === 0) throw new Error(`\nNo themes found in ${pc.blue(tokensDir)}`);
|
|
142
|
+
console.log(`\nFound ${pc.green(String(themes.length))} theme(s): ${themes.map((t) => pc.cyan(t)).join(", ")}`);
|
|
143
|
+
const config = {
|
|
144
|
+
outDir: tokensDir,
|
|
145
|
+
themes: {}
|
|
146
|
+
};
|
|
147
|
+
for (const themeName of themes) {
|
|
148
|
+
console.log(`\nProcessing theme ${pc.cyan(themeName)}...`);
|
|
149
|
+
const themeTokens = await readThemeTokens(tokensDir, themeName);
|
|
150
|
+
const themeConfig = await readThemeConfig(tokensDir, themeName);
|
|
151
|
+
const typographyConfig = await readTypographyConfig(tokensDir, themeName);
|
|
152
|
+
const { main, support, neutral } = categorizeColors(themeTokens, themeName);
|
|
153
|
+
if (Object.keys(main).length === 0) console.warn(pc.yellow(`\nWarning: No main colors found for theme ${themeName}`));
|
|
154
|
+
if (!neutral) {
|
|
155
|
+
console.warn(pc.yellow(`\nWarning: No neutral color found for theme ${themeName}`));
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const borderRadius = extractBorderRadius(themeConfig);
|
|
159
|
+
const fontFamily = extractFontFamily(themeConfig) ?? extractFontFamilyFromPrimitives(typographyConfig, themeName);
|
|
160
|
+
config.themes[themeName] = {
|
|
161
|
+
colors: {
|
|
162
|
+
main,
|
|
163
|
+
support,
|
|
164
|
+
neutral
|
|
165
|
+
},
|
|
166
|
+
borderRadius,
|
|
167
|
+
typography: fontFamily ? { fontFamily } : void 0
|
|
168
|
+
};
|
|
169
|
+
console.log(`\n✅ Main colors: ${Object.keys(main).map((c) => pc.cyan(c)).join(", ") || pc.dim("none")}`);
|
|
170
|
+
console.log(`\n✅ Support colors: ${Object.keys(support).map((c) => pc.cyan(c)).join(", ") || pc.dim("none")}`);
|
|
171
|
+
console.log(`\n✅ Neutral: ${pc.cyan(neutral)}`);
|
|
172
|
+
if (borderRadius !== void 0) console.log(`\n✅ Border radius: ${pc.cyan(String(borderRadius))}`);
|
|
173
|
+
if (fontFamily) console.log(`\n✅ Font family: ${pc.cyan(fontFamily)}`);
|
|
174
|
+
}
|
|
175
|
+
return config;
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
export { generateConfigFromTokens };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tokens/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EAAE,KAAK,IAAI,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BuiltInColors, ColorCategories } from '../../types.js';
|
|
2
|
+
import { type GetStyleDictionaryConfig } from './shared.js';
|
|
3
|
+
export declare const colorSchemeVariables: GetStyleDictionaryConfig;
|
|
4
|
+
type ColorCategoryOpts = {
|
|
5
|
+
category: ColorCategories;
|
|
6
|
+
} | {
|
|
7
|
+
category: 'builtin';
|
|
8
|
+
color: BuiltInColors;
|
|
9
|
+
};
|
|
10
|
+
export declare const colorCategoryVariables: (opts: ColorCategoryOpts) => GetStyleDictionaryConfig;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/configs/color.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKrE,OAAO,EAAkB,KAAK,wBAAwB,EAAU,MAAM,aAAa,CAAC;AAEpF,eAAO,MAAM,oBAAoB,EAAE,wBA8BlC,CAAC;AAEF,KAAK,iBAAiB,GAAG;IAAE,QAAQ,EAAE,eAAe,CAAA;CAAE,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,CAAC;AAEvG,eAAO,MAAM,sBAAsB,GAChC,MAAM,iBAAiB,KAAG,wBAgD1B,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { isColorCategoryToken, isSemanticColorToken, typeEquals } from "../../utils.js";
|
|
2
|
+
import { dsTransformers } from "./shared.js";
|
|
3
|
+
import { formats } from "../formats/css.js";
|
|
4
|
+
import { buildOptions } from "../platform.js";
|
|
5
|
+
import * as R from "ramda";
|
|
6
|
+
//#region src/tokens/process/configs/color.ts
|
|
7
|
+
const colorSchemeVariables = ({ "color-scheme": colorScheme = "light", theme }) => {
|
|
8
|
+
return {
|
|
9
|
+
preprocessors: ["tokens-studio"],
|
|
10
|
+
platforms: { css: {
|
|
11
|
+
colorScheme,
|
|
12
|
+
theme,
|
|
13
|
+
selector: `${colorScheme === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme}"]`,
|
|
14
|
+
layer: `ds.theme.color-scheme.${colorScheme}`,
|
|
15
|
+
prefix: "ds",
|
|
16
|
+
buildPath: `${theme}/`,
|
|
17
|
+
transforms: dsTransformers,
|
|
18
|
+
files: [{
|
|
19
|
+
destination: `color-scheme/${colorScheme}.css`,
|
|
20
|
+
format: formats.colorScheme.name,
|
|
21
|
+
filter: (token) => typeEquals("color", token) && !R.startsWith(["global"], token.path)
|
|
22
|
+
}],
|
|
23
|
+
options: { outputReferences: false }
|
|
24
|
+
} }
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme, theme, ...permutation }) => {
|
|
28
|
+
const category = opts.category;
|
|
29
|
+
const color = category === "builtin" ? opts.color : permutation[`${category}-color`];
|
|
30
|
+
if (!color) throw new Error(category === "builtin" ? `Missing color for built-in color ${opts.color}` : `Missing color for category ${category}`);
|
|
31
|
+
return {
|
|
32
|
+
preprocessors: ["tokens-studio"],
|
|
33
|
+
platforms: { css: {
|
|
34
|
+
colorScheme,
|
|
35
|
+
theme,
|
|
36
|
+
selector: color === buildOptions?.defaultColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`,
|
|
37
|
+
layer: `ds.theme.color`,
|
|
38
|
+
prefix: "ds",
|
|
39
|
+
buildPath: `${theme}/`,
|
|
40
|
+
transforms: dsTransformers,
|
|
41
|
+
files: [{
|
|
42
|
+
destination: `color/${color}.css`,
|
|
43
|
+
format: formats.colorCategory.name,
|
|
44
|
+
filter: (token) => category === "builtin" ? isSemanticColorToken(token, color) : isColorCategoryToken(token, category)
|
|
45
|
+
}],
|
|
46
|
+
options: { outputReferences: true }
|
|
47
|
+
} }
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { colorCategoryVariables, colorSchemeVariables };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/configs/semantic.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkC,KAAK,wBAAwB,EAAU,MAAM,aAAa,CAAC;AAEpG,eAAO,MAAM,iBAAiB,EAAE,wBA4C/B,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { pathStartsWithOneOf, typeEquals } from "../../utils.js";
|
|
2
|
+
import { dsTransformers } from "./shared.js";
|
|
3
|
+
import { formats } from "../formats/css.js";
|
|
4
|
+
import * as R from "ramda";
|
|
5
|
+
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
6
|
+
//#region src/tokens/process/configs/semantic.ts
|
|
7
|
+
const semanticVariables = ({ theme }) => {
|
|
8
|
+
return {
|
|
9
|
+
preprocessors: ["tokens-studio"],
|
|
10
|
+
platforms: { css: {
|
|
11
|
+
theme,
|
|
12
|
+
basePxFontSize: 16,
|
|
13
|
+
selector: `:root`,
|
|
14
|
+
layer: `ds.theme.semantic`,
|
|
15
|
+
prefix: "ds",
|
|
16
|
+
buildPath: `${theme}/`,
|
|
17
|
+
transforms: dsTransformers,
|
|
18
|
+
files: [{
|
|
19
|
+
destination: `semantic.css`,
|
|
20
|
+
format: formats.semantic.name,
|
|
21
|
+
filter: (token) => {
|
|
22
|
+
const isUwantedToken = R.anyPass([R.includes("primitives/global")])(token.filePath);
|
|
23
|
+
const isPrivateToken = R.includes("_", token.path);
|
|
24
|
+
const unwantedPaths = pathStartsWithOneOf([
|
|
25
|
+
"size",
|
|
26
|
+
"_size",
|
|
27
|
+
"font-size",
|
|
28
|
+
"line-height",
|
|
29
|
+
"letter-spacing"
|
|
30
|
+
], token);
|
|
31
|
+
const unwantedTypes = typeEquals([
|
|
32
|
+
"color",
|
|
33
|
+
"fontWeight",
|
|
34
|
+
"fontFamily",
|
|
35
|
+
"typography"
|
|
36
|
+
], token);
|
|
37
|
+
return !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
38
|
+
}
|
|
39
|
+
}],
|
|
40
|
+
options: { outputReferences: (token, options) => {
|
|
41
|
+
return pathStartsWithOneOf(["border-radius"], token) && outputReferencesFilter(token, options);
|
|
42
|
+
} }
|
|
43
|
+
} }
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { semanticVariables };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Config as StyleDictionaryConfig } from 'style-dictionary/types';
|
|
2
|
+
import type { ThemePermutation } from '../../types.js';
|
|
3
|
+
export type GetStyleDictionaryConfig = (permutation: ThemePermutation) => StyleDictionaryConfig | {
|
|
4
|
+
config: StyleDictionaryConfig;
|
|
5
|
+
permutationOverrides?: Partial<ThemePermutation>;
|
|
6
|
+
}[];
|
|
7
|
+
export declare const prefix = "ds";
|
|
8
|
+
export declare const basePxFontSize = 16;
|
|
9
|
+
export declare const dsTransformers: string[];
|
|
10
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/configs/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,MAAM,MAAM,wBAAwB,GAAG,CACrC,WAAW,EAAE,gBAAgB,KAC1B,qBAAqB,GAAG;IAAE,MAAM,EAAE,qBAAqB,CAAC;IAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAA;CAAE,EAAE,CAAC;AAEnH,eAAO,MAAM,MAAM,OAAO,CAAC;AAC3B,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,eAAO,MAAM,cAAc,UAY1B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { resolveMath, sizeRem, typographyName, unitless } from "../transformers.js";
|
|
2
|
+
//#region src/tokens/process/configs/shared.ts
|
|
3
|
+
const prefix = "ds";
|
|
4
|
+
const basePxFontSize = 16;
|
|
5
|
+
const dsTransformers = [
|
|
6
|
+
"name/kebab",
|
|
7
|
+
resolveMath.name,
|
|
8
|
+
"ts/size/px",
|
|
9
|
+
sizeRem.name,
|
|
10
|
+
unitless.name,
|
|
11
|
+
"ts/typography/fontWeight",
|
|
12
|
+
typographyName.name,
|
|
13
|
+
"ts/color/modifiers",
|
|
14
|
+
"ts/color/css/hexrgba",
|
|
15
|
+
"ts/size/lineheight",
|
|
16
|
+
"shadow/css/shorthand"
|
|
17
|
+
];
|
|
18
|
+
//#endregion
|
|
19
|
+
export { basePxFontSize, dsTransformers, prefix };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size-mode.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/configs/size-mode.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkC,KAAK,wBAAwB,EAAU,MAAM,aAAa,CAAC;AAEpG,eAAO,MAAM,iBAAiB,EAAE,wBA8B/B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { dsTransformers } from "./shared.js";
|
|
2
|
+
import { formats } from "../formats/css.js";
|
|
3
|
+
import * as R from "ramda";
|
|
4
|
+
//#region src/tokens/process/configs/size-mode.ts
|
|
5
|
+
const sizeModeVariables = ({ theme, size }) => {
|
|
6
|
+
return {
|
|
7
|
+
preprocessors: ["tokens-studio"],
|
|
8
|
+
platforms: { css: {
|
|
9
|
+
size,
|
|
10
|
+
theme,
|
|
11
|
+
basePxFontSize: 16,
|
|
12
|
+
selector: `:root`,
|
|
13
|
+
layer: `ds.theme.size-mode`,
|
|
14
|
+
prefix: "ds",
|
|
15
|
+
buildPath: `${theme}/`,
|
|
16
|
+
transforms: dsTransformers,
|
|
17
|
+
files: [{
|
|
18
|
+
destination: `size-mode/${size}.css`,
|
|
19
|
+
format: formats.sizeMode.name,
|
|
20
|
+
filter: (token) => {
|
|
21
|
+
return R.equals(["_size", "mode-font-size"], token.path);
|
|
22
|
+
}
|
|
23
|
+
}]
|
|
24
|
+
} }
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { sizeModeVariables };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/configs/size.ts"],"names":[],"mappings":"AAMA,OAAO,EAAkC,KAAK,wBAAwB,EAAU,MAAM,aAAa,CAAC;AAEpG,eAAO,MAAM,aAAa,EAAE,wBAuC3B,CAAC"}
|