@koobiq/tokens-builder 3.0.0-beta.9 → 3.0.0-rc.10
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/LICENSE +1 -1
- package/README.md +8 -0
- package/build.js +4 -2
- package/configs/css.js +35 -6
- package/configs/js.js +1 -1
- package/filters/css-variables.js +24 -0
- package/formats/variables.js +19 -0
- package/package.json +1 -4
- package/transformGroups/css.js +4 -1
- package/transforms/attribute/font.js +10 -0
- package/transforms/attribute/theme.js +19 -0
- package/filters/size.js +0 -7
- package/transforms/attribute/size.js +0 -8
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
# Tokens Builder
|
|
2
2
|
|
|
3
|
+
## Overview
|
|
4
|
+
Tokens builder is a configuration script that utilizes Style Dictionary,
|
|
5
|
+
a design-token platform for creating and maintaining consistent design tokens across various platforms.
|
|
6
|
+
|
|
7
|
+
Overall, this script orchestrates the generation of design tokens by applying custom transformations,
|
|
8
|
+
filters, and formats to the specified theme configuration for multiple platforms,
|
|
9
|
+
facilitating a streamlined design token workflow compatible with
|
|
10
|
+
various output formats like SCSS, CSS, and TypeScript.
|
|
3
11
|
|
package/build.js
CHANGED
|
@@ -6,12 +6,13 @@ require('./transforms/attribute/md-typography')(StyleDictionary);
|
|
|
6
6
|
require('./transforms/attribute/typography')(StyleDictionary);
|
|
7
7
|
require('./transforms/attribute/palette')(StyleDictionary);
|
|
8
8
|
require('./transforms/attribute/prefix')(StyleDictionary);
|
|
9
|
-
require('./transforms/attribute/
|
|
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);
|
|
14
|
+
require('./filters/css-variables')(StyleDictionary);
|
|
13
15
|
require('./filters/color')(StyleDictionary);
|
|
14
|
-
require('./filters/size')(StyleDictionary);
|
|
15
16
|
require('./filters/typography')(StyleDictionary);
|
|
16
17
|
require('./filters/md-typography')(StyleDictionary);
|
|
17
18
|
|
|
@@ -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/configs/js.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module.exports = (StyleDictionary) => {
|
|
2
|
+
StyleDictionary.registerFilter({
|
|
3
|
+
name: 'css-variables',
|
|
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
|
|
23
|
+
})
|
|
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
|
@@ -4,7 +4,10 @@ module.exports = (StyleDictionary) => {
|
|
|
4
4
|
name: 'kbq/css',
|
|
5
5
|
transforms: [
|
|
6
6
|
'attribute/cti',
|
|
7
|
-
'kbq-attribute/
|
|
7
|
+
'kbq-attribute/palette',
|
|
8
|
+
'kbq-attribute/font',
|
|
9
|
+
'kbq-attribute/light',
|
|
10
|
+
'kbq-attribute/dark',
|
|
8
11
|
'name/cti/kebab',
|
|
9
12
|
'color/css',
|
|
10
13
|
'kbq/prefix'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module.exports = (StyleDictionary) => {
|
|
2
|
+
StyleDictionary.registerTransform({
|
|
3
|
+
name: 'kbq-attribute/font',
|
|
4
|
+
type: 'attribute',
|
|
5
|
+
matcher: ({ attributes }) => {
|
|
6
|
+
return (attributes.category === 'markdown' && attributes.item === 'font') || attributes.type === 'font';
|
|
7
|
+
},
|
|
8
|
+
transformer: () => ({ font: true })
|
|
9
|
+
});
|
|
10
|
+
};
|
|
@@ -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
|
+
};
|
package/filters/size.js
DELETED