@utrecht/design-tokens 2.1.0 → 2.2.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 (79) hide show
  1. package/.stylelintrc.json +5 -1
  2. package/CHANGELOG.md +14 -0
  3. package/config.json +8 -0
  4. package/dist/_mixin-theme.scss +34 -37
  5. package/dist/_mixin.scss +1009 -0
  6. package/dist/_variables.scss +34 -37
  7. package/dist/background-image-icon.css +0 -1
  8. package/dist/dark/_mixin-theme.scss +34 -37
  9. package/dist/dark/_mixin.scss +1020 -0
  10. package/dist/dark/_variables.scss +1017 -0
  11. package/dist/dark/index.cjs +1020 -0
  12. package/dist/dark/index.css +34 -37
  13. package/dist/dark/index.d.ts +1139 -0
  14. package/dist/dark/index.flat.json +1016 -0
  15. package/dist/dark/index.json +30694 -0
  16. package/dist/dark/index.mjs +1018 -0
  17. package/dist/dark/index.tokens.json +7885 -0
  18. package/dist/dark/list.json +30694 -0
  19. package/dist/dark/property.css +705 -0
  20. package/dist/dark/root.css +538 -541
  21. package/dist/dark/theme-prince-xml.css +1020 -0
  22. package/dist/dark/theme.css +1020 -0
  23. package/dist/dark/tokens.cjs +37567 -0
  24. package/dist/dark/tokens.d.ts +4842 -0
  25. package/dist/dark/tokens.json +37563 -0
  26. package/dist/dark/variables.cjs +1020 -0
  27. package/dist/dark/variables.css +1020 -0
  28. package/dist/dark/variables.d.ts +1139 -0
  29. package/dist/dark/variables.json +1016 -0
  30. package/dist/dark/variables.less +1017 -0
  31. package/dist/dark/variables.mjs +1018 -0
  32. package/dist/index.cjs +29 -32
  33. package/dist/index.css +149 -82
  34. package/dist/index.d.ts +18 -25
  35. package/dist/index.flat.json +591 -593
  36. package/dist/index.json +4577 -7587
  37. package/dist/index.mjs +31 -34
  38. package/dist/index.tokens.json +385 -71
  39. package/dist/list.json +31811 -0
  40. package/dist/property.css +770 -0
  41. package/dist/root.css +529 -532
  42. package/dist/theme-prince-xml.css +34 -37
  43. package/dist/theme.css +529 -532
  44. package/dist/tokens.cjs +6297 -8992
  45. package/dist/tokens.d.ts +208 -60
  46. package/dist/tokens.json +38705 -0
  47. package/dist/variables.cjs +1009 -0
  48. package/dist/variables.css +1009 -0
  49. package/dist/variables.d.ts +1128 -0
  50. package/dist/variables.json +1005 -0
  51. package/dist/variables.less +34 -37
  52. package/dist/variables.mjs +1007 -0
  53. package/package.json +6 -5
  54. package/src/background-image-icon.scss +0 -1
  55. package/src/brand/utrecht/typography.tokens.json +7 -9
  56. package/src/component/of/progress-indicator.tokens.json +1 -1
  57. package/src/component/utrecht/backdrop.tokens.json +1 -1
  58. package/src/component/utrecht/blockquote.tokens.json +3 -3
  59. package/src/component/utrecht/button.tokens.json +1 -3
  60. package/src/component/utrecht/code-block.tokens.json +2 -2
  61. package/src/component/utrecht/figure.tokens.json +2 -2
  62. package/src/component/utrecht/form-fieldset.tokens.json +2 -2
  63. package/src/component/utrecht/form-toggle.tokens.json +1 -1
  64. package/src/component/utrecht/link.tokens.json +3 -1
  65. package/src/component/utrecht/pagination.tokens.json +1 -1
  66. package/src/component/utrecht/skip-link.tokens.json +4 -2
  67. package/src/component/utrecht/table.tokens.json +1 -1
  68. package/src/component/utrecht/toptask-link.tokens.json +1 -1
  69. package/src/css-property-formatter.mjs +46 -0
  70. package/src/dark/component/tokens.json +1 -1
  71. package/src/index.scss +81 -5
  72. package/style-dictionary-build-dark.mjs +64 -0
  73. package/style-dictionary-build.mjs +41 -0
  74. package/style-dictionary-config.mjs +261 -0
  75. package/dist/figma-tokens.json +0 -40396
  76. package/src/css-property-formatter.js +0 -35
  77. package/src/style-dictionary-config-dark.js +0 -56
  78. package/src/style-dictionary-config.js +0 -63
  79. package/style-dictionary.config.json +0 -143
@@ -0,0 +1,261 @@
1
+ import { propertyFormatterHooksConfig } from './src/css-property-formatter.mjs';
2
+ const stringSort = (a, b) => (a === b ? 0 : a > b ? 1 : -1);
3
+
4
+ const sortByName = (a, b) => stringSort(a.name, b.name);
5
+
6
+ export const createStyleDictionaryConfig = ({ themeName, source = ['src/**/*.tokens.json'] }) => ({
7
+ hooks: {
8
+ formats: {
9
+ ...propertyFormatterHooksConfig,
10
+ 'json/list': function ({ dictionary }) {
11
+ return JSON.stringify(dictionary.allTokens.sort(sortByName), null, ' ');
12
+ },
13
+ },
14
+ transforms: {
15
+ 'fontSize/pxToRem': {
16
+ name: 'fontSize/pxToRem',
17
+ type: 'value',
18
+ transitive: false,
19
+ transform: (token) => {
20
+ const isFontSize = (token) => token.path[token.path.length - 1] === 'font-size' || token.type === 'fontSize';
21
+ const isLineHeight = (token) => token.path[token.path.length - 1] === 'line-height';
22
+
23
+ if ((isFontSize(token) || isLineHeight(token)) && /px$/i.test(token.value)) {
24
+ const px = parseInt(token.value, 10);
25
+ const ratio = 1 / 16;
26
+ const rem = px * ratio;
27
+ const value = `${rem}rem`;
28
+
29
+ return value;
30
+ }
31
+
32
+ return token.value;
33
+ },
34
+ },
35
+ },
36
+ },
37
+ source,
38
+ platforms: {
39
+ js: {
40
+ transformGroups: 'tokens-studio',
41
+ transforms: ['name/camel', 'fontSize/pxToRem'],
42
+ buildPath: 'dist/',
43
+ files: [
44
+ {
45
+ destination: 'variables.cjs',
46
+ format: 'javascript/module-flat',
47
+ },
48
+ {
49
+ destination: 'variables.mjs',
50
+ format: 'javascript/es6',
51
+ },
52
+ ],
53
+ },
54
+ tokenTree: {
55
+ transformGroups: 'tokens-studio',
56
+ transforms: ['fontSize/pxToRem'],
57
+ buildPath: 'dist/',
58
+ files: [
59
+ {
60
+ format: 'javascript/module',
61
+ destination: 'tokens.cjs',
62
+ },
63
+ ],
64
+ },
65
+ json: {
66
+ transformGroups: 'tokens-studio',
67
+ transforms: ['name/camel', 'fontSize/pxToRem'],
68
+ buildPath: 'dist/',
69
+ files: [
70
+ {
71
+ destination: 'tokens.json',
72
+ format: 'json',
73
+ },
74
+ {
75
+ destination: 'list.json',
76
+ format: 'json/list',
77
+ },
78
+ {
79
+ destination: 'variables.json',
80
+ format: 'json/flat',
81
+ },
82
+ ],
83
+ },
84
+ css: {
85
+ transformGroups: 'tokens-studio',
86
+ transforms: ['name/kebab', 'fontSize/pxToRem'],
87
+ buildPath: 'dist/',
88
+ files: [
89
+ {
90
+ destination: 'theme.css',
91
+ format: 'css/variables',
92
+ options: {
93
+ selector: `.${themeName}`,
94
+ outputReferences: true,
95
+ },
96
+ },
97
+ {
98
+ destination: 'variables.css',
99
+ format: 'css/variables',
100
+ options: {
101
+ selector: `:root`,
102
+ outputReferences: true,
103
+ },
104
+ },
105
+ {
106
+ destination: 'property.css',
107
+ format: 'css/property',
108
+ },
109
+ ],
110
+ },
111
+ 'css-theme-prince-xml': {
112
+ transforms: ['name/kebab', 'fontSize/pxToRem'],
113
+ buildPath: 'dist/',
114
+ files: [
115
+ {
116
+ destination: 'theme-prince-xml.css',
117
+ format: 'css/variables',
118
+ options: {
119
+ selector: '.utrecht-theme',
120
+ outputReferences: true,
121
+ },
122
+ },
123
+ ],
124
+ },
125
+ scss: {
126
+ transformGroups: 'tokens-studio',
127
+ transforms: ['name/kebab', 'fontSize/pxToRem'],
128
+ buildPath: 'dist/',
129
+ files: [
130
+ {
131
+ destination: '_variables.scss',
132
+ format: 'scss/variables',
133
+ options: {
134
+ outputReferences: true,
135
+ },
136
+ },
137
+ ],
138
+ },
139
+ 'scss-theme-mixin': {
140
+ transforms: ['name/kebab', 'fontSize/pxToRem'],
141
+ buildPath: 'dist/',
142
+ files: [
143
+ {
144
+ destination: '_mixin.scss',
145
+ format: 'css/variables',
146
+ options: {
147
+ selector: `@mixin ${themeName}`,
148
+ outputReferences: true,
149
+ },
150
+ },
151
+ ],
152
+ },
153
+ less: {
154
+ transformGroups: 'tokens-studio',
155
+ transforms: ['name/kebab', 'fontSize/pxToRem'],
156
+ buildPath: 'dist/',
157
+ files: [
158
+ {
159
+ destination: 'variables.less',
160
+ format: 'less/variables',
161
+ options: {
162
+ outputReferences: true,
163
+ },
164
+ },
165
+ ],
166
+ },
167
+ typescript: {
168
+ transforms: ['name/camel', 'fontSize/pxToRem'],
169
+ transformGroup: 'js',
170
+ buildPath: 'dist/',
171
+ files: [
172
+ {
173
+ format: 'typescript/es6-declarations',
174
+ destination: 'variables.d.ts',
175
+ },
176
+ {
177
+ format: 'typescript/module-declarations',
178
+ destination: 'tokens.d.ts',
179
+ },
180
+ ],
181
+ },
182
+ 'deprecated-js': {
183
+ transformGroups: 'tokens-studio',
184
+ transforms: ['name/camel', 'fontSize/pxToRem'],
185
+ buildPath: 'dist/',
186
+ files: [
187
+ {
188
+ destination: 'index.cjs',
189
+ format: 'javascript/module-flat',
190
+ },
191
+ {
192
+ destination: 'index.mjs',
193
+ format: 'javascript/es6',
194
+ },
195
+ ],
196
+ },
197
+ 'deprecated-json': {
198
+ transformGroups: 'tokens-studio',
199
+ transforms: ['name/camel', 'fontSize/pxToRem'],
200
+ buildPath: 'dist/',
201
+ files: [
202
+ {
203
+ destination: 'index.tokens.json',
204
+ format: 'json/nested',
205
+ },
206
+ {
207
+ destination: 'index.json',
208
+ format: 'json/list',
209
+ },
210
+ {
211
+ destination: 'index.flat.json',
212
+ format: 'json/flat',
213
+ },
214
+ ],
215
+ },
216
+ 'deprecated-css': {
217
+ transformGroups: 'tokens-studio',
218
+ transforms: ['name/kebab', 'fontSize/pxToRem'],
219
+ buildPath: 'dist/',
220
+ files: [
221
+ {
222
+ destination: 'root.css',
223
+ format: 'css/variables',
224
+ options: {
225
+ selector: `:root`,
226
+ outputReferences: true,
227
+ },
228
+ },
229
+ {
230
+ destination: 'property.css',
231
+ format: 'css/property',
232
+ },
233
+ ],
234
+ },
235
+ 'deprecated-scss-theme-mixin': {
236
+ transforms: ['name/kebab', 'fontSize/pxToRem'],
237
+ buildPath: 'dist/',
238
+ files: [
239
+ {
240
+ destination: '_mixin-theme.scss',
241
+ format: 'css/variables',
242
+ options: {
243
+ selector: `@mixin ${themeName}`,
244
+ outputReferences: true,
245
+ },
246
+ },
247
+ ],
248
+ },
249
+ 'deprecated-typescript': {
250
+ transforms: ['name/camel', 'fontSize/pxToRem'],
251
+ transformGroup: 'js',
252
+ buildPath: 'dist/',
253
+ files: [
254
+ {
255
+ format: 'typescript/es6-declarations',
256
+ destination: 'index.d.ts',
257
+ },
258
+ ],
259
+ },
260
+ },
261
+ });