@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 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
- destination: 'css-tokens.css',
6
- format: 'css/variables',
7
- filter: 'css-variables',
8
- prefix: 'kbq'
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
  };
@@ -1,6 +1,24 @@
1
1
  module.exports = (StyleDictionary) => {
2
2
  StyleDictionary.registerFilter({
3
3
  name: 'css-variables',
4
- matcher: (prop) => !prop.attributes.font && !prop.attributes.palette
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
@@ -19,5 +19,5 @@
19
19
  "default": "./*"
20
20
  }
21
21
  },
22
- "version": "3.0.0-rc.7"
22
+ "version": "3.0.0-rc.9"
23
23
  }
@@ -6,6 +6,8 @@ module.exports = (StyleDictionary) => {
6
6
  'attribute/cti',
7
7
  'kbq-attribute/palette',
8
8
  'kbq-attribute/font',
9
+ 'kbq-attribute/light',
10
+ 'kbq-attribute/dark',
9
11
  'name/cti/kebab',
10
12
  'color/css',
11
13
  'kbq/prefix'
@@ -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
+ };