@koobiq/tokens-builder 3.0.0-rc.9 → 3.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/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # Tokens Builder
2
2
 
3
3
  ## Overview
4
+
4
5
  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
+ a design-token platform for creating and maintaining consistent design tokens across various platforms.
6
7
 
7
8
  Overall, this script orchestrates the generation of design tokens by applying custom transformations,
8
9
  filters, and formats to the specified theme configuration for multiple platforms,
9
10
  facilitating a streamlined design token workflow compatible with
10
11
  various output formats like SCSS, CSS, and TypeScript.
11
-
package/build.js CHANGED
@@ -30,7 +30,6 @@ require('./formats/variables')(StyleDictionary);
30
30
  console.log('Build started...');
31
31
  console.log('==============================================');
32
32
 
33
-
34
33
  module.exports = (themeConfig) => {
35
34
  StyleDictionary.registerFileHeader({
36
35
  name: 'customHeader',
@@ -40,14 +39,14 @@ module.exports = (themeConfig) => {
40
39
 
41
40
  if (!themeConfig || themeConfig.length === 0) {
42
41
  console.error('Build Failed. Please set ThemeConfig, for example: ', {
43
- name: 'default-theme',
44
- buildPath: [
45
- `design-tokens/tokens/properties/**/*.json5`,
46
- `design-tokens/tokens/components/**/*.json5`
47
- ],
48
- outputPath: 'design-tokens/'
49
- }
50
- )
42
+ name: 'default-theme',
43
+ // prettier-ignore
44
+ buildPath: [
45
+ `design-tokens/tokens/properties/**/*.json5`,
46
+ `design-tokens/tokens/components/**/*.json5`
47
+ ],
48
+ outputPath: 'design-tokens/'
49
+ });
51
50
  process.exit(0);
52
51
  }
53
52
 
@@ -63,4 +62,4 @@ module.exports = (themeConfig) => {
63
62
 
64
63
  console.log('\n==============================================');
65
64
  console.log('\nBuild completed!');
66
- }
65
+ };
package/configs/index.js CHANGED
@@ -13,14 +13,14 @@ const filterObj = {
13
13
  function filterOptions(platforms) {
14
14
  const platformObj = {};
15
15
 
16
- platforms.map(p => Object.assign(platformObj, p));
16
+ platforms.map((p) => Object.assign(platformObj, p));
17
17
 
18
18
  Object.keys(platformObj).forEach((p) => {
19
- platformObj[p].files = platformObj[p].files.map(f => ({
19
+ platformObj[p].files = platformObj[p].files.map((f) => ({
20
20
  ...f,
21
21
  ...filterObj,
22
22
  options: {
23
- ...f.options ?? {},
23
+ ...(f.options ?? {}),
24
24
  ...filterObj.options
25
25
  }
26
26
  }));
@@ -30,7 +30,7 @@ function filterOptions(platforms) {
30
30
  }
31
31
 
32
32
  function getSources(theme) {
33
- return theme.buildPath.map(pathName => {
33
+ return theme.buildPath.map((pathName) => {
34
34
  if (pathName.startsWith('@')) {
35
35
  return join('node_modules', pathName);
36
36
  }
@@ -48,7 +48,6 @@ function getConfigs(theme) {
48
48
  }
49
49
 
50
50
  module.exports = (theme) => {
51
-
52
51
  return {
53
52
  source: [...getSources(theme)],
54
53
  platforms: getConfigs(theme)
package/configs/js.js CHANGED
@@ -13,4 +13,3 @@ module.exports = {
13
13
  ]
14
14
  }
15
15
  };
16
-
package/filters/color.js CHANGED
@@ -1,9 +1,6 @@
1
1
  module.exports = (StyleDictionary) => {
2
-
3
2
  StyleDictionary.registerFilter({
4
3
  name: 'color',
5
- matcher: (prop) => !prop.attributes.palette &&
6
- !prop.attributes.typography &&
7
- !prop.attributes['md-typography']
8
- })
9
- }
4
+ matcher: (prop) => !prop.attributes.palette && !prop.attributes.typography && !prop.attributes['md-typography']
5
+ });
6
+ };
@@ -2,23 +2,28 @@ module.exports = (StyleDictionary) => {
2
2
  StyleDictionary.registerFilter({
3
3
  name: 'css-variables',
4
4
  matcher: (prop) => {
5
- return !prop.attributes.font &&!prop.attributes.palette && !prop.attributes.light &&
6
- !prop.attributes.dark && !prop.attributes.font
5
+ return (
6
+ !prop.attributes.font &&
7
+ !prop.attributes.palette &&
8
+ !prop.attributes.light &&
9
+ !prop.attributes.dark &&
10
+ !prop.attributes.font
11
+ );
7
12
  }
8
- })
13
+ });
9
14
 
10
15
  StyleDictionary.registerFilter({
11
16
  name: 'css-variables-light',
12
17
  matcher: (prop) => prop.attributes.light
13
- })
18
+ });
14
19
 
15
20
  StyleDictionary.registerFilter({
16
21
  name: 'css-variables-dark',
17
22
  matcher: (prop) => prop.attributes.dark
18
- })
23
+ });
19
24
 
20
25
  StyleDictionary.registerFilter({
21
26
  name: 'css-variables-font',
22
27
  matcher: (prop) => prop.attributes.font
23
- })
24
- }
28
+ });
29
+ };
@@ -1,7 +1,6 @@
1
1
  module.exports = (StyleDictionary) => {
2
-
3
2
  StyleDictionary.registerFilter({
4
3
  name: 'md-typography',
5
4
  matcher: (prop) => prop.attributes['md-typography']
6
- })
7
- }
5
+ });
6
+ };
@@ -1,7 +1,6 @@
1
1
  module.exports = (StyleDictionary) => {
2
-
3
2
  StyleDictionary.registerFilter({
4
3
  name: 'palette',
5
4
  matcher: (prop) => prop.attributes.palette
6
- })
7
- }
5
+ });
6
+ };
@@ -1,7 +1,6 @@
1
1
  module.exports = (StyleDictionary) => {
2
-
3
2
  StyleDictionary.registerFilter({
4
3
  name: 'typography',
5
4
  matcher: (prop) => prop.attributes.typography
6
- })
7
- }
5
+ });
6
+ };
@@ -1,25 +1,22 @@
1
-
2
1
  module.exports = (StyleDictionary) => {
3
2
  StyleDictionary.registerFormat({
4
3
  name: 'kbq-scss/palette',
5
4
  formatter: function (dictionary) {
6
- return dictionary.allProperties
7
- .map((prop) => `\$${prop.name}: ${getMapFromObj(prop.value)};\n`)
8
- .join('\n');
5
+ return dictionary.allProperties.map((prop) => `\$${prop.name}: ${getMapFromObj(prop.value)};\n`).join('\n');
9
6
  }
10
- })
7
+ });
11
8
  };
12
9
 
13
10
  function getMapFromObj(object) {
14
11
  const result = Object.keys(object)
15
12
  .map((key) => {
16
13
  if (key === 'contrast') {
17
- return `${key}: ${getMapFromObj(object[key])}`
14
+ return `${key}: ${getMapFromObj(object[key])}`;
18
15
  }
19
16
 
20
- return `${key}: ${object[key].value},\n`
17
+ return `${key}: ${object[key].value},\n`;
21
18
  })
22
19
  .join('');
23
20
 
24
- return `(\n${result}\n)`
21
+ return `(\n${result}\n)`;
25
22
  }
@@ -1,45 +1,45 @@
1
1
  module.exports = (StyleDictionary) => {
2
-
3
2
  StyleDictionary.registerFormat({
4
3
  name: 'kbq-scss/typography',
5
- formatter: function(dictionary) {
4
+ formatter: function (dictionary) {
6
5
  let string;
7
6
 
8
7
  string = dictionary.allProperties
9
8
  .map((prop) => {
10
9
  let output = '';
11
10
 
12
- const value = prop.attributes.category === 'asset' ? `"${ prop.value }"` : prop.value;
11
+ const value = prop.attributes.category === 'asset' ? `"${prop.value}"` : prop.value;
13
12
 
14
- output += `$${ prop.name }: ${ value };`
13
+ output += `$${prop.name}: ${value};`;
15
14
 
16
15
  if (prop.comment) {
17
- output += ` // ${ prop.comment }`;
16
+ output += ` // ${prop.comment}`;
18
17
  }
19
18
 
20
19
  return output + '\n';
21
20
  })
22
21
  .join('');
23
22
 
24
- return string + `\n$${this.mapName || 'tokens' }: ${processJsonNode(dictionary.properties, 0)};\n`;
23
+ return string + `\n$${this.mapName || 'tokens'}: ${processJsonNode(dictionary.properties, 0)};\n`;
25
24
  }
26
- })
25
+ });
27
26
  };
28
27
 
29
-
30
28
  function processJsonNode(obj, depth) {
31
29
  let output = '';
32
30
 
33
31
  if (obj.hasOwnProperty('value')) {
34
32
  output += `$${obj.name}`;
35
33
  } else {
36
- output += '(\n'
37
- output += Object.keys(obj).map((newKey) => {
38
- const newProp = obj[newKey];
39
- const indent = ' '.repeat(depth+1);
40
-
41
- return `${indent}'${newKey}': ${processJsonNode(newProp, depth + 1)}`;
42
- }).join(',\n');
34
+ output += '(\n';
35
+ output += Object.keys(obj)
36
+ .map((newKey) => {
37
+ const newProp = obj[newKey];
38
+ const indent = ' '.repeat(depth + 1);
39
+
40
+ return `${indent}'${newKey}': ${processJsonNode(newProp, depth + 1)}`;
41
+ })
42
+ .join(',\n');
43
43
 
44
44
  output += '\n' + ' '.repeat(depth) + ')';
45
45
  }
@@ -3,7 +3,7 @@ const { formatHelpers } = require('style-dictionary');
3
3
  module.exports = (StyleDictionary) => {
4
4
  StyleDictionary.registerFormat({
5
5
  name: 'kbq-css/variables',
6
- formatter: function({dictionary, options={}, file}) {
6
+ formatter: function ({ dictionary, options = {}, file }) {
7
7
  const selector = options.selector ? options.selector : `:root`;
8
8
  const { outputReferences } = options;
9
9
 
@@ -11,9 +11,12 @@ module.exports = (StyleDictionary) => {
11
11
  token.name = token.name.replace(/(light|dark)-/, '');
12
12
  });
13
13
 
14
- return formatHelpers.fileHeader({file}) +
14
+ return (
15
+ formatHelpers.fileHeader({ file }) +
15
16
  `${selector} {\n` +
16
17
  formatHelpers.formattedVariables({ format: 'css', dictionary, outputReferences }) +
17
- `\n}\n`;
18
- } })
18
+ `\n}\n`
19
+ );
20
+ }
21
+ });
19
22
  };
package/package.json CHANGED
@@ -19,5 +19,5 @@
19
19
  "default": "./*"
20
20
  }
21
21
  },
22
- "version": "3.0.0-rc.9"
22
+ "version": "3.0.0"
23
23
  }
@@ -1,5 +1,4 @@
1
1
  module.exports = (StyleDictionary) => {
2
-
3
2
  StyleDictionary.registerTransformGroup({
4
3
  name: 'kbq/css',
5
4
  transforms: [
@@ -1,5 +1,4 @@
1
1
  module.exports = (StyleDictionary) => {
2
-
3
2
  StyleDictionary.registerTransformGroup({
4
3
  name: 'kbq/scss',
5
4
  transforms: [
@@ -10,4 +9,4 @@ module.exports = (StyleDictionary) => {
10
9
  'name/cti/kebab'
11
10
  ]
12
11
  });
13
- }
12
+ };
@@ -1,12 +1,6 @@
1
1
  module.exports = (StyleDictionary) => {
2
2
  StyleDictionary.registerTransformGroup({
3
3
  name: 'kbq/ts',
4
- transforms: [
5
- 'attribute/cti',
6
- 'name/cti/pascal',
7
- 'kbq-attribute/palette',
8
- 'size/px',
9
- 'color/hex'
10
- ]
4
+ transforms: ['attribute/cti', 'name/cti/pascal', 'kbq-attribute/palette', 'size/px', 'color/hex']
11
5
  });
12
- }
6
+ };
@@ -1,5 +1,4 @@
1
1
  module.exports = (StyleDictionary) => {
2
-
3
2
  StyleDictionary.registerTransform({
4
3
  name: 'kbq-attribute/md-typography',
5
4
  type: 'attribute',
@@ -1,5 +1,4 @@
1
1
  module.exports = (StyleDictionary) => {
2
-
3
2
  StyleDictionary.registerTransform({
4
3
  name: 'kbq-attribute/palette',
5
4
  type: 'attribute',
@@ -1,5 +1,4 @@
1
1
  module.exports = (StyleDictionary) => {
2
-
3
2
  StyleDictionary.registerTransform({
4
3
  name: 'kbq-attribute/typography',
5
4
  type: 'attribute',