@rijkshuisstijl-community/design-tokens 1.0.0-alpha.99 → 1.0.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 (58) hide show
  1. package/CHANGELOG.md +7 -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 +1199 -0
  13. package/dist/uitvoerend-mintgroen-focus/index.css +1202 -0
  14. package/dist/uitvoerend-mintgroen-focus/index.d.ts +1200 -0
  15. package/dist/uitvoerend-mintgroen-focus/index.js +1200 -0
  16. package/dist/uitvoerend-mintgroen-focus/index.json +1197 -0
  17. package/dist/uitvoerend-mintgroen-focus/index.tokens.json +1883 -0
  18. package/dist/uitvoerend-mintgroen-focus/root.css +1202 -0
  19. package/dist/uitvoerend-mintgroen-focus/tokens.d.ts +1906 -0
  20. package/dist/uitvoerend-mintgroen-focus/tokens.js +28122 -0
  21. package/dist/uitvoerend-violet/_variables.scss +1193 -0
  22. package/dist/uitvoerend-violet/index.css +1196 -0
  23. package/dist/uitvoerend-violet/index.d.ts +1194 -0
  24. package/dist/uitvoerend-violet/index.js +1194 -0
  25. package/dist/uitvoerend-violet/index.json +1191 -0
  26. package/dist/uitvoerend-violet/index.tokens.json +1845 -0
  27. package/dist/uitvoerend-violet/root.css +1196 -0
  28. package/dist/uitvoerend-violet/tokens.d.ts +1868 -0
  29. package/dist/uitvoerend-violet/tokens.js +27950 -0
  30. package/dist/uitvoerend-violet-oud/_variables.scss +1193 -0
  31. package/dist/uitvoerend-violet-oud/index.css +1196 -0
  32. package/dist/uitvoerend-violet-oud/index.d.ts +1194 -0
  33. package/dist/uitvoerend-violet-oud/index.js +1194 -0
  34. package/dist/uitvoerend-violet-oud/index.json +1191 -0
  35. package/dist/uitvoerend-violet-oud/index.tokens.json +1845 -0
  36. package/dist/uitvoerend-violet-oud/root.css +1196 -0
  37. package/dist/uitvoerend-violet-oud/tokens.d.ts +1868 -0
  38. package/dist/uitvoerend-violet-oud/tokens.js +27950 -0
  39. package/dist/wetgevend/_variables.scss +1193 -0
  40. package/dist/wetgevend/index.css +1196 -0
  41. package/dist/wetgevend/index.d.ts +1194 -0
  42. package/dist/wetgevend/index.js +1194 -0
  43. package/dist/wetgevend/index.json +1191 -0
  44. package/dist/wetgevend/index.tokens.json +1845 -0
  45. package/dist/wetgevend/root.css +1196 -0
  46. package/dist/wetgevend/tokens.d.ts +1868 -0
  47. package/dist/{tokens.json → wetgevend/tokens.js} +22004 -21868
  48. package/figma/figma.tokens.json +932 -234
  49. package/package.json +10 -12
  50. package/src/generated/base.tokens.json +5594 -0
  51. package/src/generated/themes.json +22362 -0
  52. package/src/generated/uitvoerend-mintgroen-focus/tokens.json +5628 -0
  53. package/src/generated/uitvoerend-violet/tokens.json +5572 -0
  54. package/src/generated/uitvoerend-violet-oud/tokens.json +5572 -0
  55. package/src/generated/{figma.tokens.json → wetgevend/tokens.json} +4398 -4354
  56. package/token-transformer.mjs +77 -41
  57. package/dist/variables.less +0 -1187
  58. package/style-dictionary.config.json +0 -105
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @rijkshuisstijl-community/design-tokens
2
+
3
+ ## 1.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - ed83ac9: First full release
package/build.mjs ADDED
@@ -0,0 +1,129 @@
1
+ import { existsSync, mkdirSync } from 'fs';
2
+ import { readFile, writeFile } from 'node:fs/promises';
3
+ import path from 'path';
4
+ import StyleDictionary from 'style-dictionary';
5
+
6
+ // Will take the theme name and remove all spaces and make it lowercase
7
+ const normalizeThemeName = (name) => {
8
+ return name.toLowerCase().replace(/\s+/g, '');
9
+ };
10
+
11
+ // Get the platforms config
12
+ const getPlatformsConfig = (buildPath, themeName) => {
13
+ return {
14
+ javascript: {
15
+ transforms: ['attribute/cti', 'name/cti/camel', 'color/hsl-4'],
16
+ transformGroup: 'js',
17
+ buildPath,
18
+ files: [
19
+ {
20
+ format: 'typescript/es6-declarations',
21
+ destination: 'index.d.ts',
22
+ },
23
+ {
24
+ format: 'typescript/module-declarations',
25
+ destination: 'tokens.d.ts',
26
+ },
27
+ {
28
+ destination: 'index.js',
29
+ format: 'javascript/es6',
30
+ },
31
+ {
32
+ destination: 'tokens.js',
33
+ format: 'javascript/module',
34
+ },
35
+ {
36
+ destination: 'index.tokens.json',
37
+ format: 'json/nested',
38
+ },
39
+ {
40
+ destination: 'index.json',
41
+ format: 'json/flat',
42
+ },
43
+ ],
44
+ },
45
+ Web: {
46
+ transforms: ['attribute/cti', 'name/cti/kebab', 'color/hsl-4'],
47
+ buildPath,
48
+ files: [
49
+ {
50
+ destination: 'root.css',
51
+ format: 'css/variables',
52
+ options: {
53
+ outputReferences: true,
54
+ },
55
+ },
56
+ {
57
+ destination: 'index.css',
58
+ format: 'css/variables',
59
+ options: {
60
+ selector: `.${themeName}`,
61
+ outputReferences: true,
62
+ },
63
+ },
64
+ {
65
+ destination: '_variables.scss',
66
+ format: 'scss/variables',
67
+ options: {
68
+ outputReferences: true,
69
+ },
70
+ },
71
+ ],
72
+ },
73
+ };
74
+ };
75
+
76
+ // This will build the base tokens without the themes and without the overwrites
77
+ async function buildBaseTokens() {
78
+ const config = getPlatformsConfig('dist/', 'rhc-theme');
79
+ const StyleDictionaryBase = StyleDictionary.extend({
80
+ source: ['./src/**/base.tokens.json'],
81
+ platforms: {
82
+ ...config,
83
+ },
84
+ });
85
+
86
+ StyleDictionaryBase.buildAllPlatforms();
87
+ }
88
+
89
+ // This will build the themes
90
+ async function buildThemes() {
91
+ const themesJson = await readFile('./src/generated/themes.json', 'utf-8');
92
+ const themes = JSON.parse(themesJson);
93
+
94
+ // Process each theme separately
95
+ for (const [theme, themeData] of Object.entries(themes)) {
96
+ const themesDir = `./src/generated/${normalizeThemeName(theme)}`;
97
+
98
+ // Create the theme directory if it doesn't exist
99
+ if (!existsSync(themesDir)) {
100
+ mkdirSync(themesDir, { recursive: true });
101
+ }
102
+
103
+ // Write individual theme tokens
104
+ await writeFile(path.join(themesDir, `tokens.json`), JSON.stringify(themeData.tokens, null, 2));
105
+
106
+ const config = getPlatformsConfig(`dist/${normalizeThemeName(theme)}/`, normalizeThemeName(theme));
107
+ // Create a separate Style Dictionary instance for each theme
108
+ const StyleDictionaryTheme = StyleDictionary.extend({
109
+ source: [`./src/generated/${normalizeThemeName(theme)}/tokens.json`],
110
+ platforms: {
111
+ ...config,
112
+ },
113
+ });
114
+
115
+ // Build this specific theme
116
+ StyleDictionaryTheme.buildAllPlatforms();
117
+ }
118
+ }
119
+
120
+ async function build() {
121
+ try {
122
+ await buildBaseTokens();
123
+ await buildThemes();
124
+ } catch (error) {
125
+ console.error(error);
126
+ }
127
+ }
128
+
129
+ build();