@digdir/designsystemet 1.0.0-next.35 → 1.0.0-next.36
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/README.md +16 -0
- package/dist/{types/bin → bin}/designsystemet.d.ts.map +1 -1
- package/dist/bin/designsystemet.js +14 -15
- package/dist/src/colors/index.d.ts.map +1 -0
- package/dist/{types/src → src}/colors/theme.d.ts +8 -3
- package/dist/src/colors/theme.d.ts.map +1 -0
- package/dist/src/colors/theme.js +17 -18
- package/dist/{types/src → src}/colors/types.d.ts +0 -1
- package/dist/src/colors/types.d.ts.map +1 -0
- package/dist/{types/src → src}/colors/utils.d.ts +7 -1
- package/dist/src/colors/utils.d.ts.map +1 -0
- package/dist/src/colors/utils.js +13 -6
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/init/createTokensPackage.d.ts.map +1 -0
- package/dist/src/init/generateMetadataJson.d.ts.map +1 -0
- package/dist/src/init/generateThemesJson.d.ts.map +1 -0
- package/dist/src/init/index.d.ts.map +1 -0
- package/dist/src/init/nextStepsMarkdown.d.ts.map +1 -0
- package/dist/src/init/utils.d.ts.map +1 -0
- package/dist/src/migrations/beta-to-v1.d.ts.map +1 -0
- package/dist/src/migrations/beta-to-v1.js +4 -4
- package/dist/src/migrations/codemods/css/plugins.d.ts.map +1 -0
- package/dist/src/migrations/codemods/css/run.d.ts.map +1 -0
- package/dist/src/migrations/codemods/jsx/classname-prefix.d.ts.map +1 -0
- package/dist/src/migrations/codemods/jsx/run.d.ts.map +1 -0
- package/dist/src/migrations/index.d.ts.map +1 -0
- package/dist/src/migrations/react-beta-to-v1.d.ts.map +1 -0
- package/dist/src/tokens/build/actions.d.ts.map +1 -0
- package/dist/src/tokens/build/builtin-colors.css +87 -0
- package/dist/src/tokens/build/configs.d.ts +21 -0
- package/dist/src/tokens/build/configs.d.ts.map +1 -0
- package/dist/src/tokens/build/configs.js +114 -61
- package/dist/src/tokens/build/formats/css.d.ts +13 -0
- package/dist/src/tokens/build/formats/css.d.ts.map +1 -0
- package/dist/src/tokens/build/formats/css.js +55 -3
- package/dist/src/tokens/build/formats/js-tokens.d.ts.map +1 -0
- package/dist/src/tokens/build/formats/js-tokens.js +2 -2
- package/dist/{types/src → src}/tokens/build/transformers.d.ts +1 -0
- package/dist/src/tokens/build/transformers.d.ts.map +1 -0
- package/dist/src/tokens/build/transformers.js +13 -0
- package/dist/src/tokens/build/types.d.ts +44 -0
- package/dist/src/tokens/build/types.d.ts.map +1 -0
- package/dist/src/tokens/build/types.js +7 -0
- package/dist/src/tokens/build/utils/entryfile.d.ts.map +1 -0
- package/dist/src/tokens/build/utils/entryfile.js +11 -3
- package/dist/src/tokens/build/utils/getMultidimensionalThemes.d.ts +35 -0
- package/dist/src/tokens/build/utils/getMultidimensionalThemes.d.ts.map +1 -0
- package/dist/src/tokens/build/utils/getMultidimensionalThemes.js +112 -0
- package/dist/src/tokens/build/utils/noCase.d.ts.map +1 -0
- package/dist/{types/src → src}/tokens/build/utils/utils.d.ts +3 -0
- package/dist/src/tokens/build/utils/utils.d.ts.map +1 -0
- package/dist/src/tokens/build/utils/utils.js +15 -0
- package/dist/src/tokens/build.d.ts +17 -0
- package/dist/src/tokens/build.d.ts.map +1 -0
- package/dist/src/tokens/build.js +76 -77
- package/dist/{types/src → src}/tokens/create.d.ts +5 -0
- package/dist/src/tokens/create.d.ts.map +1 -0
- package/dist/src/tokens/create.js +13 -10
- package/dist/src/tokens/design-tokens/default/primitives/globals.json +2 -8
- package/dist/src/tokens/design-tokens/default/semantic/style.json +86 -182
- package/dist/src/tokens/design-tokens/template/$metadata.json +4 -0
- package/dist/src/tokens/design-tokens/template/$themes.json +129 -13
- package/dist/src/tokens/design-tokens/template/semantic/color-base-file.json +262 -0
- package/dist/src/tokens/design-tokens/template/semantic/modes/category-color/category-color-template.json +62 -0
- package/dist/src/tokens/design-tokens/template/semantic/semantic-color-template.json +62 -0
- package/dist/src/tokens/design-tokens/template/themes/theme-base-file.json +53 -0
- package/dist/src/tokens/design-tokens/template/themes/theme-color-template.json +62 -0
- package/dist/src/tokens/index.d.ts +2 -0
- package/dist/src/tokens/index.d.ts.map +1 -0
- package/dist/src/tokens/index.js +5 -0
- package/dist/src/tokens/template.d.ts.map +1 -0
- package/dist/src/tokens/template.js +36 -4
- package/dist/{types/src → src}/tokens/types.d.ts +5 -2
- package/dist/src/tokens/types.d.ts.map +1 -0
- package/dist/{types/src → src}/tokens/write/generate$metadata.d.ts +2 -1
- package/dist/src/tokens/write/generate$metadata.d.ts.map +1 -0
- package/dist/src/tokens/write/generate$metadata.js +3 -1
- package/dist/{types/src → src}/tokens/write/generate$themes.d.ts +2 -1
- package/dist/src/tokens/write/generate$themes.d.ts.map +1 -0
- package/dist/src/tokens/write/generate$themes.js +16 -2
- package/dist/{types/src → src}/tokens/write.d.ts +2 -1
- package/dist/src/tokens/write.d.ts.map +1 -0
- package/dist/src/tokens/write.js +93 -5
- package/package.json +9 -8
- package/dist/src/init/template/prettier.config.js +0 -5
- package/dist/src/tokens/build/utils/permutateThemes.js +0 -64
- package/dist/src/tokens/design-tokens/default/semantic/color.json +0 -572
- package/dist/src/tokens/design-tokens/template/themes/theme.json +0 -334
- package/dist/types/src/colors/index.d.ts.map +0 -1
- package/dist/types/src/colors/theme.d.ts.map +0 -1
- package/dist/types/src/colors/types.d.ts.map +0 -1
- package/dist/types/src/colors/utils.d.ts.map +0 -1
- package/dist/types/src/init/createTokensPackage.d.ts.map +0 -1
- package/dist/types/src/init/generateMetadataJson.d.ts.map +0 -1
- package/dist/types/src/init/generateThemesJson.d.ts.map +0 -1
- package/dist/types/src/init/index.d.ts.map +0 -1
- package/dist/types/src/init/nextStepsMarkdown.d.ts.map +0 -1
- package/dist/types/src/init/template/prettier.config.d.mts +0 -9
- package/dist/types/src/init/template/prettier.config.d.mts.map +0 -1
- package/dist/types/src/init/utils.d.ts.map +0 -1
- package/dist/types/src/migrations/beta-to-v1.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/css/plugins.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/css/run.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/jsx/classname-prefix.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/jsx/run.d.ts.map +0 -1
- package/dist/types/src/migrations/index.d.ts.map +0 -1
- package/dist/types/src/migrations/react-beta-to-v1.d.ts.map +0 -1
- package/dist/types/src/tokens/build/actions.d.ts.map +0 -1
- package/dist/types/src/tokens/build/configs.d.ts +0 -31
- package/dist/types/src/tokens/build/configs.d.ts.map +0 -1
- package/dist/types/src/tokens/build/formats/css.d.ts +0 -5
- package/dist/types/src/tokens/build/formats/css.d.ts.map +0 -1
- package/dist/types/src/tokens/build/formats/js-tokens.d.ts.map +0 -1
- package/dist/types/src/tokens/build/transformers.d.ts.map +0 -1
- package/dist/types/src/tokens/build/utils/entryfile.d.ts.map +0 -1
- package/dist/types/src/tokens/build/utils/noCase.d.ts.map +0 -1
- package/dist/types/src/tokens/build/utils/permutateThemes.d.ts +0 -17
- package/dist/types/src/tokens/build/utils/permutateThemes.d.ts.map +0 -1
- package/dist/types/src/tokens/build/utils/utils.d.ts.map +0 -1
- package/dist/types/src/tokens/build.d.ts +0 -13
- package/dist/types/src/tokens/build.d.ts.map +0 -1
- package/dist/types/src/tokens/create.d.ts.map +0 -1
- package/dist/types/src/tokens/template.d.ts.map +0 -1
- package/dist/types/src/tokens/types.d.ts.map +0 -1
- package/dist/types/src/tokens/write/generate$metadata.d.ts.map +0 -1
- package/dist/types/src/tokens/write/generate$themes.d.ts.map +0 -1
- package/dist/types/src/tokens/write.d.ts.map +0 -1
- /package/dist/{types/bin → bin}/designsystemet.d.ts +0 -0
- /package/dist/{types/src → src}/colors/index.d.ts +0 -0
- /package/dist/{types/src → src}/init/createTokensPackage.d.ts +0 -0
- /package/dist/{types/src → src}/init/generateMetadataJson.d.ts +0 -0
- /package/dist/{types/src → src}/init/generateThemesJson.d.ts +0 -0
- /package/dist/{types/src → src}/init/index.d.ts +0 -0
- /package/dist/{types/src → src}/init/nextStepsMarkdown.d.ts +0 -0
- /package/dist/{types/src → src}/init/utils.d.ts +0 -0
- /package/dist/{types/src → src}/migrations/beta-to-v1.d.ts +0 -0
- /package/dist/{types/src → src}/migrations/codemods/css/plugins.d.ts +0 -0
- /package/dist/{types/src → src}/migrations/codemods/css/run.d.ts +0 -0
- /package/dist/{types/src → src}/migrations/codemods/jsx/classname-prefix.d.ts +0 -0
- /package/dist/{types/src → src}/migrations/codemods/jsx/run.d.ts +0 -0
- /package/dist/{types/src → src}/migrations/index.d.ts +0 -0
- /package/dist/{types/src → src}/migrations/react-beta-to-v1.d.ts +0 -0
- /package/dist/{types/src → src}/tokens/build/actions.d.ts +0 -0
- /package/dist/{types/src → src}/tokens/build/formats/js-tokens.d.ts +0 -0
- /package/dist/{types/src → src}/tokens/build/utils/entryfile.d.ts +0 -0
- /package/dist/{types/src → src}/tokens/build/utils/noCase.d.ts +0 -0
- /package/dist/{types/src → src}/tokens/template.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/build/utils/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAM5E;;;;GAIG;AACH,eAAO,MAAM,OAAO,UAAW,gBAAgB,WAAkD,CAAC;AAElG;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,gBAAgB,GAAG,WAAW,KAAG,CAAuC,CAAC;AAE5G;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,yDAAmB,MAAM,EAAE,GAAG,MAAM,SAAS,gBAAgB,aAMlF,CAAC;AAEH,eAAO,MAAM,mBAAmB,yDAAmB,MAAM,EAAE,SAAS,gBAAgB,aASlF,CAAC;AAEH,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAEhE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAEnE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAKpG"}
|
|
@@ -17,9 +17,24 @@ const pathStartsWithOneOf = R.curry((paths, token) => {
|
|
|
17
17
|
const matchPathsStartingWith = R.map((path) => R.startsWith([path], tokenPath), mapToLowerCase(paths));
|
|
18
18
|
return hasAnyTruth(matchPathsStartingWith);
|
|
19
19
|
});
|
|
20
|
+
function isSemanticToken(token) {
|
|
21
|
+
return token.filePath.includes("semantic/");
|
|
22
|
+
}
|
|
23
|
+
function isGlobalColorToken(token) {
|
|
24
|
+
return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
|
|
25
|
+
}
|
|
26
|
+
function isColorCategoryToken(token, category) {
|
|
27
|
+
if (!category) {
|
|
28
|
+
return ["main", "support"].some((c) => isColorCategoryToken(token, c));
|
|
29
|
+
}
|
|
30
|
+
return R.startsWith(["color", category], token.path);
|
|
31
|
+
}
|
|
20
32
|
export {
|
|
21
33
|
getType,
|
|
22
34
|
getValue,
|
|
35
|
+
isColorCategoryToken,
|
|
36
|
+
isGlobalColorToken,
|
|
37
|
+
isSemanticToken,
|
|
23
38
|
pathStartsWithOneOf,
|
|
24
39
|
typeEquals
|
|
25
40
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const DEFAULT_COLOR = "accent";
|
|
2
|
+
type Options = {
|
|
3
|
+
/** Design tokens path */
|
|
4
|
+
tokens: string;
|
|
5
|
+
/** Output directory for built tokens */
|
|
6
|
+
out: string;
|
|
7
|
+
/** Generate preview tokens */
|
|
8
|
+
preview: boolean;
|
|
9
|
+
/** Enable verbose output */
|
|
10
|
+
verbose: boolean;
|
|
11
|
+
/** Set the default "accent" color, if not overridden with data-color */
|
|
12
|
+
accentColor?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare let buildOptions: Options | undefined;
|
|
15
|
+
export declare function buildTokens(options: Options): Promise<void>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/tokens/build.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,aAAa,WAAW,CAAC;AAEtC,KAAK,OAAO,GAAG;IACb,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,8BAA8B;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,4BAA4B;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,IAAI,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;AAwC7C,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAuEjE"}
|
package/dist/src/tokens/build.js
CHANGED
|
@@ -1,91 +1,88 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import * as R from "ramda";
|
|
5
5
|
import StyleDictionary from "style-dictionary";
|
|
6
|
-
import
|
|
6
|
+
import { configs, getConfigsForThemeDimensions } from "./build/configs.js";
|
|
7
7
|
import { makeEntryFile } from "./build/utils/entryfile.js";
|
|
8
|
-
|
|
8
|
+
import { processThemeObject } from "./build/utils/getMultidimensionalThemes.js";
|
|
9
|
+
const DEFAULT_COLOR = "accent";
|
|
10
|
+
let buildOptions;
|
|
9
11
|
const sd = new StyleDictionary();
|
|
12
|
+
const buildConfigs = {
|
|
13
|
+
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
14
|
+
"color-mode": { getConfig: configs.colorModeVariables, dimensions: ["mode"] },
|
|
15
|
+
"main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
|
|
16
|
+
"support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
|
|
17
|
+
semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] },
|
|
18
|
+
storefront: {
|
|
19
|
+
name: "Storefront preview tokens",
|
|
20
|
+
getConfig: configs.typescriptTokens,
|
|
21
|
+
dimensions: ["mode"],
|
|
22
|
+
options: { outPath: path.resolve("../../apps/storefront/tokens") },
|
|
23
|
+
enabled: () => buildOptions?.preview ?? false
|
|
24
|
+
},
|
|
25
|
+
entryFiles: {
|
|
26
|
+
name: "CSS entry files",
|
|
27
|
+
getConfig: configs.semanticVariables,
|
|
28
|
+
dimensions: ["semantic"],
|
|
29
|
+
build: async (sdConfigs, { outPath }) => {
|
|
30
|
+
await Promise.all(
|
|
31
|
+
sdConfigs.map(async ({ permutation: { theme } }) => {
|
|
32
|
+
console.log(`\u{1F477} ${theme}.css`);
|
|
33
|
+
const builtinColorsFilename = "builtin-colors.css";
|
|
34
|
+
const builtinColors = path.resolve(import.meta.dirname, "build", builtinColorsFilename);
|
|
35
|
+
await fs.copyFile(builtinColors, path.resolve(outPath, theme, builtinColorsFilename));
|
|
36
|
+
return makeEntryFile({ theme, outPath, buildPath: path.resolve(outPath, theme) });
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
10
42
|
async function buildTokens(options) {
|
|
11
|
-
|
|
43
|
+
buildOptions = options;
|
|
12
44
|
const tokensDir = options.tokens;
|
|
13
|
-
const storefrontOutDir = path.resolve("../../apps/storefront/tokens");
|
|
14
45
|
const outPath = path.resolve(options.out);
|
|
15
|
-
const $themes = JSON.parse(fs.
|
|
16
|
-
const relevant$themes = $themes.filter((theme) =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
const $themes = JSON.parse(await fs.readFile(path.resolve(`${tokensDir}/$themes.json`), "utf-8")).map(processThemeObject);
|
|
47
|
+
const relevant$themes = $themes.filter((theme) => R.not(theme.group === "size" && theme.name !== "default"));
|
|
48
|
+
if (!buildOptions.accentColor) {
|
|
49
|
+
const accentOrFirstMainColor = relevant$themes.find((theme) => theme.name === DEFAULT_COLOR) || relevant$themes.find((theme) => theme.group === "main-color");
|
|
50
|
+
buildOptions.accentColor = accentOrFirstMainColor?.name;
|
|
51
|
+
}
|
|
52
|
+
if (buildOptions.accentColor !== DEFAULT_COLOR) {
|
|
53
|
+
console.log("accent color:", buildOptions.accentColor);
|
|
54
|
+
}
|
|
55
|
+
const buildAndSdConfigs = R.map(
|
|
56
|
+
(val) => ({
|
|
57
|
+
buildConfig: val,
|
|
58
|
+
sdConfigs: getConfigsForThemeDimensions(val.getConfig, relevant$themes, val.dimensions, {
|
|
59
|
+
outPath,
|
|
60
|
+
tokensDir,
|
|
61
|
+
...val.options
|
|
62
|
+
})
|
|
63
|
+
}),
|
|
64
|
+
buildConfigs
|
|
34
65
|
);
|
|
35
66
|
try {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
})
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
if (semanticConfigs.length > 0) {
|
|
59
|
-
console.log(`
|
|
60
|
-
\u{1F371} Building ${chalk.green("semantic")}`);
|
|
61
|
-
await Promise.all(
|
|
62
|
-
semanticConfigs.map(async ({ theme, config, semantic }) => {
|
|
63
|
-
console.log(`\u{1F477} ${theme} - ${semantic}`);
|
|
64
|
-
const typographyClasses = await sd.extend(config);
|
|
65
|
-
return typographyClasses.buildAllPlatforms();
|
|
66
|
-
})
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
if (storefrontConfigs.length > 0 && options.preview) {
|
|
70
|
-
console.log(`
|
|
71
|
-
\u{1F371} Building ${chalk.green("Storefront preview tokens")}`);
|
|
72
|
-
await Promise.all(
|
|
73
|
-
storefrontConfigs.map(async ({ theme, mode, config }) => {
|
|
74
|
-
console.log(`\u{1F477} ${theme} - ${mode}`);
|
|
75
|
-
const storefrontSD = await sd.extend(config);
|
|
76
|
-
return storefrontSD.buildAllPlatforms();
|
|
77
|
-
})
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
if (semanticConfigs.length > 0) {
|
|
81
|
-
console.log(`
|
|
82
|
-
\u{1F371} Building ${chalk.green("CSS file")}`);
|
|
83
|
-
await Promise.all(
|
|
84
|
-
semanticConfigs.map(async ({ theme }) => {
|
|
85
|
-
console.log(`\u{1F477} ${theme}.css`);
|
|
86
|
-
return makeEntryFile({ theme, outPath, buildPath: path.resolve(`${outPath}/${theme}`) });
|
|
87
|
-
})
|
|
88
|
-
);
|
|
67
|
+
for (const [key, { buildConfig, sdConfigs }] of R.toPairs(buildAndSdConfigs)) {
|
|
68
|
+
if (!(buildConfig.enabled?.() ?? true)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (sdConfigs.length > 0) {
|
|
72
|
+
console.log(`
|
|
73
|
+
\u{1F371} Building ${chalk.green(buildConfig.name ?? key)}`);
|
|
74
|
+
if (buildConfig.build) {
|
|
75
|
+
return await buildConfig.build(sdConfigs, { outPath, tokensDir, ...buildConfig.options });
|
|
76
|
+
}
|
|
77
|
+
await Promise.all(
|
|
78
|
+
sdConfigs.map(async ({ config, permutation }) => {
|
|
79
|
+
const modes = ["theme", ...buildConfig.dimensions];
|
|
80
|
+
const modeMessage = modes.map((x) => permutation[x]).join(" - ");
|
|
81
|
+
console.log(modeMessage);
|
|
82
|
+
return (await sd.extend(config)).buildAllPlatforms();
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
}
|
|
89
86
|
}
|
|
90
87
|
} catch (err) {
|
|
91
88
|
if (err instanceof Error) {
|
|
@@ -95,5 +92,7 @@ async function buildTokens(options) {
|
|
|
95
92
|
}
|
|
96
93
|
}
|
|
97
94
|
export {
|
|
95
|
+
DEFAULT_COLOR,
|
|
96
|
+
buildOptions,
|
|
98
97
|
buildTokens
|
|
99
98
|
};
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { Colors, Tokens, Typography } from './types.js';
|
|
2
|
+
export declare const colorCliOptions: {
|
|
3
|
+
readonly main: "main-colors";
|
|
4
|
+
readonly support: "support-colors";
|
|
5
|
+
readonly neutral: "neutral-color";
|
|
6
|
+
};
|
|
2
7
|
export type CreateTokensOptions = {
|
|
3
8
|
colors: Colors;
|
|
4
9
|
typography: Typography;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/tokens/create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAyB,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpF,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAgFF,eAAO,MAAM,YAAY,SAAU,mBAAmB,WAqBrD,CAAC"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import * as R from "ramda";
|
|
1
2
|
import { baseColors, generateScaleForColor } from "../colors/index.js";
|
|
3
|
+
const colorCliOptions = {
|
|
4
|
+
main: "main-colors",
|
|
5
|
+
support: "support-colors",
|
|
6
|
+
neutral: "neutral-color"
|
|
7
|
+
};
|
|
2
8
|
const createColorTokens = (colorArray) => {
|
|
3
9
|
const obj = {};
|
|
4
10
|
const $type = "color";
|
|
@@ -42,18 +48,14 @@ const generateTypographyTokens = (themeName, { fontFamily }) => {
|
|
|
42
48
|
};
|
|
43
49
|
};
|
|
44
50
|
const generateThemeTokens = (themeName, theme, colors) => {
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const brand2Colors = generateScaleForColor(colors.brand2, theme);
|
|
49
|
-
const brand3Colors = generateScaleForColor(colors.brand3, theme);
|
|
51
|
+
const main = R.map((color) => createColorTokens(generateScaleForColor(color, theme)), colors.main);
|
|
52
|
+
const support = R.map((color) => createColorTokens(generateScaleForColor(color, theme)), colors.support);
|
|
53
|
+
const neutral = createColorTokens(generateScaleForColor(colors.neutral, theme));
|
|
50
54
|
return {
|
|
51
55
|
[themeName]: {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
brand2: createColorTokens(brand2Colors),
|
|
56
|
-
brand3: createColorTokens(brand3Colors)
|
|
56
|
+
...main,
|
|
57
|
+
...support,
|
|
58
|
+
neutral
|
|
57
59
|
}
|
|
58
60
|
};
|
|
59
61
|
};
|
|
@@ -96,5 +98,6 @@ const createTokens = (opts) => {
|
|
|
96
98
|
return tokens;
|
|
97
99
|
};
|
|
98
100
|
export {
|
|
101
|
+
colorCliOptions,
|
|
99
102
|
createTokens
|
|
100
103
|
};
|
|
@@ -134,12 +134,6 @@
|
|
|
134
134
|
]
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
|
-
"border-radius": {
|
|
138
|
-
"base": {
|
|
139
|
-
"$type": "borderRadius",
|
|
140
|
-
"$value": "4"
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
137
|
"opacity": {
|
|
144
138
|
"30": {
|
|
145
139
|
"$type": "opacity",
|
|
@@ -147,13 +141,13 @@
|
|
|
147
141
|
}
|
|
148
142
|
},
|
|
149
143
|
"sizing": {
|
|
150
|
-
"
|
|
144
|
+
"scale": {
|
|
151
145
|
"$type": "sizing",
|
|
152
146
|
"$value": "4"
|
|
153
147
|
}
|
|
154
148
|
},
|
|
155
149
|
"spacing": {
|
|
156
|
-
"
|
|
150
|
+
"scale": {
|
|
157
151
|
"$type": "spacing",
|
|
158
152
|
"$value": "4"
|
|
159
153
|
}
|