@koobiq/tokens-builder 3.20.1 → 4.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/actions/css-index.js +3 -3
- package/build.js +72 -41
- package/configs/css.js +228 -158
- package/configs/index.js +23 -10
- package/configs/js.js +11 -4
- package/configs/scss.js +2 -7
- package/filters/has-value.js +24 -0
- package/filters/md-typography.js +2 -2
- package/filters/typography.js +2 -2
- package/formats/component.js +57 -0
- package/formats/strip-theme.js +28 -0
- package/formats/typography.js +28 -29
- package/formats/variables.js +8 -46
- package/package.json +8 -1
- package/preprocessors/expand-typography.js +114 -0
- package/transformGroups/css.js +7 -19
- package/transformGroups/scss.js +3 -3
- package/transformGroups/ts.js +9 -9
- package/transforms/attribute/deprecation-comment.js +14 -5
- package/transforms/attribute/font.js +3 -3
- package/transforms/attribute/md-typography.js +3 -3
- package/transforms/attribute/scss-value.js +5 -6
- package/transforms/attribute/theme.js +5 -5
- package/transforms/attribute/typography.js +3 -3
- package/transforms/name/custom-kebab.js +6 -13
- package/configs/css-new.js +0 -228
- package/filters/color.js +0 -6
- package/filters/css-variables.js +0 -30
- package/filters/palette.js +0 -6
- package/formats/palette.js +0 -10
- package/formats/utils.js +0 -35
- package/transforms/attribute/palette.js +0 -8
- package/transforms/attribute/prefix.js +0 -11
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
export default (StyleDictionary) => {
|
|
2
2
|
StyleDictionary.registerTransform({
|
|
3
3
|
name: 'kbq-scss/value',
|
|
4
4
|
type: 'value',
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return token.value;
|
|
5
|
+
transform: (token, _platform, options) => {
|
|
6
|
+
const value = options?.usesDtcg ? token.$value : token.value;
|
|
7
|
+
|
|
8
|
+
return value === '' ? null : value;
|
|
10
9
|
}
|
|
11
10
|
});
|
|
12
11
|
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
export default (StyleDictionary) => {
|
|
2
2
|
StyleDictionary.registerTransform({
|
|
3
3
|
name: 'kbq-attribute/light',
|
|
4
4
|
type: 'attribute',
|
|
5
|
-
|
|
5
|
+
filter: ({ attributes }) => {
|
|
6
6
|
return (
|
|
7
7
|
(attributes.category === 'markdown' && attributes.item === 'light') ||
|
|
8
8
|
attributes.type === 'light' ||
|
|
9
9
|
attributes.category === 'light'
|
|
10
10
|
);
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
transform: () => ({ light: true })
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
StyleDictionary.registerTransform({
|
|
16
16
|
name: 'kbq-attribute/dark',
|
|
17
17
|
type: 'attribute',
|
|
18
|
-
|
|
18
|
+
filter: ({ attributes }) => {
|
|
19
19
|
return (
|
|
20
20
|
(attributes.category === 'markdown' && attributes.item === 'dark') ||
|
|
21
21
|
attributes.type === 'dark' ||
|
|
22
22
|
attributes.category === 'dark'
|
|
23
23
|
);
|
|
24
24
|
},
|
|
25
|
-
|
|
25
|
+
transform: () => ({ dark: true })
|
|
26
26
|
});
|
|
27
27
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
export default (StyleDictionary) => {
|
|
2
2
|
StyleDictionary.registerTransform({
|
|
3
3
|
name: 'kbq-attribute/typography',
|
|
4
4
|
type: 'attribute',
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
filter: (token) => token.attributes.category === 'typography',
|
|
6
|
+
transform: () => ({ typography: true })
|
|
7
7
|
});
|
|
8
8
|
};
|
|
@@ -13,27 +13,20 @@ const toKebab = (path) => {
|
|
|
13
13
|
return standardKebab.replace(/-a-(\d+)$/, '-a$1');
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
export default (StyleDictionary) => {
|
|
17
|
+
// Strips 'light'/'dark' when used as the category segment (e.g. shadow.light.card →
|
|
18
|
+
// shadow-card), so theme-scoped tokens don't carry the theme in their variable name —
|
|
19
|
+
// the theme lives in the `.kbq-light` / `.kbq-dark` selector instead.
|
|
17
20
|
StyleDictionary.registerTransform({
|
|
18
21
|
name: 'name/custom-kebab',
|
|
19
22
|
type: 'name',
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Same as custom-kebab but strips 'light'/'dark' when used as the type
|
|
24
|
-
// segment (e.g. shadow.light.card → shadow-card).
|
|
25
|
-
// Used for the new palette output so theme-scoped shadows don't carry
|
|
26
|
-
// the theme prefix in their variable name.
|
|
27
|
-
StyleDictionary.registerTransform({
|
|
28
|
-
name: 'name/custom-kebab-strip-theme',
|
|
29
|
-
type: 'name',
|
|
30
|
-
transformer: (token) => {
|
|
23
|
+
transform: (token, platform) => {
|
|
31
24
|
const path =
|
|
32
25
|
token.attributes.category === 'light' || token.attributes.category === 'dark'
|
|
33
26
|
? token.path.filter((part) => part !== 'light' && part !== 'dark')
|
|
34
27
|
: token.path;
|
|
35
28
|
|
|
36
|
-
return toKebab(path);
|
|
29
|
+
return toKebab(platform?.prefix ? [platform.prefix, ...path] : path);
|
|
37
30
|
}
|
|
38
31
|
});
|
|
39
32
|
};
|
package/configs/css-new.js
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
const semanticPaletteColors = ['theme', 'success', 'warning', 'error', 'contrast', 'white', 'black', 'purple'];
|
|
2
|
-
const newPaletteColors = [
|
|
3
|
-
'blue',
|
|
4
|
-
'slate',
|
|
5
|
-
'red',
|
|
6
|
-
'orange',
|
|
7
|
-
'yellow',
|
|
8
|
-
'green',
|
|
9
|
-
'teal',
|
|
10
|
-
'purple',
|
|
11
|
-
'darkBlue',
|
|
12
|
-
'darkSlate',
|
|
13
|
-
'darkRed',
|
|
14
|
-
'darkOrange',
|
|
15
|
-
'darkYellow',
|
|
16
|
-
'darkGreen',
|
|
17
|
-
'darkTeal',
|
|
18
|
-
'darkPurple',
|
|
19
|
-
'grey',
|
|
20
|
-
'darkGrey',
|
|
21
|
-
'greyA',
|
|
22
|
-
'darkGreyA',
|
|
23
|
-
'whiteA',
|
|
24
|
-
'blackA',
|
|
25
|
-
'blueA',
|
|
26
|
-
'slateA',
|
|
27
|
-
'redA',
|
|
28
|
-
'orangeA',
|
|
29
|
-
'yellowA',
|
|
30
|
-
'greenA',
|
|
31
|
-
'tealA',
|
|
32
|
-
'purpleA',
|
|
33
|
-
'darkBlueA',
|
|
34
|
-
'darkSlateA',
|
|
35
|
-
'darkRedA',
|
|
36
|
-
'darkOrangeA',
|
|
37
|
-
'darkYellowA',
|
|
38
|
-
'darkGreenA',
|
|
39
|
-
'darkTealA',
|
|
40
|
-
'darkPurpleA',
|
|
41
|
-
'yellowFixed',
|
|
42
|
-
'orangeFixed',
|
|
43
|
-
'darkYellowFixed',
|
|
44
|
-
'darkOrangeFixed',
|
|
45
|
-
'yellowFixedA',
|
|
46
|
-
'orangeFixedA',
|
|
47
|
-
'darkYellowFixedA',
|
|
48
|
-
'darkOrangeFixedA',
|
|
49
|
-
'white',
|
|
50
|
-
'black'
|
|
51
|
-
];
|
|
52
|
-
const newSemanticPaletteColors = [
|
|
53
|
-
'contrast',
|
|
54
|
-
'contrastA',
|
|
55
|
-
'theme',
|
|
56
|
-
'themeA',
|
|
57
|
-
'error',
|
|
58
|
-
'errorA',
|
|
59
|
-
'warning',
|
|
60
|
-
'warningA',
|
|
61
|
-
'warningFixed',
|
|
62
|
-
'warningFixedA',
|
|
63
|
-
'success',
|
|
64
|
-
'successA',
|
|
65
|
-
'visited',
|
|
66
|
-
'visitedA',
|
|
67
|
-
'darkContrast',
|
|
68
|
-
'darkContrastA',
|
|
69
|
-
'darkTheme',
|
|
70
|
-
'darkThemeA',
|
|
71
|
-
'darkError',
|
|
72
|
-
'darkErrorA',
|
|
73
|
-
'darkWarning',
|
|
74
|
-
'darkWarningA',
|
|
75
|
-
'darkWarningFixed',
|
|
76
|
-
'darkWarningFixedA',
|
|
77
|
-
'darkSuccess',
|
|
78
|
-
'darkSuccessA',
|
|
79
|
-
'darkVisited',
|
|
80
|
-
'darkVisitedA'
|
|
81
|
-
];
|
|
82
|
-
|
|
83
|
-
const newPaletteByColorsConfig = newPaletteColors.map((color) => ({
|
|
84
|
-
destination: `palette/${color}.css`,
|
|
85
|
-
format: 'kbq-css/variables',
|
|
86
|
-
filter: (token) => token.attributes.category === 'plt' && token.attributes.type === color,
|
|
87
|
-
prefix: 'kbq'
|
|
88
|
-
}));
|
|
89
|
-
|
|
90
|
-
const newSemanticPaletteConfig = newSemanticPaletteColors.map((color) => ({
|
|
91
|
-
destination: `semantic-palette/${color}.css`,
|
|
92
|
-
format: 'kbq-css/palette',
|
|
93
|
-
filter: (token) => token.attributes.category === 'semantic' && token.attributes.type === color,
|
|
94
|
-
prefix: 'kbq',
|
|
95
|
-
options: {
|
|
96
|
-
outputReferences: true
|
|
97
|
-
}
|
|
98
|
-
}));
|
|
99
|
-
|
|
100
|
-
module.exports = {
|
|
101
|
-
css: {
|
|
102
|
-
transformGroup: 'kbq/css-new',
|
|
103
|
-
actions: ['kbq/css-index'],
|
|
104
|
-
// OKLch entry point. Font/size/typography are color-agnostic and identical across tracks,
|
|
105
|
-
// so they are pulled from the sibling web/css track (../css) instead of being duplicated
|
|
106
|
-
// here. Per-color palette/semantic-palette splits are omitted since their variables are
|
|
107
|
-
// already covered by the aggregate palette.css / semantic-palette.css.
|
|
108
|
-
index: {
|
|
109
|
-
dir: '',
|
|
110
|
-
files: [
|
|
111
|
-
'../css/font.css',
|
|
112
|
-
'../css/size.css',
|
|
113
|
-
'../css/typography.css',
|
|
114
|
-
'../css/md-typography.css',
|
|
115
|
-
'palette.css',
|
|
116
|
-
'semantic-palette.css',
|
|
117
|
-
'light/semantic-colors.css',
|
|
118
|
-
'light/shadows.css',
|
|
119
|
-
'dark/semantic-colors.css',
|
|
120
|
-
'dark/shadows.css'
|
|
121
|
-
]
|
|
122
|
-
},
|
|
123
|
-
files: [
|
|
124
|
-
...newSemanticPaletteConfig,
|
|
125
|
-
...newPaletteByColorsConfig,
|
|
126
|
-
{
|
|
127
|
-
destination: 'palette.css',
|
|
128
|
-
format: 'kbq-css/variables',
|
|
129
|
-
filter: (token) => token.attributes.category === 'plt',
|
|
130
|
-
prefix: 'kbq'
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
destination: 'semantic-palette.css',
|
|
134
|
-
format: 'kbq-css/variables',
|
|
135
|
-
filter: (token) => token.attributes.category === 'semantic',
|
|
136
|
-
prefix: 'kbq',
|
|
137
|
-
options: {
|
|
138
|
-
outputReferences: true
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
destination: 'light/shadows.css',
|
|
143
|
-
format: 'kbq-css/variables',
|
|
144
|
-
filter: (token) => token.attributes.light && token.attributes.category === 'shadow',
|
|
145
|
-
prefix: 'kbq',
|
|
146
|
-
options: {
|
|
147
|
-
selector: '.kbq-light',
|
|
148
|
-
outputReferences: true
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
destination: 'light/semantic-colors.css',
|
|
153
|
-
format: 'kbq-css/variables',
|
|
154
|
-
filter: (token) =>
|
|
155
|
-
token.attributes.light &&
|
|
156
|
-
token.filePath.includes('colors.v2.json5') &&
|
|
157
|
-
!semanticPaletteColors.includes(token.attributes.type),
|
|
158
|
-
prefix: 'kbq',
|
|
159
|
-
options: {
|
|
160
|
-
selector: '.kbq-light',
|
|
161
|
-
outputReferences: true
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
destination: 'dark/shadows.css',
|
|
166
|
-
format: 'kbq-css/variables',
|
|
167
|
-
filter: (token) => token.attributes.dark && token.attributes.category === 'shadow',
|
|
168
|
-
prefix: 'kbq',
|
|
169
|
-
options: {
|
|
170
|
-
selector: '.kbq-dark',
|
|
171
|
-
outputReferences: true
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
destination: 'dark/semantic-colors.css',
|
|
176
|
-
format: 'kbq-css/variables',
|
|
177
|
-
filter: (token) =>
|
|
178
|
-
token.attributes.dark &&
|
|
179
|
-
token.filePath.includes('colors.v2.json5') &&
|
|
180
|
-
!semanticPaletteColors.includes(token.attributes.type),
|
|
181
|
-
prefix: 'kbq',
|
|
182
|
-
options: {
|
|
183
|
-
selector: '.kbq-dark',
|
|
184
|
-
outputReferences: true
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
destination: 'css-tokens.css',
|
|
189
|
-
format: 'css/variables',
|
|
190
|
-
filter: (token) =>
|
|
191
|
-
!token.attributes.font &&
|
|
192
|
-
!token.attributes.palette &&
|
|
193
|
-
!token.attributes.light &&
|
|
194
|
-
!token.attributes.dark &&
|
|
195
|
-
token.type !== 'font' &&
|
|
196
|
-
token.attributes.category !== 'palette',
|
|
197
|
-
prefix: 'kbq',
|
|
198
|
-
options: {
|
|
199
|
-
outputReferences: true
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
destination: 'css-tokens-light.css',
|
|
204
|
-
format: 'kbq-css/variables',
|
|
205
|
-
filter: (token) =>
|
|
206
|
-
token.attributes.light &&
|
|
207
|
-
!token.attributes.palette &&
|
|
208
|
-
!semanticPaletteColors.includes(token.attributes.type),
|
|
209
|
-
prefix: 'kbq',
|
|
210
|
-
options: {
|
|
211
|
-
selector: '.kbq-light'
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
destination: 'css-tokens-dark.css',
|
|
216
|
-
format: 'kbq-css/variables',
|
|
217
|
-
filter: (token) =>
|
|
218
|
-
token.attributes.dark &&
|
|
219
|
-
!token.attributes.palette &&
|
|
220
|
-
!semanticPaletteColors.includes(token.attributes.type),
|
|
221
|
-
prefix: 'kbq',
|
|
222
|
-
options: {
|
|
223
|
-
selector: '.kbq-dark'
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
]
|
|
227
|
-
}
|
|
228
|
-
};
|
package/filters/color.js
DELETED
package/filters/css-variables.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module.exports = (StyleDictionary) => {
|
|
2
|
-
StyleDictionary.registerFilter({
|
|
3
|
-
name: 'css-variables',
|
|
4
|
-
matcher: (prop) => {
|
|
5
|
-
return (
|
|
6
|
-
!prop.attributes.font &&
|
|
7
|
-
!prop.attributes.palette &&
|
|
8
|
-
!prop.attributes.light &&
|
|
9
|
-
!prop.attributes.dark &&
|
|
10
|
-
!prop.attributes.font &&
|
|
11
|
-
prop.type !== 'font'
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
StyleDictionary.registerFilter({
|
|
17
|
-
name: 'css-variables-light',
|
|
18
|
-
matcher: (prop) => prop.attributes.light && !prop.attributes.palette
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
StyleDictionary.registerFilter({
|
|
22
|
-
name: 'css-variables-dark',
|
|
23
|
-
matcher: (prop) => prop.attributes.dark && !prop.attributes.palette
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
StyleDictionary.registerFilter({
|
|
27
|
-
name: 'css-variables-font',
|
|
28
|
-
matcher: (prop) => prop.attributes.font || prop.type === 'font'
|
|
29
|
-
});
|
|
30
|
-
};
|
package/filters/palette.js
DELETED
package/formats/palette.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const { getMapFromObj } = require('../formats/utils');
|
|
2
|
-
|
|
3
|
-
module.exports = (StyleDictionary) => {
|
|
4
|
-
StyleDictionary.registerFormat({
|
|
5
|
-
name: 'kbq-scss/palette',
|
|
6
|
-
formatter: function (dictionary) {
|
|
7
|
-
return dictionary.allProperties.map((prop) => `\$${prop.name}: ${getMapFromObj(prop.value)};\n`).join('\n');
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
};
|
package/formats/utils.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const transform = require('style-dictionary/lib/common/transforms');
|
|
2
|
-
|
|
3
|
-
const unwrapObjectTransformer = (token, additionalAttrs = {}) => {
|
|
4
|
-
return Object.keys(token.value).map((key) => {
|
|
5
|
-
const subToken = token.value[key];
|
|
6
|
-
const res = {
|
|
7
|
-
...subToken,
|
|
8
|
-
filePath: token.filePath,
|
|
9
|
-
path: [...token.path, key],
|
|
10
|
-
name: `kbq-${[...token.path, key].join('-')}`,
|
|
11
|
-
original: { value: subToken }
|
|
12
|
-
};
|
|
13
|
-
res.attributes = { ...transform['attribute/cti'].transformer(res), ...additionalAttrs };
|
|
14
|
-
return res;
|
|
15
|
-
}, {});
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const getMapFromObj = (object) => {
|
|
19
|
-
const result = Object.keys(object)
|
|
20
|
-
.map((key) => {
|
|
21
|
-
if (key === 'contrast') {
|
|
22
|
-
return `${key}: ${getMapFromObj(object[key])}`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return `${key}: ${object[key].value},\n`;
|
|
26
|
-
})
|
|
27
|
-
.join('');
|
|
28
|
-
|
|
29
|
-
return `(\n${result}\n)`;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
module.exports = {
|
|
33
|
-
unwrapObjectTransformer,
|
|
34
|
-
getMapFromObj
|
|
35
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
module.exports = (StyleDictionary) => {
|
|
2
|
-
StyleDictionary.registerTransform({
|
|
3
|
-
name: 'kbq/prefix',
|
|
4
|
-
type: 'attribute',
|
|
5
|
-
transformer: (prop, options) => {
|
|
6
|
-
const prefix = options.files[0].prefix ? `${options.files[0].prefix}-` : '';
|
|
7
|
-
|
|
8
|
-
prop.name = `${prefix}${prop.name}`;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
};
|