@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.
@@ -1,5 +1,5 @@
1
- const fs = require('fs');
2
- const path = require('node:path');
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
3
 
4
4
  const HEADER = '/**\n * Do not edit directly\n */\n';
5
5
 
@@ -22,7 +22,7 @@ const HEADER = '/**\n * Do not edit directly\n */\n';
22
22
  * files: [ … ]
23
23
  * }
24
24
  */
25
- module.exports = (StyleDictionary) => {
25
+ export default (StyleDictionary) => {
26
26
  StyleDictionary.registerAction({
27
27
  name: 'kbq/css-index',
28
28
  do: (_dictionary, config) => {
package/build.js CHANGED
@@ -1,47 +1,66 @@
1
- const StyleDictionary = require('style-dictionary');
2
- const getPlatformConfig = require('./configs');
1
+ import StyleDictionary from 'style-dictionary';
2
+ import getPlatformConfig from './configs/index.js';
3
3
 
4
4
  // ==== Include custom transforms ====
5
- require('./transforms/attribute/md-typography')(StyleDictionary);
6
- require('./transforms/attribute/typography')(StyleDictionary);
7
- require('./transforms/attribute/palette')(StyleDictionary);
8
- require('./transforms/attribute/prefix')(StyleDictionary);
9
- require('./transforms/attribute/font')(StyleDictionary);
10
- require('./transforms/attribute/theme')(StyleDictionary);
11
- require('./transforms/attribute/scss-value')(StyleDictionary);
12
- require('./transforms/attribute/deprecation-comment')(StyleDictionary);
13
- require('./transforms/name/custom-kebab')(StyleDictionary);
5
+ import registerMdTypographyAttribute from './transforms/attribute/md-typography.js';
6
+ import registerTypographyAttribute from './transforms/attribute/typography.js';
7
+ import registerFontAttribute from './transforms/attribute/font.js';
8
+ import registerThemeAttributes from './transforms/attribute/theme.js';
9
+ import registerScssValue from './transforms/attribute/scss-value.js';
10
+ import registerDeprecationComment from './transforms/attribute/deprecation-comment.js';
11
+ import registerCustomKebab from './transforms/name/custom-kebab.js';
12
+
13
+ // ==== Include custom preprocessors ====
14
+ import registerExpandTypography from './preprocessors/expand-typography.js';
14
15
 
15
16
  // ==== Include custom filters ====
16
- require('./filters/palette')(StyleDictionary);
17
- require('./filters/css-variables')(StyleDictionary);
18
- require('./filters/color')(StyleDictionary);
19
- require('./filters/typography')(StyleDictionary);
20
- require('./filters/md-typography')(StyleDictionary);
17
+ import registerTypographyFilter from './filters/typography.js';
18
+ import registerMdTypographyFilter from './filters/md-typography.js';
21
19
 
22
20
  // ==== Include custom transform groups ====
23
- require('./transformGroups/scss')(StyleDictionary);
24
- require('./transformGroups/css')(StyleDictionary);
25
- require('./transformGroups/ts')(StyleDictionary);
21
+ import registerScssGroup from './transformGroups/scss.js';
22
+ import registerCssGroup from './transformGroups/css.js';
23
+ import registerTsGroup from './transformGroups/ts.js';
26
24
 
27
25
  // ==== Include custom formats ====
28
- require('./formats/typography')(StyleDictionary);
29
- require('./formats/palette')(StyleDictionary);
30
- require('./formats/variables')(StyleDictionary);
26
+ import registerTypographyFormat from './formats/typography.js';
27
+ import registerVariablesFormat from './formats/variables.js';
28
+ import registerComponentFormat from './formats/component.js';
31
29
 
32
30
  // ==== Include custom actions ====
33
- require('./actions/css-index')(StyleDictionary);
31
+ import registerCssIndex from './actions/css-index.js';
32
+
33
+ registerMdTypographyAttribute(StyleDictionary);
34
+ registerTypographyAttribute(StyleDictionary);
35
+ registerFontAttribute(StyleDictionary);
36
+ registerThemeAttributes(StyleDictionary);
37
+ registerScssValue(StyleDictionary);
38
+ registerDeprecationComment(StyleDictionary);
39
+ registerCustomKebab(StyleDictionary);
40
+
41
+ registerExpandTypography(StyleDictionary);
42
+
43
+ registerTypographyFilter(StyleDictionary);
44
+ registerMdTypographyFilter(StyleDictionary);
45
+
46
+ registerScssGroup(StyleDictionary);
47
+ registerCssGroup(StyleDictionary);
48
+ registerTsGroup(StyleDictionary);
34
49
 
35
- // ==== Run build ====
36
- console.log('Build started...');
37
- console.log('==============================================');
50
+ registerTypographyFormat(StyleDictionary);
51
+ registerVariablesFormat(StyleDictionary);
52
+ registerComponentFormat(StyleDictionary);
38
53
 
39
- module.exports = (themeConfig) => {
40
- StyleDictionary.registerFileHeader({
41
- name: 'customHeader',
42
- fileHeader: () => [`Do not edit directly`]
43
- });
44
- console.log('themeConfig: ', themeConfig);
54
+ registerCssIndex(StyleDictionary);
55
+
56
+ StyleDictionary.registerFileHeader({
57
+ name: 'customHeader',
58
+ fileHeader: () => [`Do not edit directly`]
59
+ });
60
+
61
+ export default async (themeConfig) => {
62
+ console.log('Build started...');
63
+ console.log('==============================================');
45
64
 
46
65
  if (!themeConfig || themeConfig.length === 0) {
47
66
  console.error('Build Failed. Please set ThemeConfig, for example: ', {
@@ -53,18 +72,30 @@ module.exports = (themeConfig) => {
53
72
  ],
54
73
  outputPath: 'design-tokens/'
55
74
  });
56
- process.exit(0);
75
+ process.exit(1);
57
76
  }
58
77
 
59
- themeConfig.map((platform) => {
60
- // APPLY THE CONFIGURATION
61
- // Very important: the registration of custom transforms
62
- // needs to be done _before_ applying the configuration
63
- const StyleDictionaryExtended = StyleDictionary.extend(getPlatformConfig(platform));
78
+ for (const theme of themeConfig) {
79
+ console.log('themeConfig: ', theme);
64
80
 
65
- // FINALLY, BUILD ALL THE PLATFORMS
66
- StyleDictionaryExtended.buildAllPlatforms();
67
- });
81
+ const config = getPlatformConfig(theme);
82
+ const sd = new StyleDictionary(config);
83
+
84
+ // One platform at a time, rather than sd.buildAllPlatforms().
85
+ //
86
+ // That helper runs every platform through a single Promise.all, while the "filtered out
87
+ // token references" warning is counted in a module-level store that is not scoped to a
88
+ // platform. The css platform switches that warning off on purpose — its files reference
89
+ // each other across file boundaries — but with the platforms interleaved, a warning css
90
+ // raised could be flushed, and thrown on, while scss or js was being written, where the
91
+ // top-level `warnings: 'error'` still applies. Which platform got the blame came down to
92
+ // how the file writes happened to interleave.
93
+ //
94
+ // Building sequentially keeps each warning with the platform that caused it.
95
+ for (const name of Object.keys(config.platforms)) {
96
+ await sd.buildPlatform(name);
97
+ }
98
+ }
68
99
 
69
100
  console.log('\n==============================================');
70
101
  console.log('\nBuild completed!');
package/configs/css.js CHANGED
@@ -1,252 +1,322 @@
1
- const fs = require('fs');
2
- const path = require('node:path');
1
+ import { hasValue } from '../filters/has-value.js';
3
2
 
4
- const paletteColors = ['black', 'blue', 'cyan', 'green', 'grey', 'orange', 'purple', 'red', 'white', 'yellow'];
5
- const semanticPaletteColors = ['theme', 'success', 'warning', 'error', 'contrast', 'white', 'black', 'purple'];
3
+ const paletteColors = [
4
+ 'blue',
5
+ 'slate',
6
+ 'red',
7
+ 'orange',
8
+ 'yellow',
9
+ 'green',
10
+ 'teal',
11
+ 'purple',
12
+ 'darkBlue',
13
+ 'darkSlate',
14
+ 'darkRed',
15
+ 'darkOrange',
16
+ 'darkYellow',
17
+ 'darkGreen',
18
+ 'darkTeal',
19
+ 'darkPurple',
20
+ 'grey',
21
+ 'darkGrey',
22
+ 'greyA',
23
+ 'darkGreyA',
24
+ 'whiteA',
25
+ 'blackA',
26
+ 'blueA',
27
+ 'slateA',
28
+ 'redA',
29
+ 'orangeA',
30
+ 'yellowA',
31
+ 'greenA',
32
+ 'tealA',
33
+ 'purpleA',
34
+ 'darkBlueA',
35
+ 'darkSlateA',
36
+ 'darkRedA',
37
+ 'darkOrangeA',
38
+ 'darkYellowA',
39
+ 'darkGreenA',
40
+ 'darkTealA',
41
+ 'darkPurpleA',
42
+ 'yellowFixed',
43
+ 'orangeFixed',
44
+ 'darkYellowFixed',
45
+ 'darkOrangeFixed',
46
+ 'yellowFixedA',
47
+ 'orangeFixedA',
48
+ 'darkYellowFixedA',
49
+ 'darkOrangeFixedA',
50
+ 'white',
51
+ 'black'
52
+ ];
6
53
 
7
- // resolve components path if script used externally
8
- const componentsPath = fs.existsSync(path.join('node_modules', '@koobiq/design-tokens', 'web', 'components'))
9
- ? path.join('node_modules', '@koobiq/design-tokens', 'web', 'components')
10
- : path.join('packages', 'design-tokens', 'web', 'components');
54
+ const semanticPaletteColors = [
55
+ 'contrast',
56
+ 'contrastA',
57
+ 'theme',
58
+ 'themeA',
59
+ 'error',
60
+ 'errorA',
61
+ 'warning',
62
+ 'warningA',
63
+ 'warningFixed',
64
+ 'warningFixedA',
65
+ 'success',
66
+ 'successA',
67
+ 'visited',
68
+ 'visitedA',
69
+ 'darkContrast',
70
+ 'darkContrastA',
71
+ 'darkTheme',
72
+ 'darkThemeA',
73
+ 'darkError',
74
+ 'darkErrorA',
75
+ 'darkWarning',
76
+ 'darkWarningA',
77
+ 'darkWarningFixed',
78
+ 'darkWarningFixedA',
79
+ 'darkSuccess',
80
+ 'darkSuccessA',
81
+ 'darkVisited',
82
+ 'darkVisitedA'
83
+ ];
11
84
 
12
- const componentTokens = fs
13
- .readdirSync(componentsPath)
14
- .filter((fileName) => fileName.endsWith('.json5'))
15
- .map((fileName) => fileName.replace('.json5', ''));
85
+ /**
86
+ * The component token sets that survived v4, named after their source file in web/components/.
87
+ *
88
+ * Each gets its own stylesheet under css/components/, because they are opt-in and wildly uneven
89
+ * in size: code-block is 34 of the 68 emitted component variables, so a consumer who renders no
90
+ * code blocks should not have to carry them to get a styled scrollbar.
91
+ */
92
+ const components = [
93
+ { file: 'code-block', root: 'code-block' },
94
+ { file: 'scrollbars', root: 'scrollbar' },
95
+ { file: 'skeleton', root: 'skeleton' }
96
+ ];
16
97
 
17
- const componentTokensBase = componentTokens.map((fileName) => ({
18
- destination: `deprecated/css/components/${fileName}/${fileName}.css`,
19
- format: 'kbq-css/variables',
20
- filter: (token) => token.filePath.includes(fileName) && !token.attributes.light && !token.attributes.dark,
21
- prefix: 'kbq',
22
- options: {
23
- outputReferences: true
24
- }
25
- }));
98
+ const componentRoots = components.map(({ root }) => root);
26
99
 
27
- const componentTokensLight = componentTokens.map((fileName) => ({
28
- destination: `deprecated/css/components/${fileName}/${fileName}-light.css`,
100
+ /**
101
+ * Tokens authored under web/components — code-block syntax colours, scrollbar, skeleton.
102
+ *
103
+ * Matched on the token's own path rather than its `filePath`: Style Dictionary leaves `filePath`
104
+ * undefined on a token whose value is null, and those are exactly the deliberately-unstyled
105
+ * component tokens, so a filePath test both throws and mis-sorts them into the global aggregates.
106
+ */
107
+ const isComponent = (token) => componentRoots.includes(token.attributes.category);
108
+
109
+ /**
110
+ * Everything sliced by category lives under css/, mirroring how the package was laid out before
111
+ * v4. The aggregates that stitch those slices back together (css-tokens*.css,
112
+ * component-tokens*.css) stay at the root of web/, so "a slice" and "the whole thing" are told
113
+ * apart by location.
114
+ */
115
+ const sliced = (destination) => `css/${destination}`;
116
+
117
+ const paletteByColorsConfig = paletteColors.map((color) => ({
118
+ destination: sliced(`palette/${color}.css`),
29
119
  format: 'kbq-css/variables',
30
- filter: (token) => token.filePath.includes(fileName) && token.attributes.light,
31
- prefix: 'kbq',
32
- options: {
33
- selector: '.kbq-light'
34
- }
120
+ filter: (token) => token.attributes.category === 'plt' && token.attributes.type === color
35
121
  }));
36
122
 
37
- const componentTokensDark = componentTokens.map((fileName) => ({
38
- destination: `deprecated/css/components/${fileName}/${fileName}-dark.css`,
123
+ const semanticPaletteConfig = semanticPaletteColors.map((color) => ({
124
+ destination: sliced(`semantic-palette/${color}.css`),
39
125
  format: 'kbq-css/variables',
40
- filter: (token) => token.filePath.includes(fileName) && token.attributes.dark,
41
- prefix: 'kbq',
126
+ filter: (token) => token.attributes.category === 'semantic' && token.attributes.type === color,
42
127
  options: {
43
- selector: '.kbq-dark'
128
+ outputReferences: true
44
129
  }
45
130
  }));
46
131
 
47
- const paletteByColorsConfig = paletteColors.map((color) => ({
48
- destination: `css/palette/${color}.css`,
49
- format: 'kbq-css/variables',
50
- filter: (token) => token.attributes.category === 'palette' && token.attributes.type === color,
51
- prefix: 'kbq'
52
- }));
53
-
54
- const semanticPaletteConfig = semanticPaletteColors.map((color) => ({
55
- destination: `css/semantic-palette/${color}.css`,
56
- format: 'kbq-css/palette',
57
- filter: (token) =>
58
- token.filePath.includes('colors.v1.json5') &&
59
- token.attributes.light &&
60
- token.attributes.type === color &&
61
- (token.attributes.palette || token.name.includes('default')),
62
- prefix: 'kbq',
132
+ const componentsConfig = components.map(({ file, root }) => ({
133
+ destination: sliced(`components/${file}.css`),
134
+ format: 'kbq-css/component',
135
+ filter: (token) => hasValue(token) && token.attributes.category === root,
63
136
  options: {
64
137
  outputReferences: true
65
138
  }
66
139
  }));
67
140
 
68
- module.exports = {
141
+ export default {
69
142
  css: {
70
143
  transformGroup: 'kbq/css',
71
144
  actions: ['kbq/css-index'],
72
- // Curated aggregate token files consumers can pull in via a single entry point.
73
- // Per-color palette splits, root css-tokens*.css and deprecated component tokens are
74
- // intentionally excluded to avoid duplicate variable declarations.
145
+ prefix: 'kbq',
146
+ // Token files are split across many outputs on purpose (palette.css,
147
+ // semantic-palette.css, light/semantic-colors.css …) and reference each other across
148
+ // those files — which is exactly what index.css stitches back together. Style
149
+ // Dictionary warns for every reference whose target was filtered out of the file being
150
+ // written, so that one warning is muted here. Transform errors still fail the build:
151
+ // they are gated by the top-level `log` (see configs/index.js).
152
+ log: { warnings: 'disabled' },
153
+ // Per-color palette/semantic-palette splits are omitted from the index since their
154
+ // variables are already covered by the aggregate palette.css / semantic-palette.css.
155
+ //
156
+ // Component tokens are omitted on purpose too: only consumers using code-block,
157
+ // scrollbar or skeleton need them, so they ship opt-in — one file per component under
158
+ // css/components/, plus component-tokens*.css at the root for all of them at once.
75
159
  index: {
76
160
  dir: 'css',
77
161
  files: [
78
- 'css/font.css',
79
- 'css/size.css',
80
- 'css/typography.css',
81
- 'css/md-typography.css',
82
- 'css/palette.css',
83
- 'css/light/semantic-palette.css',
84
- 'css/light/semantic-colors.css',
85
- 'css/light/shadows.css',
86
- 'css/dark/semantic-palette.css',
87
- 'css/dark/semantic-colors.css',
88
- 'css/dark/shadows.css'
162
+ sliced('font.css'),
163
+ sliced('size.css'),
164
+ sliced('typography.css'),
165
+ sliced('md-typography.css'),
166
+ sliced('palette.css'),
167
+ sliced('semantic-palette.css'),
168
+ sliced('light/semantic-colors.css'),
169
+ sliced('light/shadows.css'),
170
+ sliced('dark/semantic-colors.css'),
171
+ sliced('dark/shadows.css')
89
172
  ]
90
173
  },
91
174
  files: [
92
175
  ...semanticPaletteConfig,
176
+ ...paletteByColorsConfig,
177
+ ...componentsConfig,
93
178
  {
94
- destination: 'css/light/semantic-palette.css',
95
- format: 'kbq-css/palette',
96
- filter: (token) =>
97
- token.attributes.light &&
98
- token.filePath.includes('colors.v1.json5') &&
99
- (token.attributes.palette || token.name.includes('default')),
100
- prefix: 'kbq',
101
- options: {
102
- selector: '.kbq-light'
103
- }
179
+ destination: sliced('font.css'),
180
+ format: 'css/variables',
181
+ filter: (token) => token.attributes.category === 'font'
104
182
  },
105
183
  {
106
- destination: 'css/dark/semantic-palette.css',
107
- format: 'kbq-css/palette',
108
- filter: (token) =>
109
- token.attributes.dark &&
110
- token.filePath.includes('colors.v1.json5') &&
111
- (token.attributes.palette || token.name.includes('default')),
112
- prefix: 'kbq',
113
- options: {
114
- selector: '.kbq-dark'
115
- }
184
+ destination: sliced('size.css'),
185
+ format: 'css/variables',
186
+ filter: (token) => token.attributes.category === 'size'
116
187
  },
117
188
  {
118
- destination: 'css/light/semantic-colors.css',
119
- format: 'kbq-css/palette',
120
- filter: (token) =>
121
- token.attributes.light &&
122
- token.filePath.includes('colors.v1.json5') &&
123
- !semanticPaletteColors.includes(token.attributes.type),
124
- prefix: 'kbq',
189
+ destination: sliced('typography.css'),
190
+ format: 'css/variables',
191
+ filter: (token) => token.attributes.category === 'typography',
125
192
  options: {
126
- selector: '.kbq-light'
193
+ outputReferences: true
127
194
  }
128
195
  },
129
196
  {
130
- destination: 'css/dark/semantic-colors.css',
131
- format: 'kbq-css/palette',
132
- filter: (token) =>
133
- token.attributes.dark &&
134
- token.filePath.includes('colors.v1.json5') &&
135
- !semanticPaletteColors.includes(token.attributes.type),
136
- prefix: 'kbq',
197
+ destination: sliced('md-typography.css'),
198
+ format: 'css/variables',
199
+ filter: (token) => token.attributes.category === 'md-typography',
137
200
  options: {
138
- selector: '.kbq-dark'
201
+ outputReferences: true
139
202
  }
140
203
  },
141
204
  {
142
- destination: 'css/font.css',
143
- format: 'css/variables',
144
- filter: (token) => token.attributes.category === 'font',
145
- prefix: 'kbq'
146
- },
147
- {
148
- destination: 'css/size.css',
149
- format: 'css/variables',
150
- filter: (token) => token.attributes.category === 'size',
151
- prefix: 'kbq'
205
+ destination: sliced('palette.css'),
206
+ format: 'kbq-css/variables',
207
+ filter: (token) => token.attributes.category === 'plt'
152
208
  },
153
209
  {
154
- destination: 'css/md-typography.css',
155
- format: 'css/variables',
156
- filter: (token) => token.attributes.category === 'md-typography',
157
- prefix: 'kbq',
210
+ destination: sliced('semantic-palette.css'),
211
+ format: 'kbq-css/variables',
212
+ filter: (token) => token.attributes.category === 'semantic',
158
213
  options: {
159
214
  outputReferences: true
160
215
  }
161
216
  },
162
- ...paletteByColorsConfig,
163
217
  {
164
- destination: 'css/palette.css',
218
+ destination: sliced('light/shadows.css'),
165
219
  format: 'kbq-css/variables',
166
- filter: (token) => token.attributes.category === 'palette',
167
- prefix: 'kbq'
220
+ filter: (token) => token.attributes.light && token.attributes.category === 'shadow',
221
+ options: {
222
+ selector: '.kbq-light',
223
+ outputReferences: true
224
+ }
168
225
  },
169
226
  {
170
- destination: 'css/light/shadows.css',
227
+ destination: sliced('light/semantic-colors.css'),
171
228
  format: 'kbq-css/variables',
172
- filter: (token) => token.attributes.light && token.attributes.category === 'shadow',
173
- prefix: 'kbq',
229
+ // `filePath?.` because Style Dictionary leaves it undefined on null-valued tokens;
230
+ // a token with no known file is simply not one of colors.json5's.
231
+ filter: (token) => token.attributes.light && token.filePath?.includes('colors.json5'),
174
232
  options: {
175
- selector: '.kbq-light'
233
+ selector: '.kbq-light',
234
+ outputReferences: true
176
235
  }
177
236
  },
178
237
  {
179
- destination: 'css/dark/shadows.css',
238
+ destination: sliced('dark/shadows.css'),
180
239
  format: 'kbq-css/variables',
181
240
  filter: (token) => token.attributes.dark && token.attributes.category === 'shadow',
182
- prefix: 'kbq',
183
241
  options: {
184
- selector: '.kbq-dark'
242
+ selector: '.kbq-dark',
243
+ outputReferences: true
185
244
  }
186
245
  },
187
246
  {
188
- destination: 'css/typography.css',
189
- format: 'css/variables',
190
- filter: (token) => token.attributes.category === 'typography',
191
- prefix: 'kbq',
247
+ destination: sliced('dark/semantic-colors.css'),
248
+ format: 'kbq-css/variables',
249
+ filter: (token) => token.attributes.dark && token.filePath?.includes('colors.json5'),
192
250
  options: {
251
+ selector: '.kbq-dark',
193
252
  outputReferences: true
194
253
  }
195
254
  },
196
- ...componentTokensBase,
197
- ...componentTokensLight,
198
- ...componentTokensDark,
255
+ // The three component token sets that survived v4 (code-block syntax colours,
256
+ // scrollbar, skeleton). Only consumers of those components need them, so they are
257
+ // opt-in: kept out of index.css and out of the css-tokens*.css aggregates, and
258
+ // shipped as their own triple mirroring the css-tokens*.css naming.
199
259
  {
200
- destination: 'deprecated/css/components-light.css',
260
+ destination: 'component-tokens.css',
201
261
  format: 'kbq-css/variables',
202
262
  filter: (token) =>
203
- token.attributes.light && !token.attributes.palette && token.filePath.includes('components'),
204
- prefix: 'kbq',
263
+ hasValue(token) && isComponent(token) && !token.attributes.light && !token.attributes.dark,
205
264
  options: {
206
- selector: '.kbq-light'
265
+ outputReferences: true
207
266
  }
208
267
  },
209
268
  {
210
- destination: 'deprecated/css/components-dark.css',
269
+ destination: 'component-tokens-light.css',
211
270
  format: 'kbq-css/variables',
212
- filter: (token) =>
213
- token.attributes.dark && !token.attributes.palette && token.filePath.includes('components'),
214
- prefix: 'kbq',
271
+ filter: (token) => hasValue(token) && isComponent(token) && token.attributes.light,
215
272
  options: {
216
- selector: '.kbq-dark'
273
+ selector: '.kbq-light',
274
+ outputReferences: true
217
275
  }
218
276
  },
219
277
  {
220
- destination: 'css-tokens.css',
221
- format: 'css/variables',
222
- filter: 'css-variables',
223
- prefix: 'kbq'
278
+ destination: 'component-tokens-dark.css',
279
+ format: 'kbq-css/variables',
280
+ filter: (token) => hasValue(token) && isComponent(token) && token.attributes.dark,
281
+ options: {
282
+ selector: '.kbq-dark',
283
+ outputReferences: true
284
+ }
224
285
  },
225
286
  {
226
- destination: 'css-tokens-light.css',
227
- format: 'kbq-css/variables',
228
- filter: 'css-variables-light',
229
- prefix: 'kbq',
287
+ destination: 'css-tokens.css',
288
+ format: 'css/variables',
289
+ filter: (token) =>
290
+ hasValue(token) &&
291
+ !isComponent(token) &&
292
+ !token.attributes.font &&
293
+ !token.attributes.light &&
294
+ !token.attributes.dark &&
295
+ token.type !== 'font',
230
296
  options: {
231
- selector: '.kbq-light'
297
+ outputReferences: true
232
298
  }
233
299
  },
300
+ // outputReferences matters here as much as it does in the index files: without it a
301
+ // role token is written as a resolved literal, the plt → semantic → role chain is
302
+ // gone from the output, and repointing the semantic layer (the supported way to
303
+ // re-theme) silently stops working for anyone consuming this entry point.
234
304
  {
235
- destination: 'css-tokens-dark.css',
305
+ destination: 'css-tokens-light.css',
236
306
  format: 'kbq-css/variables',
237
- filter: 'css-variables-dark',
238
- prefix: 'kbq',
307
+ filter: (token) => hasValue(token) && !isComponent(token) && token.attributes.light,
239
308
  options: {
240
- selector: '.kbq-dark'
309
+ selector: '.kbq-light',
310
+ outputReferences: true
241
311
  }
242
312
  },
243
313
  {
244
- destination: 'css-tokens-font.css',
314
+ destination: 'css-tokens-dark.css',
245
315
  format: 'kbq-css/variables',
246
- filter: 'css-variables-font',
247
- prefix: 'kbq',
316
+ filter: (token) => hasValue(token) && !isComponent(token) && token.attributes.dark,
248
317
  options: {
249
- selector: '.kbq-font'
318
+ selector: '.kbq-dark',
319
+ outputReferences: true
250
320
  }
251
321
  }
252
322
  ]