@digdir/designsystemet 1.0.8 → 1.1.0

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 (55) hide show
  1. package/dist/bin/config.js +20 -19
  2. package/dist/bin/designsystemet.js +421 -359
  3. package/dist/src/colors/index.d.ts +2 -2
  4. package/dist/src/colors/index.d.ts.map +1 -1
  5. package/dist/src/colors/index.js +143 -143
  6. package/dist/src/colors/theme.d.ts +1 -2
  7. package/dist/src/colors/theme.d.ts.map +1 -1
  8. package/dist/src/config.d.ts.map +1 -1
  9. package/dist/src/config.js +20 -19
  10. package/dist/src/index.js +394 -394
  11. package/dist/src/scripts/createJsonSchema.js +19 -19
  12. package/dist/src/scripts/update-template.d.ts.map +1 -1
  13. package/dist/src/tokens/build.d.ts.map +1 -1
  14. package/dist/src/tokens/build.js +89 -28
  15. package/dist/src/tokens/create/generators/$designsystemet.js +12 -13
  16. package/dist/src/tokens/create/generators/color.js +21 -21
  17. package/dist/src/tokens/create/write.js +13 -14
  18. package/dist/src/tokens/create.d.ts +1 -0
  19. package/dist/src/tokens/create.d.ts.map +1 -1
  20. package/dist/src/tokens/create.js +22 -21
  21. package/dist/src/tokens/format.d.ts.map +1 -1
  22. package/dist/src/tokens/format.js +883 -884
  23. package/dist/src/tokens/index.d.ts +2 -2
  24. package/dist/src/tokens/index.d.ts.map +1 -1
  25. package/dist/src/tokens/index.js +271 -271
  26. package/dist/src/tokens/process/configs/color.d.ts.map +1 -1
  27. package/dist/src/tokens/process/configs/color.js +5 -5
  28. package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -1
  29. package/dist/src/tokens/process/configs/semantic.js +5 -5
  30. package/dist/src/tokens/process/configs/storefront.d.ts.map +1 -1
  31. package/dist/src/tokens/process/configs/storefront.js +1 -1
  32. package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
  33. package/dist/src/tokens/process/configs/typography.js +5 -5
  34. package/dist/src/tokens/process/configs.d.ts.map +1 -1
  35. package/dist/src/tokens/process/configs.js +5 -5
  36. package/dist/src/tokens/process/formats/css/color.js +2 -2
  37. package/dist/src/tokens/process/formats/css/semantic.js +2 -2
  38. package/dist/src/tokens/process/formats/css/typography.js +1 -1
  39. package/dist/src/tokens/process/formats/css.js +5 -5
  40. package/dist/src/tokens/process/formats/js-tokens.js +1 -1
  41. package/dist/src/tokens/process/output/tailwind.d.ts +3 -0
  42. package/dist/src/tokens/process/output/tailwind.d.ts.map +1 -0
  43. package/dist/src/tokens/process/output/tailwind.js +59 -0
  44. package/dist/src/tokens/process/{theme.d.ts → output/theme.d.ts} +2 -2
  45. package/dist/src/tokens/process/output/theme.d.ts.map +1 -0
  46. package/dist/src/tokens/process/{theme.js → output/theme.js} +15 -16
  47. package/dist/src/tokens/process/platform.d.ts +3 -1
  48. package/dist/src/tokens/process/platform.d.ts.map +1 -1
  49. package/dist/src/tokens/process/platform.js +5 -5
  50. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +5 -5
  51. package/dist/src/tokens/types.d.ts +1 -1
  52. package/dist/src/tokens/types.d.ts.map +1 -1
  53. package/dist/src/tokens/utils.d.ts.map +1 -1
  54. package/package.json +12 -13
  55. package/dist/src/tokens/process/theme.d.ts.map +0 -1
@@ -5,36 +5,6 @@ import { Argument, createCommand, program } from "@commander-js/extra-typings";
5
5
  import chalk10 from "chalk";
6
6
  import * as R26 from "ramda";
7
7
 
8
- // src/colors/utils.ts
9
- import chroma from "chroma-js";
10
- import Colorjs from "colorjs.io";
11
- import { Hsluv } from "hsluv";
12
- var getLuminanceFromLightness = (lightness) => {
13
- const conv = new Hsluv();
14
- conv.hsluv_l = lightness;
15
- conv.hsluvToHex();
16
- return chroma(conv.hex).luminance();
17
- };
18
- var getLightnessFromHex = (hex) => {
19
- const conv = new Hsluv();
20
- conv.hex = hex;
21
- conv.hexToHsluv();
22
- return conv.hsluv_l;
23
- };
24
- var convertToHex = (color) => {
25
- if (!color) {
26
- return "#000000";
27
- }
28
- if (/^#[0-9A-Fa-f]{6}$/.test(color)) {
29
- return color;
30
- }
31
- return chroma(color).hex();
32
- };
33
-
34
- // src/colors/theme.ts
35
- import chroma2 from "chroma-js";
36
- import * as R2 from "ramda";
37
-
38
8
  // src/colors/colorMetadata.ts
39
9
  import * as R from "ramda";
40
10
  var baseColors = {
@@ -288,6 +258,36 @@ var colorMetadata = {
288
258
  };
289
259
  var colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
290
260
 
261
+ // src/colors/theme.ts
262
+ import chroma2 from "chroma-js";
263
+ import * as R2 from "ramda";
264
+
265
+ // src/colors/utils.ts
266
+ import chroma from "chroma-js";
267
+ import Colorjs from "colorjs.io";
268
+ import { Hsluv } from "hsluv";
269
+ var getLuminanceFromLightness = (lightness) => {
270
+ const conv = new Hsluv();
271
+ conv.hsluv_l = lightness;
272
+ conv.hsluvToHex();
273
+ return chroma(conv.hex).luminance();
274
+ };
275
+ var getLightnessFromHex = (hex) => {
276
+ const conv = new Hsluv();
277
+ conv.hex = hex;
278
+ conv.hexToHsluv();
279
+ return conv.hsluv_l;
280
+ };
281
+ var convertToHex = (color) => {
282
+ if (!color) {
283
+ return "#000000";
284
+ }
285
+ if (/^#[0-9A-Fa-f]{6}$/.test(color)) {
286
+ return color;
287
+ }
288
+ return chroma(color).hex();
289
+ };
290
+
291
291
  // src/colors/theme.ts
292
292
  var RESERVED_COLORS = [
293
293
  "neutral",
@@ -864,14 +864,71 @@ import path from "path";
864
864
  import chalk6 from "chalk";
865
865
  import * as R18 from "ramda";
866
866
 
867
- // src/tokens/process/theme.ts
868
- import * as R5 from "ramda";
867
+ // src/tokens/process/output/tailwind.ts
868
+ var createTailwindCSSFiles = (cssFiles) => {
869
+ console.log("\n\u{1F371} Creating Tailwind Config");
870
+ return cssFiles.map((file) => {
871
+ if (file.destination) {
872
+ const tailwindConfig = generateTailwind(file.output);
873
+ const tailwindFile = {
874
+ destination: file.destination.replace(".css", ".tailwind.css"),
875
+ output: tailwindConfig
876
+ };
877
+ return tailwindFile;
878
+ }
879
+ return void 0;
880
+ }).filter((item) => item !== void 0);
881
+ };
882
+ var generateTailwind = (css) => {
883
+ const tailwind = ["--font-sans: var(--ds-font-family)"];
884
+ const tokens = Array.from(new Set(css.match(/--ds-[^:)]+/g)), (m) => m).sort(
885
+ (a, b) => a.localeCompare(b, void 0, { numeric: true, sensitivity: "base" })
886
+ );
887
+ for (const token of tokens) {
888
+ if (token.startsWith("--ds-color-") && !token.startsWith("--ds-color-focus")) {
889
+ tailwind.push(`--color-${token.replace("--ds-color-", "")}: var(${token})`);
890
+ } else if (token.startsWith("--ds-font-weight-")) {
891
+ tailwind.push(`--font-weight-${token.replace("--ds-font-weight-", "")}: var(${token})`);
892
+ } else if (token.match(/--ds-border-radius-(sm|md|lg|xl)/)) {
893
+ tailwind.push(`--radius-${token.replace("--ds-border-radius-", "")}: var(${token})`);
894
+ } else if (token.match(/--ds-body-(sm|mg|lg)-body-font-size/)) {
895
+ tailwind.push(`--text-${token.replace("--ds-body-", "").replace("-font-size", "")}: var(${token})`);
896
+ } else if (token.match(/^--ds-size-\d+$/)) {
897
+ tailwind.push(`--spacing-${token.replace("--ds-size-", "")}: var(${token})`);
898
+ }
899
+ }
900
+ const dynamicColors = `[data-color] {
901
+ --color-background-default: var(--ds-color-background-default);
902
+ --color-background-tinted: var(--ds-color-background-tinted);
903
+ --color-surface-default: var(--ds-color-surface-default);
904
+ --color-surface-tinted: var(--ds-color-surface-tinted);
905
+ --color-surface-hover: var(--ds-color-surface-hover);
906
+ --color-surface-active: var(--ds-color-surface-active);
907
+ --color-border-subtle: var(--ds-color-border-subtle);
908
+ --color-border-default: var(--ds-color-border-default);
909
+ --color-border-strong: var(--ds-color-border-strong);
910
+ --color-text-subtle: var(--ds-color-text-subtle);
911
+ --color-text-default: var(--ds-color-text-default);
912
+ --color-base-default: var(--ds-color-base-default);
913
+ --color-base-hover: var(--ds-color-base-hover);
914
+ --color-base-active: var(--ds-color-base-active);
915
+ --color-base-contrast-subtle: var(--ds-color-base-contrast-subtle);
916
+ --color-base-contrast-default: var(--ds-color-base-contrast-default);
917
+ }`;
918
+ return `@theme {${tailwind.map((str) => `
919
+ ${str};`).join("")}
920
+ }
921
+ ${dynamicColors}`;
922
+ };
923
+
924
+ // src/tokens/process/output/theme.ts
869
925
  import chalk3 from "chalk";
926
+ import * as R5 from "ramda";
870
927
 
871
928
  // package.json
872
929
  var package_default = {
873
930
  name: "@digdir/designsystemet",
874
- version: "1.0.8",
931
+ version: "1.1.0",
875
932
  description: "CLI for Designsystemet",
876
933
  author: "Designsystemet team",
877
934
  engines: {
@@ -881,7 +938,7 @@ var package_default = {
881
938
  type: "git",
882
939
  url: "git+https://github.com/digdir/designsystemet.git"
883
940
  },
884
- homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
941
+ homepage: "https://github.com/digdir/designsystemet/tree/main/packages/cli",
885
942
  license: "MIT",
886
943
  type: "module",
887
944
  main: "./dist/src/index.js",
@@ -906,8 +963,6 @@ var package_default = {
906
963
  },
907
964
  scripts: {
908
965
  designsystemet: "tsx ./bin/designsystemet.ts",
909
- "build:tokens": "pnpm run designsystemet tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
910
- "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
911
966
  build: "tsup && pnpm build:types && pnpm build:json-schema",
912
967
  "build:types": "tsc --emitDeclarationOnly --declaration",
913
968
  "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
@@ -915,17 +970,20 @@ var package_default = {
915
970
  "test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
916
971
  "test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
917
972
  "test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
973
+ "test:tokens-build-tailwind": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean --experimental-tailwind",
918
974
  "test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
975
+ "test:tokens-build-config-tailwind": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean --experimental-tailwind",
919
976
  "test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
920
977
  "test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
921
978
  test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
979
+ "digdir:tokens-build": "pnpm run designsystemet tokens build -t ../../internal/design-tokens -o ../../packages/theme/brand --clean --experimental-tailwind",
922
980
  "digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
923
981
  "update:template": "tsx ./src/scripts/update-template.ts",
924
- "update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
982
+ "update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts && pnpm digdir:tokens-build",
925
983
  verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
926
984
  },
927
985
  dependencies: {
928
- "@commander-js/extra-typings": "^13.1.0",
986
+ "@commander-js/extra-typings": "^14.0.0",
929
987
  "@tokens-studio/sd-transforms": "1.3.0",
930
988
  "apca-w3": "^0.1.9",
931
989
  chalk: "^5.4.1",
@@ -936,11 +994,11 @@ var package_default = {
936
994
  "fast-glob": "^3.3.3",
937
995
  hsluv: "^1.0.1",
938
996
  "object-hash": "^3.0.0",
939
- postcss: "^8.5.3",
997
+ postcss: "^8.5.5",
940
998
  ramda: "^0.30.1",
941
999
  "style-dictionary": "^4.4.0",
942
- zod: "^3.25.30",
943
- "zod-validation-error": "^3.4.1"
1000
+ zod: "^3.25.64",
1001
+ "zod-validation-error": "^3.5.0"
944
1002
  },
945
1003
  devDependencies: {
946
1004
  "@tokens-studio/types": "0.5.2",
@@ -948,20 +1006,18 @@ var package_default = {
948
1006
  "@types/chroma-js": "^3.1.1",
949
1007
  "@types/fs-extra": "^11.0.4",
950
1008
  "@types/glob": "^8.1.0",
951
- "@types/jscodeshift": "^0.12.0",
952
- "@types/node": "^22.15.21",
1009
+ "@types/node": "^22.15.31",
953
1010
  "@types/object-hash": "^3.0.6",
954
1011
  "@types/ramda": "^0.30.2",
955
1012
  "fs-extra": "^11.3.0",
956
- "ts-toolbelt": "^9.6.0",
957
1013
  tslib: "^2.8.1",
958
1014
  tsup: "^8.5.0",
959
- tsx: "^4.19.4",
1015
+ tsx: "^4.20.3",
960
1016
  typescript: "^5.8.3"
961
1017
  }
962
1018
  };
963
1019
 
964
- // src/tokens/process/theme.ts
1020
+ // src/tokens/process/output/theme.ts
965
1021
  var defaultFileHeader = `build: v${package_default.version}`;
966
1022
  var createThemeCSSFiles = ({
967
1023
  processedBuilds,
@@ -1130,7 +1186,7 @@ var prefersColorScheme = (colorScheme2, content) => `
1130
1186
  `;
1131
1187
  var colorScheme = {
1132
1188
  name: "ds/css-colorscheme",
1133
- format: async ({ dictionary, file, options, platform }) => {
1189
+ format: async ({ dictionary, options, platform }) => {
1134
1190
  const { allTokens } = dictionary;
1135
1191
  const { outputReferences, usesDtcg } = options;
1136
1192
  const { selector, colorScheme: colorScheme2, layer } = platform;
@@ -1172,7 +1228,7 @@ ${selector} ${content} ${autoSelectorContent}
1172
1228
  };
1173
1229
  var colorCategory = {
1174
1230
  name: "ds/css-colorcategory",
1175
- format: async ({ dictionary, file, options, platform }) => {
1231
+ format: async ({ dictionary, options, platform }) => {
1176
1232
  const { outputReferences, usesDtcg } = options;
1177
1233
  const { selector, layer } = platform;
1178
1234
  const format = R7.compose(
@@ -1215,7 +1271,7 @@ var isInlineTokens = R8.anyPass([isNumericBorderRadiusToken, isNumericSizeToken,
1215
1271
  var overrideSizingFormula = (format, token) => {
1216
1272
  const [name, value] = format(token).split(":");
1217
1273
  const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
1218
- const round = `round(down, ${calc}, 0.0625rem)`;
1274
+ const round = `round(down, ${calc}, 1px)`;
1219
1275
  return {
1220
1276
  name,
1221
1277
  round,
@@ -1243,7 +1299,7 @@ ${round.join("\n")}
1243
1299
  };
1244
1300
  var semantic = {
1245
1301
  name: "ds/css-semantic",
1246
- format: async ({ dictionary, file, options, platform }) => {
1302
+ format: async ({ dictionary, options, platform }) => {
1247
1303
  const { outputReferences, usesDtcg } = options;
1248
1304
  const { selector, layer } = platform;
1249
1305
  const format = createPropertyFormatter2({
@@ -1281,7 +1337,7 @@ var typographyFontFamilyPredicate = R9.allPass([
1281
1337
  ]);
1282
1338
  var typography = {
1283
1339
  name: "ds/css-typography",
1284
- format: async ({ dictionary, file, options, platform }) => {
1340
+ format: async ({ dictionary, options, platform }) => {
1285
1341
  const { outputReferences, usesDtcg } = options;
1286
1342
  const { selector, layer } = platform;
1287
1343
  const format = createPropertyFormatter3({
@@ -2170,7 +2226,7 @@ var buildTokens = async (options) => {
2170
2226
  try {
2171
2227
  const $designsystemetContent = await readFile(`${tokensDir}/$designsystemet.json`);
2172
2228
  $designsystemet = JSON.parse($designsystemetContent);
2173
- } catch (error) {
2229
+ } catch (_error) {
2174
2230
  }
2175
2231
  console.log(`
2176
2232
  \u{1F3D7}\uFE0F Start building tokens in ${chalk6.green(tokensDir)}`);
@@ -2181,57 +2237,319 @@ var buildTokens = async (options) => {
2181
2237
  type: "build",
2182
2238
  $themes
2183
2239
  });
2184
- console.log(`
2185
- \u{1F4BE} Writing build to ${chalk6.green(outDir)}`);
2186
- for (const { formatted } of processedBuilds.types) {
2187
- await write(formatted, outDir, options.dry);
2188
- }
2189
2240
  const fileHeader2 = R18.join("")([
2190
2241
  defaultFileHeader,
2191
2242
  $designsystemet ? `
2192
2243
  design-tokens: v${$designsystemet.version}` : ""
2193
2244
  ]);
2194
- await write(createThemeCSSFiles({ processedBuilds, fileHeader: fileHeader2 }), outDir, options.dry);
2245
+ let cssFiles = createThemeCSSFiles({ processedBuilds, fileHeader: fileHeader2 });
2246
+ if (options.tailwind) {
2247
+ const tailwindFiles = createTailwindCSSFiles(cssFiles);
2248
+ cssFiles = cssFiles.concat(tailwindFiles.filter(Boolean));
2249
+ }
2250
+ console.log(`
2251
+ \u{1F4BE} Writing build to ${chalk6.green(outDir)}`);
2252
+ for (const { formatted } of processedBuilds.types) {
2253
+ await write(formatted, outDir, options.dry);
2254
+ }
2255
+ await write(cssFiles, outDir, options.dry);
2195
2256
  console.log(`
2196
2257
  \u2705 Finished building tokens!`);
2197
2258
  return processedBuilds;
2198
2259
  };
2199
2260
 
2200
- // src/tokens/create/defaults.ts
2261
+ // src/tokens/create/write.ts
2262
+ import path2 from "path";
2263
+ import chalk7 from "chalk";
2201
2264
  import * as R19 from "ramda";
2202
2265
 
2203
- // src/tokens/template/design-tokens/primitives/globals.json with { type: 'json' }
2204
- var globals_default = {
2205
- "border-width": {
2206
- "1": {
2207
- $type: "borderWidth",
2208
- $value: "1px"
2266
+ // src/tokens/create/generators/$designsystemet.ts
2267
+ function generate$Designsystemet() {
2268
+ return {
2269
+ name: package_default.name,
2270
+ version: package_default.version
2271
+ };
2272
+ }
2273
+
2274
+ // src/tokens/create/generators/$metadata.ts
2275
+ function generate$Metadata(schemes, themes, colors2) {
2276
+ return {
2277
+ tokenSetOrder: [
2278
+ "primitives/globals",
2279
+ "primitives/modes/size/small",
2280
+ "primitives/modes/size/medium",
2281
+ "primitives/modes/size/large",
2282
+ "primitives/modes/size/global",
2283
+ "primitives/modes/typography/size/small",
2284
+ "primitives/modes/typography/size/medium",
2285
+ "primitives/modes/typography/size/large",
2286
+ ...themes.map((theme) => `primitives/modes/typography/primary/${theme}`),
2287
+ ...themes.map((theme) => `primitives/modes/typography/secondary/${theme}`),
2288
+ ...schemes.flatMap((scheme) => [
2289
+ `primitives/modes/color-scheme/${scheme}/global`,
2290
+ ...themes.map((theme) => `primitives/modes/color-scheme/${scheme}/${theme}`)
2291
+ ]),
2292
+ ...themes.map((theme) => `themes/${theme}`),
2293
+ "semantic/color",
2294
+ ...Object.entries(colors2.main).map(([color]) => `semantic/modes/main-color/${color}`),
2295
+ ...Object.entries(colors2.support).map(([color]) => `semantic/modes/support-color/${color}`),
2296
+ "semantic/style"
2297
+ ]
2298
+ };
2299
+ }
2300
+
2301
+ // src/tokens/create/generators/$themes.ts
2302
+ var capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
2303
+ async function createHash(text, algo = "SHA-1") {
2304
+ const crypto = globalThis.crypto;
2305
+ return Array.from(
2306
+ new Uint8Array(await crypto.subtle.digest(algo, new TextEncoder().encode(text))),
2307
+ (byte) => byte.toString(16).padStart(2, "0")
2308
+ ).join("");
2309
+ }
2310
+ async function generate$Themes(colorSchemes, themes, colors2) {
2311
+ return [
2312
+ ...generateSizeGroup(),
2313
+ ...await generateThemesGroup(themes),
2314
+ ...generateTypographyGroup(themes),
2315
+ ...generateColorSchemesGroup(colorSchemes, themes),
2316
+ generateSemanticGroup(),
2317
+ ...await generateColorGroup("main", colors2),
2318
+ ...await generateColorGroup("support", colors2)
2319
+ ];
2320
+ }
2321
+ function generateSizeGroup() {
2322
+ return [
2323
+ {
2324
+ id: "8b2c8cc86611a34b135cb22948666779361fd729",
2325
+ name: "medium",
2326
+ $figmaStyleReferences: {},
2327
+ selectedTokenSets: {
2328
+ "primitives/modes/size/medium": TokenSetStatus.SOURCE,
2329
+ "primitives/modes/size/global": TokenSetStatus.ENABLED,
2330
+ "primitives/modes/typography/size/medium": TokenSetStatus.ENABLED
2331
+ },
2332
+ $figmaCollectionId: "VariableCollectionId:36248:20757",
2333
+ $figmaModeId: "41630:1",
2334
+ group: "Size"
2209
2335
  },
2210
- "3": {
2211
- $type: "borderWidth",
2212
- $value: "3px"
2336
+ {
2337
+ id: "d49b9eebeb48a4f165a74b7261733d0a73370f0e",
2338
+ name: "large",
2339
+ $figmaStyleReferences: {},
2340
+ selectedTokenSets: {
2341
+ "primitives/modes/size/large": TokenSetStatus.SOURCE,
2342
+ "primitives/modes/size/global": TokenSetStatus.ENABLED,
2343
+ "primitives/modes/typography/size/large": TokenSetStatus.ENABLED
2344
+ },
2345
+ $figmaCollectionId: "VariableCollectionId:36248:20757",
2346
+ $figmaModeId: "41630:2",
2347
+ group: "Size"
2348
+ },
2349
+ {
2350
+ id: "fb11567729c298ca37c9da4e3a27716a23480824",
2351
+ name: "small",
2352
+ $figmaStyleReferences: {},
2353
+ selectedTokenSets: {
2354
+ "primitives/modes/size/small": TokenSetStatus.SOURCE,
2355
+ "primitives/modes/size/global": TokenSetStatus.ENABLED,
2356
+ "primitives/modes/typography/size/small": TokenSetStatus.ENABLED
2357
+ },
2358
+ $figmaCollectionId: "VariableCollectionId:36248:20757",
2359
+ $figmaModeId: "41630:3",
2360
+ group: "Size"
2213
2361
  }
2362
+ ];
2363
+ }
2364
+ var colorSchemeDefaults = {
2365
+ light: {
2366
+ name: "Light",
2367
+ selectedTokenSets: {},
2368
+ id: "0daa3ca0b427b9349da7e7dc00101b5668972926",
2369
+ $figmaCollectionId: "VariableCollectionId:34811:5472",
2370
+ $figmaModeId: "34811:0"
2214
2371
  },
2215
- shadow: {
2216
- "100": {
2217
- $type: "boxShadow",
2218
- $value: [
2219
- {
2220
- color: "rgba(0,0,0,0.16)",
2221
- x: "0",
2222
- y: "0",
2223
- blur: "1",
2224
- spread: "0"
2372
+ dark: {
2373
+ name: "Dark",
2374
+ selectedTokenSets: {},
2375
+ id: "9ebd8aed52afbffc17e2666e8b4653a53498b257",
2376
+ $figmaCollectionId: "VariableCollectionId:34811:5472",
2377
+ $figmaModeId: "34811:1"
2378
+ },
2379
+ contrast: {
2380
+ name: "Contrast",
2381
+ selectedTokenSets: {},
2382
+ id: "9ebd8aed52afbffc17e2666e8b4653a53498b123",
2383
+ $figmaCollectionId: "VariableCollectionId:34811:5472",
2384
+ $figmaModeId: "34811:2"
2385
+ }
2386
+ };
2387
+ function generateColorSchemesGroup(colorSchemes, themes) {
2388
+ return colorSchemes.map(
2389
+ (scheme) => ({
2390
+ ...colorSchemeDefaults[scheme],
2391
+ selectedTokenSets: Object.fromEntries([
2392
+ [`primitives/modes/color-scheme/${scheme}/global`, TokenSetStatus.ENABLED],
2393
+ ...themes.map((theme) => [`primitives/modes/color-scheme/${scheme}/${theme}`, TokenSetStatus.ENABLED])
2394
+ ]),
2395
+ group: "Color scheme"
2396
+ })
2397
+ );
2398
+ }
2399
+ async function generateThemesGroup(themes) {
2400
+ return Promise.all(
2401
+ themes.map(
2402
+ async (theme, index) => ({
2403
+ id: await createHash(theme),
2404
+ $figmaCollectionId: "VariableCollectionId:36528:61712",
2405
+ $figmaModeId: `40960:${index + 6}`,
2406
+ // Start on 6 in Token Studio and Community file for some reason
2407
+ name: theme,
2408
+ selectedTokenSets: {
2409
+ [`themes/${theme}`]: TokenSetStatus.ENABLED
2225
2410
  },
2226
- {
2227
- x: "0",
2228
- y: "1",
2229
- blur: "2",
2230
- spread: "0",
2231
- color: "rgba(0,0,0,0.12)"
2232
- }
2233
- ]
2234
- },
2411
+ group: "Theme"
2412
+ })
2413
+ )
2414
+ );
2415
+ }
2416
+ function generateSemanticGroup() {
2417
+ return {
2418
+ id: "541629445ef90ad5363f9e88f52a1ccb617e6f84",
2419
+ name: "Semantic",
2420
+ selectedTokenSets: {
2421
+ "semantic/style": TokenSetStatus.ENABLED,
2422
+ "semantic/color": TokenSetStatus.ENABLED,
2423
+ "primitives/globals": TokenSetStatus.SOURCE
2424
+ },
2425
+ $figmaCollectionId: "VariableCollectionId:34811:5976",
2426
+ $figmaModeId: "34811:5",
2427
+ group: "Semantic"
2428
+ };
2429
+ }
2430
+ async function generateColorGroup(group, colors2) {
2431
+ return Promise.all(
2432
+ Object.entries(colors2[group]).map(
2433
+ async ([color]) => ({
2434
+ id: await createHash(`${group}-${color}`),
2435
+ name: color,
2436
+ selectedTokenSets: {
2437
+ [`semantic/modes/${group}-color/${color}`]: TokenSetStatus.ENABLED
2438
+ },
2439
+ group: `${capitalize(group)} color`
2440
+ })
2441
+ )
2442
+ );
2443
+ }
2444
+ function generateTypographyGroup(themes) {
2445
+ return [
2446
+ {
2447
+ id: "368d753fcac4455f289500eaa42e70dc0a03522f",
2448
+ $figmaCollectionId: "VariableCollectionId:36248:20769",
2449
+ $figmaModeId: "36248:2",
2450
+ name: "Primary",
2451
+ selectedTokenSets: Object.fromEntries(
2452
+ themes.map((theme) => [`primitives/modes/typography/primary/${theme}`, TokenSetStatus.ENABLED])
2453
+ ),
2454
+ group: "Typography"
2455
+ },
2456
+ {
2457
+ id: "264b8bd1d40b364e1ea3acf09e49795ddd4c513c",
2458
+ $figmaCollectionId: "VariableCollectionId:36248:20769",
2459
+ $figmaModeId: "36248:3",
2460
+ name: "Secondary",
2461
+ selectedTokenSets: Object.fromEntries(
2462
+ themes.map((theme) => [`primitives/modes/typography/secondary/${theme}`, TokenSetStatus.ENABLED])
2463
+ ),
2464
+ group: "Typography"
2465
+ }
2466
+ ];
2467
+ }
2468
+
2469
+ // src/tokens/create/write.ts
2470
+ var stringify = (data) => JSON.stringify(data, null, 2);
2471
+ var writeTokens = async (options) => {
2472
+ const {
2473
+ outDir,
2474
+ tokenSets,
2475
+ theme: { name: themeName, colors: colors2 },
2476
+ dry
2477
+ } = options;
2478
+ const targetDir = path2.resolve(process.cwd(), String(outDir));
2479
+ const $themesPath = path2.join(targetDir, "$themes.json");
2480
+ const $metadataPath = path2.join(targetDir, "$metadata.json");
2481
+ const $designsystemetPath = path2.join(targetDir, "$designsystemet.json");
2482
+ let themeObjects = [];
2483
+ await mkdir(targetDir, dry);
2484
+ try {
2485
+ const $themes2 = await readFile($themesPath);
2486
+ if ($themes2) {
2487
+ themeObjects = JSON.parse($themes2);
2488
+ }
2489
+ } catch (_error) {
2490
+ }
2491
+ const concatThemeNames = R19.pipe(
2492
+ R19.filter((obj) => R19.toLower(obj.group || "") === "theme"),
2493
+ R19.map(R19.prop("name")),
2494
+ // New theme is added to the end of the list so we keep the same order from config and Token Studio
2495
+ R19.append(themeName),
2496
+ R19.uniq
2497
+ );
2498
+ const themes = concatThemeNames(themeObjects);
2499
+ console.log(`
2500
+ Themes: ${chalk7.blue(themes.join(", "))}`);
2501
+ const $themes = await generate$Themes(["dark", "light"], themes, colors2);
2502
+ const $metadata = generate$Metadata(["dark", "light"], themes, colors2);
2503
+ const $designsystemet = generate$Designsystemet();
2504
+ await writeFile($themesPath, stringify($themes), dry);
2505
+ await writeFile($metadataPath, stringify($metadata), dry);
2506
+ await writeFile($designsystemetPath, stringify($designsystemet), dry);
2507
+ for (const [set4, tokens] of tokenSets) {
2508
+ const fileDir = path2.join(targetDir, path2.dirname(set4));
2509
+ await mkdir(fileDir, dry);
2510
+ const filePath = path2.join(targetDir, `${set4}.json`);
2511
+ await writeFile(filePath, stringify(tokens), dry);
2512
+ }
2513
+ console.log(
2514
+ `Finished creating Designsystem design tokens in ${chalk7.green(outDir)} for theme ${chalk7.blue(themeName)}`
2515
+ );
2516
+ };
2517
+
2518
+ // src/tokens/create/defaults.ts
2519
+ import * as R20 from "ramda";
2520
+
2521
+ // src/tokens/template/design-tokens/primitives/globals.json with { type: 'json' }
2522
+ var globals_default = {
2523
+ "border-width": {
2524
+ "1": {
2525
+ $type: "borderWidth",
2526
+ $value: "1px"
2527
+ },
2528
+ "3": {
2529
+ $type: "borderWidth",
2530
+ $value: "3px"
2531
+ }
2532
+ },
2533
+ shadow: {
2534
+ "100": {
2535
+ $type: "boxShadow",
2536
+ $value: [
2537
+ {
2538
+ color: "rgba(0,0,0,0.16)",
2539
+ x: "0",
2540
+ y: "0",
2541
+ blur: "1",
2542
+ spread: "0"
2543
+ },
2544
+ {
2545
+ x: "0",
2546
+ y: "1",
2547
+ blur: "2",
2548
+ spread: "0",
2549
+ color: "rgba(0,0,0,0.12)"
2550
+ }
2551
+ ]
2552
+ },
2235
2553
  "200": {
2236
2554
  $type: "boxShadow",
2237
2555
  $value: [
@@ -3183,13 +3501,13 @@ var defaultTokens = {
3183
3501
  "primitives/modes/typography/size/large": large_default2,
3184
3502
  "semantic/style": style_default
3185
3503
  };
3186
- var getDefaultTokens = (tokenSets) => Object.entries(R19.pick(tokenSets, defaultTokens));
3504
+ var getDefaultTokens = (tokenSets) => Object.entries(R20.pick(tokenSets, defaultTokens));
3187
3505
  var getDefaultToken = (tokenPath) => {
3188
3506
  return [tokenPath, defaultTokens[tokenPath]];
3189
3507
  };
3190
3508
 
3191
3509
  // src/tokens/create/generators/color.ts
3192
- import * as R20 from "ramda";
3510
+ import * as R21 from "ramda";
3193
3511
  var generateColor = (colorArray) => {
3194
3512
  const obj = {};
3195
3513
  const $type = "color";
@@ -3199,8 +3517,8 @@ var generateColor = (colorArray) => {
3199
3517
  return obj;
3200
3518
  };
3201
3519
  var generateColorScheme = (themeName, colorScheme2, colors2) => {
3202
- const main = R20.map((color) => generateColor(generateColorScale(color, colorScheme2)), colors2.main);
3203
- const support = R20.map((color) => generateColor(generateColorScale(color, colorScheme2)), colors2.support);
3520
+ const main = R21.map((color) => generateColor(generateColorScale(color, colorScheme2)), colors2.main);
3521
+ const support = R21.map((color) => generateColor(generateColorScale(color, colorScheme2)), colors2.support);
3204
3522
  const neutral = generateColor(generateColorScale(colors2.neutral, colorScheme2));
3205
3523
  return {
3206
3524
  [themeName]: {
@@ -3228,7 +3546,7 @@ var generateColorGlobal = (colorScheme2) => {
3228
3546
  };
3229
3547
 
3230
3548
  // src/tokens/create/generators/semantic.ts
3231
- import * as R21 from "ramda";
3549
+ import * as R22 from "ramda";
3232
3550
 
3233
3551
  // src/tokens/template/design-tokens/semantic/color.base.template.json with { type: 'json' }
3234
3552
  var color_base_template_default = {
@@ -3692,7 +4010,7 @@ var generateSemantic = (colors2) => {
3692
4010
  const semanticColorTokens = customColors.map(
3693
4011
  (colorName) => [
3694
4012
  colorName,
3695
- R21.map((x) => ({ ...x, $value: x.$value.replace("<color>", colorName) }), color_template_default)
4013
+ R22.map((x) => ({ ...x, $value: x.$value.replace("<color>", colorName) }), color_template_default)
3696
4014
  ]
3697
4015
  );
3698
4016
  const color = {
@@ -3709,7 +4027,7 @@ var generateSemantic = (colors2) => {
3709
4027
  };
3710
4028
 
3711
4029
  // src/tokens/create/generators/theme.ts
3712
- import * as R22 from "ramda";
4030
+ import * as R23 from "ramda";
3713
4031
 
3714
4032
  // src/tokens/template/design-tokens/themes/theme.base.template.json with { type: 'json' }
3715
4033
  var theme_base_template_default = {
@@ -3845,7 +4163,7 @@ var generateTheme = (colors2, themeName, borderRadius) => {
3845
4163
  customColors.map(
3846
4164
  (colorName) => [
3847
4165
  colorName,
3848
- R22.map((x) => ({ ...x, $value: x.$value.replace("<color>", colorName) }), theme_template_default)
4166
+ R23.map((x) => ({ ...x, $value: x.$value.replace("<color>", colorName) }), theme_template_default)
3849
4167
  ]
3850
4168
  )
3851
4169
  );
@@ -3857,8 +4175,8 @@ var generateTheme = (colors2, themeName, borderRadius) => {
3857
4175
  },
3858
4176
  ...remainingThemeFile
3859
4177
  };
3860
- const baseBorderRadius = R22.lensPath(["border-radius", "base", "$value"]);
3861
- const updatedThemeFile = R22.set(baseBorderRadius, String(borderRadius), themeFile);
4178
+ const baseBorderRadius = R23.lensPath(["border-radius", "base", "$value"]);
4179
+ const updatedThemeFile = R23.set(baseBorderRadius, String(borderRadius), themeFile);
3862
4180
  const token = JSON.parse(
3863
4181
  JSON.stringify(
3864
4182
  updatedThemeFile,
@@ -3909,6 +4227,7 @@ var generateTypography = (themeName, { fontFamily }) => {
3909
4227
  var cliOptions = {
3910
4228
  outDir: "out-dir",
3911
4229
  clean: "clean",
4230
+ tailwind: "tailwind",
3912
4231
  theme: {
3913
4232
  colors: {
3914
4233
  main: "main-colors",
@@ -3953,263 +4272,6 @@ var createTokens = async (opts) => {
3953
4272
  return { tokenSets };
3954
4273
  };
3955
4274
 
3956
- // src/tokens/create/write.ts
3957
- import path2 from "path";
3958
- import chalk7 from "chalk";
3959
- import * as R23 from "ramda";
3960
-
3961
- // src/tokens/create/generators/$designsystemet.ts
3962
- function generate$Designsystemet() {
3963
- return {
3964
- name: package_default.name,
3965
- version: package_default.version
3966
- };
3967
- }
3968
-
3969
- // src/tokens/create/generators/$metadata.ts
3970
- function generate$Metadata(schemes, themes, colors2) {
3971
- return {
3972
- tokenSetOrder: [
3973
- "primitives/globals",
3974
- "primitives/modes/size/small",
3975
- "primitives/modes/size/medium",
3976
- "primitives/modes/size/large",
3977
- "primitives/modes/size/global",
3978
- "primitives/modes/typography/size/small",
3979
- "primitives/modes/typography/size/medium",
3980
- "primitives/modes/typography/size/large",
3981
- ...themes.map((theme) => `primitives/modes/typography/primary/${theme}`),
3982
- ...themes.map((theme) => `primitives/modes/typography/secondary/${theme}`),
3983
- ...schemes.flatMap((scheme) => [
3984
- `primitives/modes/color-scheme/${scheme}/global`,
3985
- ...themes.map((theme) => `primitives/modes/color-scheme/${scheme}/${theme}`)
3986
- ]),
3987
- ...themes.map((theme) => `themes/${theme}`),
3988
- "semantic/color",
3989
- ...Object.entries(colors2.main).map(([color]) => `semantic/modes/main-color/${color}`),
3990
- ...Object.entries(colors2.support).map(([color]) => `semantic/modes/support-color/${color}`),
3991
- "semantic/style"
3992
- ]
3993
- };
3994
- }
3995
-
3996
- // src/tokens/create/generators/$themes.ts
3997
- var capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
3998
- async function createHash(text, algo = "SHA-1") {
3999
- const crypto = globalThis.crypto;
4000
- return Array.from(
4001
- new Uint8Array(await crypto.subtle.digest(algo, new TextEncoder().encode(text))),
4002
- (byte) => byte.toString(16).padStart(2, "0")
4003
- ).join("");
4004
- }
4005
- async function generate$Themes(colorSchemes, themes, colors2) {
4006
- return [
4007
- ...generateSizeGroup(),
4008
- ...await generateThemesGroup(themes),
4009
- ...generateTypographyGroup(themes),
4010
- ...generateColorSchemesGroup(colorSchemes, themes),
4011
- generateSemanticGroup(),
4012
- ...await generateColorGroup("main", colors2),
4013
- ...await generateColorGroup("support", colors2)
4014
- ];
4015
- }
4016
- function generateSizeGroup() {
4017
- return [
4018
- {
4019
- id: "8b2c8cc86611a34b135cb22948666779361fd729",
4020
- name: "medium",
4021
- $figmaStyleReferences: {},
4022
- selectedTokenSets: {
4023
- "primitives/modes/size/medium": TokenSetStatus.SOURCE,
4024
- "primitives/modes/size/global": TokenSetStatus.ENABLED,
4025
- "primitives/modes/typography/size/medium": TokenSetStatus.ENABLED
4026
- },
4027
- $figmaCollectionId: "VariableCollectionId:36248:20757",
4028
- $figmaModeId: "41630:1",
4029
- group: "Size"
4030
- },
4031
- {
4032
- id: "d49b9eebeb48a4f165a74b7261733d0a73370f0e",
4033
- name: "large",
4034
- $figmaStyleReferences: {},
4035
- selectedTokenSets: {
4036
- "primitives/modes/size/large": TokenSetStatus.SOURCE,
4037
- "primitives/modes/size/global": TokenSetStatus.ENABLED,
4038
- "primitives/modes/typography/size/large": TokenSetStatus.ENABLED
4039
- },
4040
- $figmaCollectionId: "VariableCollectionId:36248:20757",
4041
- $figmaModeId: "41630:2",
4042
- group: "Size"
4043
- },
4044
- {
4045
- id: "fb11567729c298ca37c9da4e3a27716a23480824",
4046
- name: "small",
4047
- $figmaStyleReferences: {},
4048
- selectedTokenSets: {
4049
- "primitives/modes/size/small": TokenSetStatus.SOURCE,
4050
- "primitives/modes/size/global": TokenSetStatus.ENABLED,
4051
- "primitives/modes/typography/size/small": TokenSetStatus.ENABLED
4052
- },
4053
- $figmaCollectionId: "VariableCollectionId:36248:20757",
4054
- $figmaModeId: "41630:3",
4055
- group: "Size"
4056
- }
4057
- ];
4058
- }
4059
- var colorSchemeDefaults = {
4060
- light: {
4061
- name: "Light",
4062
- selectedTokenSets: {},
4063
- id: "0daa3ca0b427b9349da7e7dc00101b5668972926",
4064
- $figmaCollectionId: "VariableCollectionId:34811:5472",
4065
- $figmaModeId: "34811:0"
4066
- },
4067
- dark: {
4068
- name: "Dark",
4069
- selectedTokenSets: {},
4070
- id: "9ebd8aed52afbffc17e2666e8b4653a53498b257",
4071
- $figmaCollectionId: "VariableCollectionId:34811:5472",
4072
- $figmaModeId: "34811:1"
4073
- },
4074
- contrast: {
4075
- name: "Contrast",
4076
- selectedTokenSets: {},
4077
- id: "9ebd8aed52afbffc17e2666e8b4653a53498b123",
4078
- $figmaCollectionId: "VariableCollectionId:34811:5472",
4079
- $figmaModeId: "34811:2"
4080
- }
4081
- };
4082
- function generateColorSchemesGroup(colorSchemes, themes) {
4083
- return colorSchemes.map(
4084
- (scheme) => ({
4085
- ...colorSchemeDefaults[scheme],
4086
- selectedTokenSets: Object.fromEntries([
4087
- [`primitives/modes/color-scheme/${scheme}/global`, TokenSetStatus.ENABLED],
4088
- ...themes.map((theme) => [`primitives/modes/color-scheme/${scheme}/${theme}`, TokenSetStatus.ENABLED])
4089
- ]),
4090
- group: "Color scheme"
4091
- })
4092
- );
4093
- }
4094
- async function generateThemesGroup(themes) {
4095
- return Promise.all(
4096
- themes.map(
4097
- async (theme, index) => ({
4098
- id: await createHash(theme),
4099
- $figmaCollectionId: "VariableCollectionId:36528:61712",
4100
- $figmaModeId: `40960:${index + 6}`,
4101
- // Start on 6 in Token Studio and Community file for some reason
4102
- name: theme,
4103
- selectedTokenSets: {
4104
- [`themes/${theme}`]: TokenSetStatus.ENABLED
4105
- },
4106
- group: "Theme"
4107
- })
4108
- )
4109
- );
4110
- }
4111
- function generateSemanticGroup() {
4112
- return {
4113
- id: "541629445ef90ad5363f9e88f52a1ccb617e6f84",
4114
- name: "Semantic",
4115
- selectedTokenSets: {
4116
- "semantic/style": TokenSetStatus.ENABLED,
4117
- "semantic/color": TokenSetStatus.ENABLED,
4118
- "primitives/globals": TokenSetStatus.SOURCE
4119
- },
4120
- $figmaCollectionId: "VariableCollectionId:34811:5976",
4121
- $figmaModeId: "34811:5",
4122
- group: "Semantic"
4123
- };
4124
- }
4125
- async function generateColorGroup(group, colors2) {
4126
- return Promise.all(
4127
- Object.entries(colors2[group]).map(
4128
- async ([color]) => ({
4129
- id: await createHash(`${group}-${color}`),
4130
- name: color,
4131
- selectedTokenSets: {
4132
- [`semantic/modes/${group}-color/${color}`]: TokenSetStatus.ENABLED
4133
- },
4134
- group: `${capitalize(group)} color`
4135
- })
4136
- )
4137
- );
4138
- }
4139
- function generateTypographyGroup(themes) {
4140
- return [
4141
- {
4142
- id: "368d753fcac4455f289500eaa42e70dc0a03522f",
4143
- $figmaCollectionId: "VariableCollectionId:36248:20769",
4144
- $figmaModeId: "36248:2",
4145
- name: "Primary",
4146
- selectedTokenSets: Object.fromEntries(
4147
- themes.map((theme) => [`primitives/modes/typography/primary/${theme}`, TokenSetStatus.ENABLED])
4148
- ),
4149
- group: "Typography"
4150
- },
4151
- {
4152
- id: "264b8bd1d40b364e1ea3acf09e49795ddd4c513c",
4153
- $figmaCollectionId: "VariableCollectionId:36248:20769",
4154
- $figmaModeId: "36248:3",
4155
- name: "Secondary",
4156
- selectedTokenSets: Object.fromEntries(
4157
- themes.map((theme) => [`primitives/modes/typography/secondary/${theme}`, TokenSetStatus.ENABLED])
4158
- ),
4159
- group: "Typography"
4160
- }
4161
- ];
4162
- }
4163
-
4164
- // src/tokens/create/write.ts
4165
- var stringify = (data) => JSON.stringify(data, null, 2);
4166
- var writeTokens = async (options) => {
4167
- const {
4168
- outDir,
4169
- tokenSets,
4170
- theme: { name: themeName, colors: colors2 },
4171
- dry
4172
- } = options;
4173
- const targetDir = path2.resolve(process.cwd(), String(outDir));
4174
- const $themesPath = path2.join(targetDir, "$themes.json");
4175
- const $metadataPath = path2.join(targetDir, "$metadata.json");
4176
- const $designsystemetPath = path2.join(targetDir, "$designsystemet.json");
4177
- let themeObjects = [];
4178
- await mkdir(targetDir, dry);
4179
- try {
4180
- const $themes2 = await readFile($themesPath);
4181
- if ($themes2) {
4182
- themeObjects = JSON.parse($themes2);
4183
- }
4184
- } catch (error) {
4185
- }
4186
- const concatThemeNames = R23.pipe(
4187
- R23.filter((obj) => R23.toLower(obj.group || "") === "theme"),
4188
- R23.map(R23.prop("name")),
4189
- // New theme is added to the end of the list so we keep the same order from config and Token Studio
4190
- R23.append(themeName),
4191
- R23.uniq
4192
- );
4193
- const themes = concatThemeNames(themeObjects);
4194
- console.log(`
4195
- Themes: ${chalk7.blue(themes.join(", "))}`);
4196
- const $themes = await generate$Themes(["dark", "light"], themes, colors2);
4197
- const $metadata = generate$Metadata(["dark", "light"], themes, colors2);
4198
- const $designsystemet = generate$Designsystemet();
4199
- await writeFile($themesPath, stringify($themes), dry);
4200
- await writeFile($metadataPath, stringify($metadata), dry);
4201
- await writeFile($designsystemetPath, stringify($designsystemet), dry);
4202
- for (const [set4, tokens] of tokenSets) {
4203
- const fileDir = path2.join(targetDir, path2.dirname(set4));
4204
- await mkdir(fileDir, dry);
4205
- const filePath = path2.join(targetDir, `${set4}.json`);
4206
- await writeFile(filePath, stringify(tokens), dry);
4207
- }
4208
- console.log(
4209
- `Finished creating Designsystem design tokens in ${chalk7.green(outDir)} for theme ${chalk7.blue(themeName)}`
4210
- );
4211
- };
4212
-
4213
4275
  // bin/config.ts
4214
4276
  import path4 from "path";
4215
4277
  import chalk9 from "chalk";
@@ -4218,8 +4280,8 @@ import * as R25 from "ramda";
4218
4280
  // src/config.ts
4219
4281
  import chalk8 from "chalk";
4220
4282
  import * as R24 from "ramda";
4221
- import { fromError } from "zod-validation-error";
4222
4283
  import { z } from "zod/v4";
4284
+ import { fromError } from "zod-validation-error";
4223
4285
  function mapPathToOptionName(path5) {
4224
4286
  const normalisedPath = path5[0] === "themes" ? ["theme", ...R24.drop(2, path5)] : path5;
4225
4287
  const option = R24.path(normalisedPath, cliOptions);
@@ -4408,8 +4470,8 @@ function makeTokenCommands() {
4408
4470
  "-o, --out-dir <string>",
4409
4471
  `Output directory for built ${chalk10.blue("design-tokens")}`,
4410
4472
  DEFAULT_TOKENS_BUILD_DIR
4411
- ).option(`--${cliOptions.clean} [boolean]`, "Clean output directory before building tokens", parseBoolean, false).option("--dry [boolean]", `Dry run for built ${chalk10.blue("design-tokens")}`, parseBoolean, false).option("-p, --preview", "Generate preview token.ts files", false).option("--verbose", "Enable verbose output", false).option("--config <string>", `Path to config file (default: "${DEFAULT_CONFIG_FILE}")`).action(async (opts) => {
4412
- const { preview, verbose, clean, dry } = opts;
4473
+ ).option(`--${cliOptions.clean} [boolean]`, "Clean output directory before building tokens", parseBoolean, false).option("--dry [boolean]", `Dry run for built ${chalk10.blue("design-tokens")}`, parseBoolean, false).option("-p, --preview", "Generate preview token.ts files", false).option("--verbose", "Enable verbose output", false).option("--config <string>", `Path to config file (default: "${DEFAULT_CONFIG_FILE}")`).option("--experimental-tailwind", "Generate Tailwind CSS classes for tokens", false).action(async (opts) => {
4474
+ const { preview, verbose, clean, dry, experimentalTailwind } = opts;
4413
4475
  const tokensDir = typeof opts.tokens === "string" ? opts.tokens : DEFAULT_TOKENS_CREATE_DIR;
4414
4476
  const outDir = typeof opts.outDir === "string" ? opts.outDir : "./dist/tokens";
4415
4477
  const { configFile, configPath } = await getConfigFile(opts.config);
@@ -4420,7 +4482,7 @@ function makeTokenCommands() {
4420
4482
  if (clean) {
4421
4483
  await cleanDir(outDir, dry);
4422
4484
  }
4423
- await buildTokens({ tokensDir, outDir, preview, verbose, dry, ...config });
4485
+ await buildTokens({ tokensDir, outDir, preview, verbose, dry, tailwind: experimentalTailwind, ...config });
4424
4486
  return Promise.resolve();
4425
4487
  });
4426
4488
  tokenCmd.command("create").description("Create Designsystemet tokens").option(`-m, --${cliOptions.theme.colors.main} <name:hex...>`, `Main colors`, parseColorValues).option(`-s, --${cliOptions.theme.colors.support} <name:hex...>`, `Support colors`, parseColorValues).option(`-n, --${cliOptions.theme.colors.neutral} <hex>`, `Neutral hex color`, convertToHex).option(
@@ -4480,7 +4542,7 @@ function parseColorValues(value, previous = {}) {
4480
4542
  previous[name] = convertToHex(hex);
4481
4543
  return previous;
4482
4544
  }
4483
- function parseBoolean(value, previous) {
4545
+ function parseBoolean(value) {
4484
4546
  return value === "true" || value === true;
4485
4547
  }
4486
4548
  async function getConfigFile(config) {