@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.
- package/CHANGELOG.md +14 -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 +1204 -0
- package/dist/uitvoerend-mintgroen-focus/index.css +1207 -0
- package/dist/uitvoerend-mintgroen-focus/index.d.ts +1205 -0
- package/dist/uitvoerend-mintgroen-focus/index.js +1205 -0
- package/dist/uitvoerend-mintgroen-focus/index.json +1202 -0
- package/dist/uitvoerend-mintgroen-focus/index.tokens.json +1890 -0
- package/dist/uitvoerend-mintgroen-focus/root.css +1207 -0
- package/dist/uitvoerend-mintgroen-focus/tokens.d.ts +1913 -0
- package/dist/uitvoerend-mintgroen-focus/tokens.js +28229 -0
- package/dist/uitvoerend-violet/_variables.scss +1198 -0
- package/dist/uitvoerend-violet/index.css +1201 -0
- package/dist/uitvoerend-violet/index.d.ts +1199 -0
- package/dist/uitvoerend-violet/index.js +1199 -0
- package/dist/uitvoerend-violet/index.json +1196 -0
- package/dist/uitvoerend-violet/index.tokens.json +1852 -0
- package/dist/uitvoerend-violet/root.css +1201 -0
- package/dist/uitvoerend-violet/tokens.d.ts +1875 -0
- package/dist/uitvoerend-violet/tokens.js +28057 -0
- package/dist/uitvoerend-violet-oud/_variables.scss +1198 -0
- package/dist/uitvoerend-violet-oud/index.css +1201 -0
- package/dist/uitvoerend-violet-oud/index.d.ts +1199 -0
- package/dist/uitvoerend-violet-oud/index.js +1199 -0
- package/dist/uitvoerend-violet-oud/index.json +1196 -0
- package/dist/uitvoerend-violet-oud/index.tokens.json +1852 -0
- package/dist/uitvoerend-violet-oud/root.css +1201 -0
- package/dist/uitvoerend-violet-oud/tokens.d.ts +1875 -0
- package/dist/uitvoerend-violet-oud/tokens.js +28057 -0
- package/dist/wetgevend/_variables.scss +1198 -0
- package/dist/wetgevend/index.css +1201 -0
- package/dist/wetgevend/index.d.ts +1199 -0
- package/dist/wetgevend/index.js +1199 -0
- package/dist/wetgevend/index.json +1196 -0
- package/dist/wetgevend/index.tokens.json +1852 -0
- package/dist/wetgevend/root.css +1201 -0
- package/dist/wetgevend/tokens.d.ts +1875 -0
- package/dist/{tokens.json → wetgevend/tokens.js} +17174 -16931
- package/figma/figma.tokens.json +937 -235
- package/package.json +10 -12
- package/src/generated/{figma.tokens.json → base.tokens.json} +4373 -4307
- package/src/generated/themes.json +22450 -0
- package/src/generated/uitvoerend-mintgroen-focus/tokens.json +5650 -0
- package/src/generated/uitvoerend-violet/tokens.json +5594 -0
- package/src/generated/uitvoerend-violet-oud/tokens.json +5594 -0
- package/src/generated/wetgevend/tokens.json +5594 -0
- package/token-transformer.mjs +77 -41
- package/dist/variables.less +0 -1187
- package/style-dictionary.config.json +0 -105
package/token-transformer.mjs
CHANGED
|
@@ -1,49 +1,85 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
50
|
+
// Process themes to add the enabled components
|
|
51
|
+
const themes = tokens.$themes || [];
|
|
52
|
+
const processedThemes = {};
|
|
42
53
|
|
|
43
|
-
|
|
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
|
-
|
|
47
|
-
input: './figma/figma.tokens.json',
|
|
48
|
-
output: './src/generated/figma.tokens.json',
|
|
49
|
-
});
|
|
85
|
+
transformAndSplitTokens();
|