@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.
- package/CHANGELOG.md +7 -0
- package/build.mjs +129 -0
- package/dist/_variables.scss +646 -635
- package/dist/index.css +646 -635
- package/dist/index.d.ts +725 -715
- package/dist/index.js +742 -731
- package/dist/index.json +741 -730
- package/dist/index.tokens.json +1625 -1617
- package/dist/root.css +646 -635
- package/dist/tokens.d.ts +1506 -1498
- package/dist/tokens.js +22273 -22035
- package/dist/uitvoerend-mintgroen-focus/_variables.scss +1199 -0
- package/dist/uitvoerend-mintgroen-focus/index.css +1202 -0
- package/dist/uitvoerend-mintgroen-focus/index.d.ts +1200 -0
- package/dist/uitvoerend-mintgroen-focus/index.js +1200 -0
- package/dist/uitvoerend-mintgroen-focus/index.json +1197 -0
- package/dist/uitvoerend-mintgroen-focus/index.tokens.json +1883 -0
- package/dist/uitvoerend-mintgroen-focus/root.css +1202 -0
- package/dist/uitvoerend-mintgroen-focus/tokens.d.ts +1906 -0
- package/dist/uitvoerend-mintgroen-focus/tokens.js +28122 -0
- package/dist/uitvoerend-violet/_variables.scss +1193 -0
- package/dist/uitvoerend-violet/index.css +1196 -0
- package/dist/uitvoerend-violet/index.d.ts +1194 -0
- package/dist/uitvoerend-violet/index.js +1194 -0
- package/dist/uitvoerend-violet/index.json +1191 -0
- package/dist/uitvoerend-violet/index.tokens.json +1845 -0
- package/dist/uitvoerend-violet/root.css +1196 -0
- package/dist/uitvoerend-violet/tokens.d.ts +1868 -0
- package/dist/uitvoerend-violet/tokens.js +27950 -0
- package/dist/uitvoerend-violet-oud/_variables.scss +1193 -0
- package/dist/uitvoerend-violet-oud/index.css +1196 -0
- package/dist/uitvoerend-violet-oud/index.d.ts +1194 -0
- package/dist/uitvoerend-violet-oud/index.js +1194 -0
- package/dist/uitvoerend-violet-oud/index.json +1191 -0
- package/dist/uitvoerend-violet-oud/index.tokens.json +1845 -0
- package/dist/uitvoerend-violet-oud/root.css +1196 -0
- package/dist/uitvoerend-violet-oud/tokens.d.ts +1868 -0
- package/dist/uitvoerend-violet-oud/tokens.js +27950 -0
- package/dist/wetgevend/_variables.scss +1193 -0
- package/dist/wetgevend/index.css +1196 -0
- package/dist/wetgevend/index.d.ts +1194 -0
- package/dist/wetgevend/index.js +1194 -0
- package/dist/wetgevend/index.json +1191 -0
- package/dist/wetgevend/index.tokens.json +1845 -0
- package/dist/wetgevend/root.css +1196 -0
- package/dist/wetgevend/tokens.d.ts +1868 -0
- package/dist/{tokens.json → wetgevend/tokens.js} +22004 -21868
- package/figma/figma.tokens.json +932 -234
- package/package.json +10 -12
- package/src/generated/base.tokens.json +5594 -0
- package/src/generated/themes.json +22362 -0
- package/src/generated/uitvoerend-mintgroen-focus/tokens.json +5628 -0
- package/src/generated/uitvoerend-violet/tokens.json +5572 -0
- package/src/generated/uitvoerend-violet-oud/tokens.json +5572 -0
- package/src/generated/{figma.tokens.json → wetgevend/tokens.json} +4398 -4354
- package/token-transformer.mjs +77 -41
- package/dist/variables.less +0 -1187
- package/style-dictionary.config.json +0 -105
package/CHANGELOG.md
ADDED
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();
|