@rijkshuisstijl-community/design-tokens 1.0.0-alpha.99 → 1.0.1

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 (58) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build.mjs +129 -0
  3. package/dist/_variables.scss +646 -635
  4. package/dist/index.css +646 -635
  5. package/dist/index.d.ts +725 -715
  6. package/dist/index.js +742 -731
  7. package/dist/index.json +741 -730
  8. package/dist/index.tokens.json +1625 -1617
  9. package/dist/root.css +646 -635
  10. package/dist/tokens.d.ts +1506 -1498
  11. package/dist/tokens.js +22273 -22035
  12. package/dist/uitvoerend-mintgroen-focus/_variables.scss +1204 -0
  13. package/dist/uitvoerend-mintgroen-focus/index.css +1207 -0
  14. package/dist/uitvoerend-mintgroen-focus/index.d.ts +1205 -0
  15. package/dist/uitvoerend-mintgroen-focus/index.js +1205 -0
  16. package/dist/uitvoerend-mintgroen-focus/index.json +1202 -0
  17. package/dist/uitvoerend-mintgroen-focus/index.tokens.json +1890 -0
  18. package/dist/uitvoerend-mintgroen-focus/root.css +1207 -0
  19. package/dist/uitvoerend-mintgroen-focus/tokens.d.ts +1913 -0
  20. package/dist/uitvoerend-mintgroen-focus/tokens.js +28229 -0
  21. package/dist/uitvoerend-violet/_variables.scss +1198 -0
  22. package/dist/uitvoerend-violet/index.css +1201 -0
  23. package/dist/uitvoerend-violet/index.d.ts +1199 -0
  24. package/dist/uitvoerend-violet/index.js +1199 -0
  25. package/dist/uitvoerend-violet/index.json +1196 -0
  26. package/dist/uitvoerend-violet/index.tokens.json +1852 -0
  27. package/dist/uitvoerend-violet/root.css +1201 -0
  28. package/dist/uitvoerend-violet/tokens.d.ts +1875 -0
  29. package/dist/uitvoerend-violet/tokens.js +28057 -0
  30. package/dist/uitvoerend-violet-oud/_variables.scss +1198 -0
  31. package/dist/uitvoerend-violet-oud/index.css +1201 -0
  32. package/dist/uitvoerend-violet-oud/index.d.ts +1199 -0
  33. package/dist/uitvoerend-violet-oud/index.js +1199 -0
  34. package/dist/uitvoerend-violet-oud/index.json +1196 -0
  35. package/dist/uitvoerend-violet-oud/index.tokens.json +1852 -0
  36. package/dist/uitvoerend-violet-oud/root.css +1201 -0
  37. package/dist/uitvoerend-violet-oud/tokens.d.ts +1875 -0
  38. package/dist/uitvoerend-violet-oud/tokens.js +28057 -0
  39. package/dist/wetgevend/_variables.scss +1198 -0
  40. package/dist/wetgevend/index.css +1201 -0
  41. package/dist/wetgevend/index.d.ts +1199 -0
  42. package/dist/wetgevend/index.js +1199 -0
  43. package/dist/wetgevend/index.json +1196 -0
  44. package/dist/wetgevend/index.tokens.json +1852 -0
  45. package/dist/wetgevend/root.css +1201 -0
  46. package/dist/wetgevend/tokens.d.ts +1875 -0
  47. package/dist/{tokens.json → wetgevend/tokens.js} +17174 -16931
  48. package/figma/figma.tokens.json +937 -235
  49. package/package.json +10 -12
  50. package/src/generated/{figma.tokens.json → base.tokens.json} +4373 -4307
  51. package/src/generated/themes.json +22450 -0
  52. package/src/generated/uitvoerend-mintgroen-focus/tokens.json +5650 -0
  53. package/src/generated/uitvoerend-violet/tokens.json +5594 -0
  54. package/src/generated/uitvoerend-violet-oud/tokens.json +5594 -0
  55. package/src/generated/wetgevend/tokens.json +5594 -0
  56. package/token-transformer.mjs +77 -41
  57. package/dist/variables.less +0 -1187
  58. package/style-dictionary.config.json +0 -105
@@ -1,49 +1,85 @@
1
- import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
- import { dirname } from 'node:path';
1
+ import { existsSync, mkdirSync } from 'fs';
2
+ import { readFile, writeFile } from 'node:fs/promises';
3
3
 
4
4
  import { transformTokens } from 'token-transformer';
5
5
 
6
- const init = async ({ input, output }) => {
7
- const json = await readFile(input, 'utf-8');
8
- const rawTokens = JSON.parse(json);
9
-
10
- const setsToUse = [];
11
-
12
- // The following components didn't work yet because of broken design token references.
13
- // You can remove excludes from this list at any time, as long as they don't break the build.
14
- const excludes = [
15
- 'components/avatar',
16
- 'components/backdrop',
17
- 'components/drawer',
18
- 'components/form-field-option-label',
19
- 'components/modal-dialog',
20
- 'components/pagination',
21
- 'components/status-badge',
22
- 'components/summary-list',
23
- 'components/task-list',
24
- 'components/toolbar-button',
25
- ];
26
-
27
- const transformerOptions = {
28
- // expandTypography: true,
29
- // expandShadow: true,
30
- // expandComposition: true,
31
- // expandBorder: true,
32
- // preserveRawValue: false,
33
- // throwErrorWhenNotResolved: true,
34
- // resolveReferences: true,
35
- };
36
-
37
- let resolved = transformTokens(rawTokens, setsToUse, excludes, transformerOptions);
6
+ // the commented options and their values are default values from the token-transformer package
7
+ const transformerOptions = {
8
+ // expandTypography: true,
9
+ // expandShadow: true,
10
+ // expandComposition: true,
11
+ // expandBorder: true,
12
+ // preserveRawValue: false,
13
+ // throwErrorWhenNotResolved: true,
14
+ // Tried to set this to false, it worked in principle but there were breaking in the styles especially with spacing. I think it's better to keep it true
15
+ // resolveReferences: true,
16
+ };
17
+
18
+ const excludes = [
19
+ 'components/avatar',
20
+ 'components/backdrop',
21
+ 'components/drawer',
22
+ 'components/form-field-option-label',
23
+ 'components/modal-dialog',
24
+ 'components/pagination',
25
+ 'components/status-badge',
26
+ 'components/summary-list',
27
+ 'components/task-list',
28
+ 'components/toolbar-button',
29
+ ];
30
+
31
+ // Split tokens into separate files
32
+ async function transformAndSplitTokens() {
33
+ // Read the raw JSON file directly
34
+ const json = await readFile('./figma/figma.tokens.json', 'utf-8');
35
+ const tokens = JSON.parse(json);
38
36
 
37
+ // Extract base tokens (excluding $themes and overwrites/)
38
+ // Not sure if other designers might not be able to modify the themes created by paid plugin so getting the base tokens is a good fallback
39
+ const baseTokens = {};
40
+ Object.entries(tokens).forEach(([key, value]) => {
41
+ if (!key.startsWith('$') && !key.startsWith('overwrites/')) {
42
+ baseTokens[key] = value;
43
+ }
44
+ });
45
+
46
+ // Transform base tokens
47
+ let resolved = transformTokens(baseTokens, [], excludes, transformerOptions);
39
48
  delete resolved['tokenSetOrder'];
40
49
 
41
- await mkdir(dirname(output), { recursive: true });
50
+ // Process themes to add the enabled components
51
+ const themes = tokens.$themes || [];
52
+ const processedThemes = {};
42
53
 
43
- await writeFile(output, JSON.stringify(resolved, null, 2));
44
- };
54
+ themes.forEach((theme) => {
55
+ const themeTokens = {};
56
+
57
+ Object.entries(theme.selectedTokenSets).forEach(([tokenSet, status]) => {
58
+ if (status === 'enabled') {
59
+ if (tokens[tokenSet]) {
60
+ themeTokens[tokenSet] = tokens[tokenSet];
61
+ }
62
+ }
63
+ });
64
+
65
+ // Transform the theme tokens
66
+ const transformedThemeTokens = transformTokens(themeTokens, [], excludes, transformerOptions);
67
+
68
+ processedThemes[theme.name] = {
69
+ id: theme.id,
70
+ tokens: transformedThemeTokens,
71
+ group: theme.group,
72
+ };
73
+ });
74
+
75
+ // Ensure directories exist
76
+ if (!existsSync('./src/generated')) {
77
+ mkdirSync('./src/generated', { recursive: true });
78
+ }
79
+
80
+ // Write files
81
+ await writeFile('./src/generated/base.tokens.json', JSON.stringify(resolved, null, 2));
82
+ await writeFile('./src/generated/themes.json', JSON.stringify(processedThemes, null, 2));
83
+ }
45
84
 
46
- init({
47
- input: './figma/figma.tokens.json',
48
- output: './src/generated/figma.tokens.json',
49
- });
85
+ transformAndSplitTokens();