@koobiq/tokens-builder 3.0.0-rc.7 → 3.0.0-rc.9
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 +2 -0
- package/configs/css.js +35 -6
- package/filters/css-variables.js +19 -1
- package/formats/variables.js +19 -0
- package/package.json +1 -1
- package/transformGroups/css.js +2 -0
- package/transforms/attribute/theme.js +19 -0
package/build.js
CHANGED
|
@@ -7,6 +7,7 @@ require('./transforms/attribute/typography')(StyleDictionary);
|
|
|
7
7
|
require('./transforms/attribute/palette')(StyleDictionary);
|
|
8
8
|
require('./transforms/attribute/prefix')(StyleDictionary);
|
|
9
9
|
require('./transforms/attribute/font')(StyleDictionary);
|
|
10
|
+
require('./transforms/attribute/theme')(StyleDictionary);
|
|
10
11
|
|
|
11
12
|
// ==== Include custom filters ====
|
|
12
13
|
require('./filters/palette')(StyleDictionary);
|
|
@@ -23,6 +24,7 @@ require('./transformGroups/ts')(StyleDictionary);
|
|
|
23
24
|
// ==== Include custom formats ====
|
|
24
25
|
require('./formats/typography')(StyleDictionary);
|
|
25
26
|
require('./formats/palette')(StyleDictionary);
|
|
27
|
+
require('./formats/variables')(StyleDictionary);
|
|
26
28
|
|
|
27
29
|
// ==== Run build ====
|
|
28
30
|
console.log('Build started...');
|
package/configs/css.js
CHANGED
|
@@ -1,11 +1,40 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
css: {
|
|
3
3
|
transformGroup: 'kbq/css',
|
|
4
|
-
files: [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
files: [
|
|
5
|
+
{
|
|
6
|
+
destination: 'css-tokens.css',
|
|
7
|
+
format: 'css/variables',
|
|
8
|
+
filter: 'css-variables',
|
|
9
|
+
prefix: 'kbq'
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
destination: 'css-tokens-light.css',
|
|
13
|
+
format: 'kbq-css/variables',
|
|
14
|
+
filter: 'css-variables-light',
|
|
15
|
+
prefix: 'kbq',
|
|
16
|
+
options: {
|
|
17
|
+
selector: '.kbq-light'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
destination: 'css-tokens-dark.css',
|
|
22
|
+
format: 'kbq-css/variables',
|
|
23
|
+
filter: 'css-variables-dark',
|
|
24
|
+
prefix: 'kbq',
|
|
25
|
+
options: {
|
|
26
|
+
selector: '.kbq-dark'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
destination: 'css-tokens-font.css',
|
|
31
|
+
format: 'kbq-css/variables',
|
|
32
|
+
filter: 'css-variables-font',
|
|
33
|
+
prefix: 'kbq',
|
|
34
|
+
options: {
|
|
35
|
+
selector: '.kbq-font'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
]
|
|
10
39
|
}
|
|
11
40
|
};
|
package/filters/css-variables.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
module.exports = (StyleDictionary) => {
|
|
2
2
|
StyleDictionary.registerFilter({
|
|
3
3
|
name: 'css-variables',
|
|
4
|
-
matcher: (prop) =>
|
|
4
|
+
matcher: (prop) => {
|
|
5
|
+
return !prop.attributes.font &&!prop.attributes.palette && !prop.attributes.light &&
|
|
6
|
+
!prop.attributes.dark && !prop.attributes.font
|
|
7
|
+
}
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
StyleDictionary.registerFilter({
|
|
11
|
+
name: 'css-variables-light',
|
|
12
|
+
matcher: (prop) => prop.attributes.light
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
StyleDictionary.registerFilter({
|
|
16
|
+
name: 'css-variables-dark',
|
|
17
|
+
matcher: (prop) => prop.attributes.dark
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
StyleDictionary.registerFilter({
|
|
21
|
+
name: 'css-variables-font',
|
|
22
|
+
matcher: (prop) => prop.attributes.font
|
|
5
23
|
})
|
|
6
24
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const { formatHelpers } = require('style-dictionary');
|
|
2
|
+
|
|
3
|
+
module.exports = (StyleDictionary) => {
|
|
4
|
+
StyleDictionary.registerFormat({
|
|
5
|
+
name: 'kbq-css/variables',
|
|
6
|
+
formatter: function({dictionary, options={}, file}) {
|
|
7
|
+
const selector = options.selector ? options.selector : `:root`;
|
|
8
|
+
const { outputReferences } = options;
|
|
9
|
+
|
|
10
|
+
dictionary.allTokens.forEach((token) => {
|
|
11
|
+
token.name = token.name.replace(/(light|dark)-/, '');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
return formatHelpers.fileHeader({file}) +
|
|
15
|
+
`${selector} {\n` +
|
|
16
|
+
formatHelpers.formattedVariables({ format: 'css', dictionary, outputReferences }) +
|
|
17
|
+
`\n}\n`;
|
|
18
|
+
} })
|
|
19
|
+
};
|
package/package.json
CHANGED
package/transformGroups/css.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports = (StyleDictionary) => {
|
|
2
|
+
StyleDictionary.registerTransform({
|
|
3
|
+
name: 'kbq-attribute/light',
|
|
4
|
+
type: 'attribute',
|
|
5
|
+
matcher: ({ attributes }) => {
|
|
6
|
+
return (attributes.category === 'markdown' && attributes.item === 'light') || attributes.type === 'light';
|
|
7
|
+
},
|
|
8
|
+
transformer: () => ({ light: true })
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
StyleDictionary.registerTransform({
|
|
12
|
+
name: 'kbq-attribute/dark',
|
|
13
|
+
type: 'attribute',
|
|
14
|
+
matcher: ({ attributes }) => {
|
|
15
|
+
return (attributes.category === 'markdown' && attributes.item === 'dark') || attributes.type === 'dark';
|
|
16
|
+
},
|
|
17
|
+
transformer: () => ({ dark: true })
|
|
18
|
+
});
|
|
19
|
+
};
|