@koobiq/tokens-builder 3.15.2 → 3.17.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/build.js +1 -0
- package/configs/css.js +123 -3
- package/formats/variables.js +2 -0
- package/package.json +1 -1
- package/transformGroups/css.js +1 -1
- package/transforms/name/custom-kebab.js +19 -0
package/build.js
CHANGED
|
@@ -10,6 +10,7 @@ require('./transforms/attribute/font')(StyleDictionary);
|
|
|
10
10
|
require('./transforms/attribute/theme')(StyleDictionary);
|
|
11
11
|
require('./transforms/attribute/scss-value')(StyleDictionary);
|
|
12
12
|
require('./transforms/attribute/deprecation-comment')(StyleDictionary);
|
|
13
|
+
require('./transforms/name/custom-kebab')(StyleDictionary);
|
|
13
14
|
|
|
14
15
|
// ==== Include custom filters ====
|
|
15
16
|
require('./filters/palette')(StyleDictionary);
|
package/configs/css.js
CHANGED
|
@@ -2,7 +2,87 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('node:path');
|
|
3
3
|
|
|
4
4
|
const paletteColors = ['black', 'blue', 'cyan', 'green', 'grey', 'orange', 'purple', 'red', 'white', 'yellow'];
|
|
5
|
+
const newPaletteColors = [
|
|
6
|
+
'blue',
|
|
7
|
+
'slate',
|
|
8
|
+
'red',
|
|
9
|
+
'orange',
|
|
10
|
+
'yellow',
|
|
11
|
+
'green',
|
|
12
|
+
'teal',
|
|
13
|
+
'purple',
|
|
14
|
+
'darkBlue',
|
|
15
|
+
'darkSlate',
|
|
16
|
+
'darkRed',
|
|
17
|
+
'darkOrange',
|
|
18
|
+
'darkYellow',
|
|
19
|
+
'darkGreen',
|
|
20
|
+
'darkTeal',
|
|
21
|
+
'darkPurple',
|
|
22
|
+
'grey',
|
|
23
|
+
'darkGrey',
|
|
24
|
+
'greyA',
|
|
25
|
+
'darkGreyA',
|
|
26
|
+
'whiteA',
|
|
27
|
+
'blackA',
|
|
28
|
+
'blueA',
|
|
29
|
+
'slateA',
|
|
30
|
+
'redA',
|
|
31
|
+
'orangeA',
|
|
32
|
+
'yellowA',
|
|
33
|
+
'greenA',
|
|
34
|
+
'tealA',
|
|
35
|
+
'purpleA',
|
|
36
|
+
'darkBlueA',
|
|
37
|
+
'darkSlateA',
|
|
38
|
+
'darkRedA',
|
|
39
|
+
'darkOrangeA',
|
|
40
|
+
'darkYellowA',
|
|
41
|
+
'darkGreenA',
|
|
42
|
+
'darkTealA',
|
|
43
|
+
'darkPurpleA',
|
|
44
|
+
'yellowFixed',
|
|
45
|
+
'orangeFixed',
|
|
46
|
+
'darkYellowFixed',
|
|
47
|
+
'darkOrangeFixed',
|
|
48
|
+
'yellowFixedA',
|
|
49
|
+
'orangeFixedA',
|
|
50
|
+
'darkYellowFixedA',
|
|
51
|
+
'darkOrangeFixedA',
|
|
52
|
+
'white',
|
|
53
|
+
'black'
|
|
54
|
+
];
|
|
5
55
|
const semanticPaletteColors = ['theme', 'success', 'warning', 'error', 'contrast', 'white', 'black', 'purple'];
|
|
56
|
+
const newSemanticPaletteColors = [
|
|
57
|
+
'contrast',
|
|
58
|
+
'contrastA',
|
|
59
|
+
'theme',
|
|
60
|
+
'themeA',
|
|
61
|
+
'error',
|
|
62
|
+
'errorA',
|
|
63
|
+
'warning',
|
|
64
|
+
'warningA',
|
|
65
|
+
'warningFixed',
|
|
66
|
+
'warningFixedA',
|
|
67
|
+
'success',
|
|
68
|
+
'successA',
|
|
69
|
+
'visited',
|
|
70
|
+
'visitedA',
|
|
71
|
+
'darkContrast',
|
|
72
|
+
'darkContrastA',
|
|
73
|
+
'darkTheme',
|
|
74
|
+
'darkThemeA',
|
|
75
|
+
'darkError',
|
|
76
|
+
'darkErrorA',
|
|
77
|
+
'darkWarning',
|
|
78
|
+
'darkWarningA',
|
|
79
|
+
'darkWarningFixed',
|
|
80
|
+
'darkWarningFixedA',
|
|
81
|
+
'darkSuccess',
|
|
82
|
+
'darkSuccessA',
|
|
83
|
+
'darkVisited',
|
|
84
|
+
'darkVisitedA'
|
|
85
|
+
];
|
|
6
86
|
|
|
7
87
|
// resolve components path if script used externally
|
|
8
88
|
const componentsPath = fs.existsSync(path.join('node_modules', '@koobiq/design-tokens', 'web', 'components'))
|
|
@@ -51,6 +131,13 @@ const paletteByColorsConfig = paletteColors.map((color) => ({
|
|
|
51
131
|
prefix: 'kbq'
|
|
52
132
|
}));
|
|
53
133
|
|
|
134
|
+
const newPaletteByColorsConfig = newPaletteColors.map((color) => ({
|
|
135
|
+
destination: `css/new/palette/${color}.css`,
|
|
136
|
+
format: 'kbq-css/variables',
|
|
137
|
+
filter: (token) => token.attributes.category === 'plt' && token.attributes.type === color,
|
|
138
|
+
prefix: 'kbq'
|
|
139
|
+
}));
|
|
140
|
+
|
|
54
141
|
const semanticPaletteConfig = semanticPaletteColors.map((color) => ({
|
|
55
142
|
destination: `css/semantic-palette/${color}.css`,
|
|
56
143
|
format: 'kbq-css/palette',
|
|
@@ -59,7 +146,20 @@ const semanticPaletteConfig = semanticPaletteColors.map((color) => ({
|
|
|
59
146
|
token.attributes.light &&
|
|
60
147
|
token.attributes.type === color &&
|
|
61
148
|
(token.attributes.palette || token.name.includes('default')),
|
|
62
|
-
prefix: 'kbq'
|
|
149
|
+
prefix: 'kbq',
|
|
150
|
+
options: {
|
|
151
|
+
outputReferences: true
|
|
152
|
+
}
|
|
153
|
+
}));
|
|
154
|
+
|
|
155
|
+
const newSemanticPaletteConfig = newSemanticPaletteColors.map((color) => ({
|
|
156
|
+
destination: `css/new/semantic-palette/${color}.css`,
|
|
157
|
+
format: 'kbq-css/palette',
|
|
158
|
+
filter: (token) => token.attributes.category === 'semantic' && token.attributes.type === color,
|
|
159
|
+
prefix: 'kbq',
|
|
160
|
+
options: {
|
|
161
|
+
outputReferences: true
|
|
162
|
+
}
|
|
63
163
|
}));
|
|
64
164
|
|
|
65
165
|
module.exports = {
|
|
@@ -67,6 +167,7 @@ module.exports = {
|
|
|
67
167
|
transformGroup: 'kbq/css',
|
|
68
168
|
files: [
|
|
69
169
|
...semanticPaletteConfig,
|
|
170
|
+
...newSemanticPaletteConfig,
|
|
70
171
|
{
|
|
71
172
|
destination: 'css/light/semantic-palette.css',
|
|
72
173
|
format: 'kbq-css/palette',
|
|
@@ -79,6 +180,7 @@ module.exports = {
|
|
|
79
180
|
selector: '.kbq-light'
|
|
80
181
|
}
|
|
81
182
|
},
|
|
183
|
+
// deprecated
|
|
82
184
|
{
|
|
83
185
|
destination: 'css/dark/semantic-palette.css',
|
|
84
186
|
format: 'kbq-css/palette',
|
|
@@ -100,7 +202,8 @@ module.exports = {
|
|
|
100
202
|
!semanticPaletteColors.includes(token.attributes.type),
|
|
101
203
|
prefix: 'kbq',
|
|
102
204
|
options: {
|
|
103
|
-
selector: '.kbq-light'
|
|
205
|
+
selector: '.kbq-light',
|
|
206
|
+
outputReferences: true
|
|
104
207
|
}
|
|
105
208
|
},
|
|
106
209
|
{
|
|
@@ -112,7 +215,8 @@ module.exports = {
|
|
|
112
215
|
!semanticPaletteColors.includes(token.attributes.type),
|
|
113
216
|
prefix: 'kbq',
|
|
114
217
|
options: {
|
|
115
|
-
selector: '.kbq-dark'
|
|
218
|
+
selector: '.kbq-dark',
|
|
219
|
+
outputReferences: true
|
|
116
220
|
}
|
|
117
221
|
},
|
|
118
222
|
{
|
|
@@ -137,12 +241,28 @@ module.exports = {
|
|
|
137
241
|
}
|
|
138
242
|
},
|
|
139
243
|
...paletteByColorsConfig,
|
|
244
|
+
...newPaletteByColorsConfig,
|
|
140
245
|
{
|
|
141
246
|
destination: 'css/palette.css',
|
|
142
247
|
format: 'kbq-css/variables',
|
|
143
248
|
filter: (token) => token.attributes.category === 'palette',
|
|
144
249
|
prefix: 'kbq'
|
|
145
250
|
},
|
|
251
|
+
{
|
|
252
|
+
destination: 'css/new/palette.css',
|
|
253
|
+
format: 'kbq-css/variables',
|
|
254
|
+
filter: (token) => token.attributes.category === 'plt',
|
|
255
|
+
prefix: 'kbq'
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
destination: 'css/new/semantic-palette.css',
|
|
259
|
+
format: 'kbq-css/variables',
|
|
260
|
+
filter: (token) => token.attributes.category === 'semantic',
|
|
261
|
+
prefix: 'kbq',
|
|
262
|
+
options: {
|
|
263
|
+
outputReferences: true
|
|
264
|
+
}
|
|
265
|
+
},
|
|
146
266
|
{
|
|
147
267
|
destination: 'css/light/shadows.css',
|
|
148
268
|
format: 'kbq-css/variables',
|
package/formats/variables.js
CHANGED
|
@@ -16,6 +16,7 @@ module.exports = (StyleDictionary) => {
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
dictionary.allTokens.forEach((token) => {
|
|
19
|
+
if (['plt', 'semantic'].includes(token.attributes.category)) return;
|
|
19
20
|
token.name = token.name.replace(/(light|dark)-/, '');
|
|
20
21
|
});
|
|
21
22
|
|
|
@@ -41,6 +42,7 @@ module.exports = (StyleDictionary) => {
|
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
dictionary.allTokens.forEach((token) => {
|
|
45
|
+
if (['plt', 'semantic'].includes(token.attributes.category)) return;
|
|
44
46
|
token.name = token.name.replace(/(light|dark)-/, '');
|
|
45
47
|
token.name = token.name.replace(/"/g, '');
|
|
46
48
|
});
|
package/package.json
CHANGED
package/transformGroups/css.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports = (StyleDictionary) => {
|
|
2
|
+
StyleDictionary.registerTransform({
|
|
3
|
+
name: 'name/custom-kebab',
|
|
4
|
+
type: 'name',
|
|
5
|
+
transformer: (token) => {
|
|
6
|
+
const standardKebab = token.path
|
|
7
|
+
.map((part) =>
|
|
8
|
+
part
|
|
9
|
+
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
10
|
+
.replace(/"/g, '')
|
|
11
|
+
.toLowerCase()
|
|
12
|
+
)
|
|
13
|
+
.join('-');
|
|
14
|
+
|
|
15
|
+
// for alpha colors, remove the dash between 'a' and the index
|
|
16
|
+
return standardKebab.replace(/-a-(\d+)$/, '-a$1');
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|