@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.
Files changed (149) hide show
  1. package/README.md +16 -0
  2. package/dist/{types/bin → bin}/designsystemet.d.ts.map +1 -1
  3. package/dist/bin/designsystemet.js +14 -15
  4. package/dist/src/colors/index.d.ts.map +1 -0
  5. package/dist/{types/src → src}/colors/theme.d.ts +8 -3
  6. package/dist/src/colors/theme.d.ts.map +1 -0
  7. package/dist/src/colors/theme.js +17 -18
  8. package/dist/{types/src → src}/colors/types.d.ts +0 -1
  9. package/dist/src/colors/types.d.ts.map +1 -0
  10. package/dist/{types/src → src}/colors/utils.d.ts +7 -1
  11. package/dist/src/colors/utils.d.ts.map +1 -0
  12. package/dist/src/colors/utils.js +13 -6
  13. package/dist/src/index.d.ts +3 -0
  14. package/dist/src/index.d.ts.map +1 -0
  15. package/dist/src/index.js +2 -0
  16. package/dist/src/init/createTokensPackage.d.ts.map +1 -0
  17. package/dist/src/init/generateMetadataJson.d.ts.map +1 -0
  18. package/dist/src/init/generateThemesJson.d.ts.map +1 -0
  19. package/dist/src/init/index.d.ts.map +1 -0
  20. package/dist/src/init/nextStepsMarkdown.d.ts.map +1 -0
  21. package/dist/src/init/utils.d.ts.map +1 -0
  22. package/dist/src/migrations/beta-to-v1.d.ts.map +1 -0
  23. package/dist/src/migrations/beta-to-v1.js +4 -4
  24. package/dist/src/migrations/codemods/css/plugins.d.ts.map +1 -0
  25. package/dist/src/migrations/codemods/css/run.d.ts.map +1 -0
  26. package/dist/src/migrations/codemods/jsx/classname-prefix.d.ts.map +1 -0
  27. package/dist/src/migrations/codemods/jsx/run.d.ts.map +1 -0
  28. package/dist/src/migrations/index.d.ts.map +1 -0
  29. package/dist/src/migrations/react-beta-to-v1.d.ts.map +1 -0
  30. package/dist/src/tokens/build/actions.d.ts.map +1 -0
  31. package/dist/src/tokens/build/builtin-colors.css +87 -0
  32. package/dist/src/tokens/build/configs.d.ts +21 -0
  33. package/dist/src/tokens/build/configs.d.ts.map +1 -0
  34. package/dist/src/tokens/build/configs.js +114 -61
  35. package/dist/src/tokens/build/formats/css.d.ts +13 -0
  36. package/dist/src/tokens/build/formats/css.d.ts.map +1 -0
  37. package/dist/src/tokens/build/formats/css.js +55 -3
  38. package/dist/src/tokens/build/formats/js-tokens.d.ts.map +1 -0
  39. package/dist/src/tokens/build/formats/js-tokens.js +2 -2
  40. package/dist/{types/src → src}/tokens/build/transformers.d.ts +1 -0
  41. package/dist/src/tokens/build/transformers.d.ts.map +1 -0
  42. package/dist/src/tokens/build/transformers.js +13 -0
  43. package/dist/src/tokens/build/types.d.ts +44 -0
  44. package/dist/src/tokens/build/types.d.ts.map +1 -0
  45. package/dist/src/tokens/build/types.js +7 -0
  46. package/dist/src/tokens/build/utils/entryfile.d.ts.map +1 -0
  47. package/dist/src/tokens/build/utils/entryfile.js +11 -3
  48. package/dist/src/tokens/build/utils/getMultidimensionalThemes.d.ts +35 -0
  49. package/dist/src/tokens/build/utils/getMultidimensionalThemes.d.ts.map +1 -0
  50. package/dist/src/tokens/build/utils/getMultidimensionalThemes.js +112 -0
  51. package/dist/src/tokens/build/utils/noCase.d.ts.map +1 -0
  52. package/dist/{types/src → src}/tokens/build/utils/utils.d.ts +3 -0
  53. package/dist/src/tokens/build/utils/utils.d.ts.map +1 -0
  54. package/dist/src/tokens/build/utils/utils.js +15 -0
  55. package/dist/src/tokens/build.d.ts +17 -0
  56. package/dist/src/tokens/build.d.ts.map +1 -0
  57. package/dist/src/tokens/build.js +76 -77
  58. package/dist/{types/src → src}/tokens/create.d.ts +5 -0
  59. package/dist/src/tokens/create.d.ts.map +1 -0
  60. package/dist/src/tokens/create.js +13 -10
  61. package/dist/src/tokens/design-tokens/default/primitives/globals.json +2 -8
  62. package/dist/src/tokens/design-tokens/default/semantic/style.json +86 -182
  63. package/dist/src/tokens/design-tokens/template/$metadata.json +4 -0
  64. package/dist/src/tokens/design-tokens/template/$themes.json +129 -13
  65. package/dist/src/tokens/design-tokens/template/semantic/color-base-file.json +262 -0
  66. package/dist/src/tokens/design-tokens/template/semantic/modes/category-color/category-color-template.json +62 -0
  67. package/dist/src/tokens/design-tokens/template/semantic/semantic-color-template.json +62 -0
  68. package/dist/src/tokens/design-tokens/template/themes/theme-base-file.json +53 -0
  69. package/dist/src/tokens/design-tokens/template/themes/theme-color-template.json +62 -0
  70. package/dist/src/tokens/index.d.ts +2 -0
  71. package/dist/src/tokens/index.d.ts.map +1 -0
  72. package/dist/src/tokens/index.js +5 -0
  73. package/dist/src/tokens/template.d.ts.map +1 -0
  74. package/dist/src/tokens/template.js +36 -4
  75. package/dist/{types/src → src}/tokens/types.d.ts +5 -2
  76. package/dist/src/tokens/types.d.ts.map +1 -0
  77. package/dist/{types/src → src}/tokens/write/generate$metadata.d.ts +2 -1
  78. package/dist/src/tokens/write/generate$metadata.d.ts.map +1 -0
  79. package/dist/src/tokens/write/generate$metadata.js +3 -1
  80. package/dist/{types/src → src}/tokens/write/generate$themes.d.ts +2 -1
  81. package/dist/src/tokens/write/generate$themes.d.ts.map +1 -0
  82. package/dist/src/tokens/write/generate$themes.js +16 -2
  83. package/dist/{types/src → src}/tokens/write.d.ts +2 -1
  84. package/dist/src/tokens/write.d.ts.map +1 -0
  85. package/dist/src/tokens/write.js +93 -5
  86. package/package.json +9 -8
  87. package/dist/src/init/template/prettier.config.js +0 -5
  88. package/dist/src/tokens/build/utils/permutateThemes.js +0 -64
  89. package/dist/src/tokens/design-tokens/default/semantic/color.json +0 -572
  90. package/dist/src/tokens/design-tokens/template/themes/theme.json +0 -334
  91. package/dist/types/src/colors/index.d.ts.map +0 -1
  92. package/dist/types/src/colors/theme.d.ts.map +0 -1
  93. package/dist/types/src/colors/types.d.ts.map +0 -1
  94. package/dist/types/src/colors/utils.d.ts.map +0 -1
  95. package/dist/types/src/init/createTokensPackage.d.ts.map +0 -1
  96. package/dist/types/src/init/generateMetadataJson.d.ts.map +0 -1
  97. package/dist/types/src/init/generateThemesJson.d.ts.map +0 -1
  98. package/dist/types/src/init/index.d.ts.map +0 -1
  99. package/dist/types/src/init/nextStepsMarkdown.d.ts.map +0 -1
  100. package/dist/types/src/init/template/prettier.config.d.mts +0 -9
  101. package/dist/types/src/init/template/prettier.config.d.mts.map +0 -1
  102. package/dist/types/src/init/utils.d.ts.map +0 -1
  103. package/dist/types/src/migrations/beta-to-v1.d.ts.map +0 -1
  104. package/dist/types/src/migrations/codemods/css/plugins.d.ts.map +0 -1
  105. package/dist/types/src/migrations/codemods/css/run.d.ts.map +0 -1
  106. package/dist/types/src/migrations/codemods/jsx/classname-prefix.d.ts.map +0 -1
  107. package/dist/types/src/migrations/codemods/jsx/run.d.ts.map +0 -1
  108. package/dist/types/src/migrations/index.d.ts.map +0 -1
  109. package/dist/types/src/migrations/react-beta-to-v1.d.ts.map +0 -1
  110. package/dist/types/src/tokens/build/actions.d.ts.map +0 -1
  111. package/dist/types/src/tokens/build/configs.d.ts +0 -31
  112. package/dist/types/src/tokens/build/configs.d.ts.map +0 -1
  113. package/dist/types/src/tokens/build/formats/css.d.ts +0 -5
  114. package/dist/types/src/tokens/build/formats/css.d.ts.map +0 -1
  115. package/dist/types/src/tokens/build/formats/js-tokens.d.ts.map +0 -1
  116. package/dist/types/src/tokens/build/transformers.d.ts.map +0 -1
  117. package/dist/types/src/tokens/build/utils/entryfile.d.ts.map +0 -1
  118. package/dist/types/src/tokens/build/utils/noCase.d.ts.map +0 -1
  119. package/dist/types/src/tokens/build/utils/permutateThemes.d.ts +0 -17
  120. package/dist/types/src/tokens/build/utils/permutateThemes.d.ts.map +0 -1
  121. package/dist/types/src/tokens/build/utils/utils.d.ts.map +0 -1
  122. package/dist/types/src/tokens/build.d.ts +0 -13
  123. package/dist/types/src/tokens/build.d.ts.map +0 -1
  124. package/dist/types/src/tokens/create.d.ts.map +0 -1
  125. package/dist/types/src/tokens/template.d.ts.map +0 -1
  126. package/dist/types/src/tokens/types.d.ts.map +0 -1
  127. package/dist/types/src/tokens/write/generate$metadata.d.ts.map +0 -1
  128. package/dist/types/src/tokens/write/generate$themes.d.ts.map +0 -1
  129. package/dist/types/src/tokens/write.d.ts.map +0 -1
  130. /package/dist/{types/bin → bin}/designsystemet.d.ts +0 -0
  131. /package/dist/{types/src → src}/colors/index.d.ts +0 -0
  132. /package/dist/{types/src → src}/init/createTokensPackage.d.ts +0 -0
  133. /package/dist/{types/src → src}/init/generateMetadataJson.d.ts +0 -0
  134. /package/dist/{types/src → src}/init/generateThemesJson.d.ts +0 -0
  135. /package/dist/{types/src → src}/init/index.d.ts +0 -0
  136. /package/dist/{types/src → src}/init/nextStepsMarkdown.d.ts +0 -0
  137. /package/dist/{types/src → src}/init/utils.d.ts +0 -0
  138. /package/dist/{types/src → src}/migrations/beta-to-v1.d.ts +0 -0
  139. /package/dist/{types/src → src}/migrations/codemods/css/plugins.d.ts +0 -0
  140. /package/dist/{types/src → src}/migrations/codemods/css/run.d.ts +0 -0
  141. /package/dist/{types/src → src}/migrations/codemods/jsx/classname-prefix.d.ts +0 -0
  142. /package/dist/{types/src → src}/migrations/codemods/jsx/run.d.ts +0 -0
  143. /package/dist/{types/src → src}/migrations/index.d.ts +0 -0
  144. /package/dist/{types/src → src}/migrations/react-beta-to-v1.d.ts +0 -0
  145. /package/dist/{types/src → src}/tokens/build/actions.d.ts +0 -0
  146. /package/dist/{types/src → src}/tokens/build/formats/js-tokens.d.ts +0 -0
  147. /package/dist/{types/src → src}/tokens/build/utils/entryfile.d.ts +0 -0
  148. /package/dist/{types/src → src}/tokens/build/utils/noCase.d.ts +0 -0
  149. /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"}
@@ -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 * as configs from "./build/configs.js";
6
+ import { configs, getConfigsForThemeDimensions } from "./build/configs.js";
7
7
  import { makeEntryFile } from "./build/utils/entryfile.js";
8
- const { permutateThemes, getConfigs } = configs;
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
- const verbosity = options.verbose ? "verbose" : "silent";
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.readFileSync(path.resolve(`${tokensDir}/$themes.json`), "utf-8"));
16
- const relevant$themes = $themes.filter((theme) => {
17
- const group = R.toLower(R.defaultTo("")(theme.group));
18
- if (group === "size" && theme.name.toLowerCase() !== "default") return false;
19
- return true;
20
- });
21
- const themes = permutateThemes(relevant$themes);
22
- const typographyThemes = R.filter((val) => val.mode === "light", themes);
23
- const colormodeThemes = R.filter((val) => val.typography === "primary", themes);
24
- const semanticThemes = R.filter((val) => val.mode === "light" && val.typography === "primary", themes);
25
- const colorModeConfigs = getConfigs(configs.colorModeVariables, outPath, tokensDir, colormodeThemes, verbosity);
26
- const semanticConfigs = getConfigs(configs.semanticVariables, outPath, tokensDir, semanticThemes, verbosity);
27
- const typographyConfigs = getConfigs(configs.typographyVariables, outPath, tokensDir, typographyThemes, verbosity);
28
- const storefrontConfigs = getConfigs(
29
- configs.typescriptTokens,
30
- storefrontOutDir,
31
- tokensDir,
32
- colormodeThemes,
33
- verbosity
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
- if (typographyConfigs.length > 0) {
37
- console.log(`
38
- \u{1F371} Building ${chalk.green("typography")}`);
39
- await Promise.all(
40
- typographyConfigs.map(async ({ theme, typography, config }) => {
41
- console.log(`\u{1F477} ${theme} - ${typography}`);
42
- const typographyClasses = await sd.extend(config);
43
- return typographyClasses.buildAllPlatforms();
44
- })
45
- );
46
- }
47
- if (colorModeConfigs.length > 0) {
48
- console.log(`
49
- \u{1F371} Building ${chalk.green("color-mode")}`);
50
- await Promise.all(
51
- colorModeConfigs.map(async ({ theme, mode, config }) => {
52
- console.log(`\u{1F477} ${theme} - ${mode}`);
53
- const themeVariablesSD = await sd.extend(config);
54
- return themeVariablesSD.buildAllPlatforms();
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 accentColors = generateScaleForColor(colors.accent, theme);
46
- const neutralColors = generateScaleForColor(colors.neutral, theme);
47
- const brand1Colors = generateScaleForColor(colors.brand1, theme);
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
- accent: createColorTokens(accentColors),
53
- neutral: createColorTokens(neutralColors),
54
- brand1: createColorTokens(brand1Colors),
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
- "base": {
144
+ "scale": {
151
145
  "$type": "sizing",
152
146
  "$value": "4"
153
147
  }
154
148
  },
155
149
  "spacing": {
156
- "base": {
150
+ "scale": {
157
151
  "$type": "spacing",
158
152
  "$value": "4"
159
153
  }