@grantcodes/style-dictionary 1.3.0 → 1.4.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/assets/fonts/grantina.css +1 -0
  3. package/assets/logos/grantina/monogram-light-bg.svg +3 -0
  4. package/assets/logos/grantina/monogram.svg +15 -0
  5. package/dist/css/grantcodes/dark.css +168 -0
  6. package/dist/css/grantcodes/grantcodes.css +343 -0
  7. package/dist/css/grantcodes/tokens.css +343 -0
  8. package/dist/css/grantina/dark.css +166 -0
  9. package/dist/css/grantina/grantina.css +363 -0
  10. package/dist/css/grantina/tokens.css +363 -0
  11. package/dist/css/todomap/dark.css +120 -0
  12. package/dist/css/todomap/todomap.css +360 -0
  13. package/dist/css/todomap/tokens.css +360 -0
  14. package/dist/css/wireframe/dark.css +180 -0
  15. package/dist/css/wireframe/tokens.css +365 -0
  16. package/dist/css/wireframe/wireframe.css +365 -0
  17. package/dist/js/grantcodes/style-dictionary.d.ts +339 -0
  18. package/dist/js/grantcodes/style-dictionary.js +362 -0
  19. package/dist/js/grantina/style-dictionary.d.ts +362 -0
  20. package/dist/js/grantina/style-dictionary.js +391 -0
  21. package/dist/js/todomap/style-dictionary.d.ts +356 -0
  22. package/dist/js/todomap/style-dictionary.js +388 -0
  23. package/dist/js/wireframe/style-dictionary.d.ts +361 -0
  24. package/dist/js/wireframe/style-dictionary.js +368 -0
  25. package/dist/json/grantcodes/tokens.json +329 -0
  26. package/dist/json/grantina/tokens.json +352 -0
  27. package/dist/json/todomap/tokens.json +346 -0
  28. package/dist/json/wireframe/tokens.json +351 -0
  29. package/package.json +76 -61
  30. package/.turbo/turbo-build.log +0 -45
  31. package/.turbo/turbo-lint.log +0 -10
  32. package/AGENTS.md +0 -67
  33. package/biome.json +0 -9
  34. package/build.js +0 -10
  35. package/config.js +0 -509
  36. package/demo.html +0 -171
  37. package/lib/color-generator.js +0 -13
  38. package/lib/get-style-dictionary-config.js +0 -223
  39. package/lib/get-themes.js +0 -10
  40. package/lib/index.js +0 -3
  41. package/tests/tokens.test.js +0 -87
  42. package/tokens/core/tier-1-definitions/colors.json +0 -174
  43. package/tokens/core/tier-1-definitions/z-index.json +0 -28
  44. package/tokens/grantcodes/tier-1-definitions/animation.json +0 -26
  45. package/tokens/grantcodes/tier-1-definitions/borders.json +0 -35
  46. package/tokens/grantcodes/tier-1-definitions/colors.json +0 -35
  47. package/tokens/grantcodes/tier-1-definitions/shadows.json +0 -38
  48. package/tokens/grantcodes/tier-1-definitions/spacing.json +0 -49
  49. package/tokens/grantcodes/tier-1-definitions/typography.json +0 -142
  50. package/tokens/grantcodes/tier-2-usage/00-colors-background.json +0 -71
  51. package/tokens/grantcodes/tier-2-usage/00-colors-border.json +0 -41
  52. package/tokens/grantcodes/tier-2-usage/00-colors-content.json +0 -44
  53. package/tokens/grantcodes/tier-2-usage/animation.json +0 -23
  54. package/tokens/grantcodes/tier-2-usage/borders.json +0 -26
  55. package/tokens/grantcodes/tier-2-usage/shadows.json +0 -38
  56. package/tokens/grantcodes/tier-2-usage/spacing.json +0 -25
  57. package/tokens/grantcodes/tier-2-usage/typography-usage.json +0 -276
  58. package/tokens/grantcodes/tier-3-components/button.json +0 -94
  59. package/tokens/grantcodes/tier-3-components/focus-ring.json +0 -25
  60. package/tokens/grantcodes/tier-3-components/form.json +0 -69
  61. package/tokens/grantcodes/tier-3-components/link.json +0 -38
  62. package/tokens/todomap/tier-1-definitions/colors.json +0 -91
  63. package/tokens/todomap/tier-1-definitions/spacing.json +0 -49
  64. package/tokens/todomap/tier-1-definitions/typography.json +0 -12
  65. package/tokens/todomap/tier-2-usage/00-colors-background.json +0 -35
  66. package/tokens/todomap/tier-2-usage/00-colors-content.json +0 -32
  67. package/tokens/todomap/tier-2-usage/spacing.json +0 -25
  68. package/tokens/todomap/tier-2-usage/typography-usage.json +0 -20
  69. package/tokens/todomap/tier-3-components/button.json +0 -140
  70. package/tokens/todomap/tier-3-components/focus-ring.json +0 -25
  71. package/tokens/todomap/tier-3-components/form.json +0 -69
  72. package/tokens/todomap/tier-3-components/link.json +0 -38
  73. package/tokens/wireframe/tier-1-definitions/animation.json +0 -17
  74. package/tokens/wireframe/tier-1-definitions/borders.json +0 -41
  75. package/tokens/wireframe/tier-1-definitions/colors.json +0 -35
  76. package/tokens/wireframe/tier-1-definitions/shadows.json +0 -38
  77. package/tokens/wireframe/tier-1-definitions/spacing.json +0 -49
  78. package/tokens/wireframe/tier-1-definitions/typography.json +0 -130
  79. package/tokens/wireframe/tier-2-usage/00-colors-background.json +0 -85
  80. package/tokens/wireframe/tier-2-usage/00-colors-border.json +0 -41
  81. package/tokens/wireframe/tier-2-usage/00-colors-content.json +0 -44
  82. package/tokens/wireframe/tier-2-usage/animation.json +0 -23
  83. package/tokens/wireframe/tier-2-usage/borders.json +0 -32
  84. package/tokens/wireframe/tier-2-usage/shadows.json +0 -38
  85. package/tokens/wireframe/tier-2-usage/spacing.json +0 -25
  86. package/tokens/wireframe/tier-2-usage/typography-usage.json +0 -444
  87. package/tokens/wireframe/tier-3-components/button.json +0 -94
  88. package/tokens/wireframe/tier-3-components/focus-ring.json +0 -25
  89. package/tokens/wireframe/tier-3-components/form.json +0 -69
  90. package/tokens/wireframe/tier-3-components/link.json +0 -38
package/config.js DELETED
@@ -1,509 +0,0 @@
1
- import StyleDictionary from "style-dictionary";
2
- import minimist from "minimist";
3
-
4
- /**
5
- * List of themes to build
6
- * 1) Add your new theme here in order to have it show up in the dropdown
7
- */
8
- const AVAILABLE_THEMES = ["wireframe", "grantcodes", "todomap"];
9
-
10
- /**
11
- * Look for args passed on the command line
12
- * 1) Used to build a single theme if needed
13
- * 2) Pass in the theme name as an argument
14
- * 3) If no argument is passed, build all themes
15
- */
16
- const args = minimist(process.argv.slice(2));
17
- const theme = args.theme;
18
-
19
- /**
20
- * Helper function to check if token is from tier-2 or tier-3
21
- * 1) Used to determine if the token should be included in the theme tokens to apply `theme` prefix
22
- */
23
- const isHigherTierToken = (filePath) => {
24
- const isHigherTier =
25
- filePath.includes("tier-2-usage") || filePath.includes("tier-3-components");
26
- return isHigherTier;
27
- };
28
-
29
- /**
30
- * Transform shadow tokens
31
- * 1) Used to transform the individual shadow tokens into a single box-shadow-sm, box-shadow-md, etc. with x, y, blur, spread, and color concatenated
32
- */
33
- const transformTypographyTokens = (dictionary, themeTokens) => {
34
- const typographyGroups = dictionary.allTokens.filter(
35
- (p) =>
36
- isHigherTierToken(p.filePath) &&
37
- p.path[0] === 'typography'
38
- ).reduce((groups, token) => {
39
- const style = token.path[1]; // extract typography.{style}
40
- if (!groups[style]) groups[style] = {};
41
- groups[style][token.path[2]] = token.value;
42
- return groups;
43
- }, {});
44
-
45
- Object.keys(typographyGroups).forEach((style) => {
46
- const group = typographyGroups[style];
47
- if (group['font-family'] && group['font-weight'] && group['font-size'] && group['line-height']) {
48
- const shorthand = `${group['font-weight']} ${group['font-size']}/${group['line-height']} ${group['font-family']}`;
49
- themeTokens.push(` --g-theme-typography-${style}: ${shorthand};`);
50
- }
51
- });
52
- };
53
-
54
- const transformShadowTokens = (dictionary, size, themeTokens) => {
55
- const shadowProps = dictionary.allTokens.filter(
56
- (p) =>
57
- isHigherTierToken(p.filePath) &&
58
- p.path[0] === "box-shadow" &&
59
- p.path[1] === size,
60
- );
61
-
62
- const x = shadowProps.find((p) => p.path[2] === "x")?.value || "0px";
63
- const y = shadowProps.find((p) => p.path[2] === "y")?.value || "0px";
64
- const blur = shadowProps.find((p) => p.path[2] === "blur")?.value || "0px";
65
- const spread =
66
- shadowProps.find((p) => p.path[2] === "spread")?.value || "0px";
67
- const color =
68
- shadowProps.find((p) => p.path[2] === "color")?.value || "transparent";
69
-
70
- /* 1 */
71
- themeTokens.push(
72
- ` --g-theme-box-shadow-${size}: ${x} ${y} ${blur} ${spread} ${color};`,
73
- );
74
- };
75
-
76
- /**
77
- * Transform line height tokens
78
- * 1) Used to transform the line height tokens to a unitless value for CSS by dividing the line height by the font size
79
- */
80
- const transformLineHeight = (
81
- dictionary,
82
- prop,
83
- outputArray,
84
- formatTokenName,
85
- ) => {
86
- const cleanPath = prop.path
87
- .map((segment) =>
88
- segment.startsWith("@") ? segment.substring(1) : segment,
89
- )
90
- .filter((segment) => segment !== "")
91
- .join("-");
92
-
93
- // For tier-1 tokens (typography.line-height.16), find matching font-size (typography.font-size.16)
94
- // For tier-2/3 tokens (typography.headline-lg.line-height), find matching font-size (typography.headline-lg.font-size)
95
- const isTier1 =
96
- prop.path.length === 3 &&
97
- prop.path[0] === "typography" &&
98
- prop.path[1] === "line-height";
99
- let fontSizePath;
100
- if (isTier1) {
101
- // Tier-1: typography.line-height.16 -> typography.font-size.16
102
- fontSizePath = ["typography", "font-size", prop.path[2]];
103
- } else {
104
- // Tier-2/3: typography.headline-lg.line-height -> typography.headline-lg.font-size
105
- fontSizePath = [...prop.path.slice(0, -1), "font-size"];
106
- }
107
-
108
- const fontSizeProp = dictionary.allTokens.find(
109
- (p) => p.path.join(".") === fontSizePath.join("."),
110
- );
111
-
112
- // Parse line-height value to pixels
113
- let lineHeightPx;
114
- if (prop.value.endsWith("px")) {
115
- lineHeightPx = parseFloat(prop.value.replace("px", ""));
116
- } else if (prop.value.endsWith("rem")) {
117
- lineHeightPx = parseFloat(prop.value.replace("rem", "")) * 16;
118
- } else {
119
- lineHeightPx = parseFloat(prop.value);
120
- }
121
-
122
- if (fontSizeProp) {
123
- // Found matching font-size - use it for calculation
124
- let fontSizePx;
125
- if (fontSizeProp.value.endsWith("px")) {
126
- fontSizePx = parseFloat(fontSizeProp.value.replace("px", ""));
127
- } else if (fontSizeProp.value.endsWith("rem")) {
128
- fontSizePx = parseFloat(fontSizeProp.value.replace("rem", "")) * 16;
129
- } else {
130
- fontSizePx = parseFloat(fontSizeProp.value);
131
- }
132
-
133
- if (fontSizePx > 0) {
134
- const unitlessValue = (lineHeightPx / fontSizePx).toFixed(2);
135
- outputArray.push(
136
- ` ${formatTokenName(cleanPath, prop)}: ${unitlessValue};`,
137
- );
138
- return;
139
- }
140
- } else if (isTier1 && lineHeightPx > 0) {
141
- // For tier-1 tokens without matching font-size, use 16px as base font-size
142
- const BASE_FONT_SIZE = 16;
143
- const unitlessValue = (lineHeightPx / BASE_FONT_SIZE).toFixed(2);
144
- outputArray.push(
145
- ` ${formatTokenName(cleanPath, prop)}: ${unitlessValue};`,
146
- );
147
- return;
148
- }
149
-
150
- // Fallback: output as-is if we can't calculate
151
- outputArray.push(` ${formatTokenName(cleanPath, prop)}: ${prop.value};`);
152
- };
153
-
154
- /**
155
- * Format variables
156
- * 1) Used to format the inner contents of the :root or .[theme-name] ruleset
157
- */
158
- const formatVariables = (dictionary) => {
159
- const processedShadows = new Set();
160
- const tier1Tokens = [];
161
- const themeTokens = [];
162
-
163
- /**
164
- * Format token global prefix and tier 2/3 identifier
165
- * 1) If the token is from tier-2 or tier-3, prefix it with `g-theme-`
166
- * 2) Otherwise, prefix it with `g-`
167
- */
168
- const formatTokenName = (cleanPath, prop) => {
169
- if (isHigherTierToken(prop.filePath)) {
170
- return `--g-theme-${cleanPath}`;
171
- }
172
- return `--g-${cleanPath}`;
173
- };
174
-
175
- /**
176
- * Get all box-shadow values from tier 2/3
177
- * 1) Used to determine which box-shadow values to transform into a single box-shadow-sm, box-shadow-md, etc.
178
- */
179
- const shadowSizes = dictionary.tokens.shadow
180
- ? Object.keys(dictionary.tokens.shadow)
181
- .map((key) => key.split("-")[0])
182
- .filter((value, index, self) => self.indexOf(value) === index) // Get unique sizes
183
- : [];
184
-
185
- /**
186
- * Iterate over all tokens and format them
187
- *
188
- */
189
-
190
- transformTypographyTokens(dictionary, themeTokens);
191
-
192
- dictionary.allTokens.forEach((prop) => {
193
- /**
194
- * 1) Always include z-index and size tokens from core
195
- */
196
- if (prop.path[0] === "z-index") {
197
- const cleanPath = prop.path
198
- .map((segment) =>
199
- segment.startsWith("@") ? segment.substring(1) : segment,
200
- )
201
- .filter((segment) => segment !== "")
202
- .join("-");
203
- tier1Tokens.push(` ${formatTokenName(cleanPath, prop)}: ${prop.value};`);
204
- return;
205
- }
206
-
207
- /**
208
- * Handle box-shadow token transformations
209
- * If the token is from tier-2 or tier-3 and is a box-shadow, transform it into a single box-shadow-sm, box-shadow-md, etc.
210
- */
211
- if (
212
- isHigherTierToken(prop.filePath) &&
213
- prop.path[0] === "box-shadow" &&
214
- shadowSizes.includes(prop.path[1])
215
- ) {
216
- const size = prop.path[1];
217
- if (processedShadows.has(size)) return;
218
- processedShadows.add(size);
219
- transformShadowTokens(dictionary, size, themeTokens);
220
- } else if (
221
- prop.path[0] === "typography" &&
222
- prop.path.includes("line-height")
223
- ) {
224
- /**
225
- * Handle line heights in typography (both tier-1 and tier-2/3)
226
- * 1) Transform line-height tokens to unitless values by dividing by font-size
227
- */
228
- const outputArray = isHigherTierToken(prop.filePath)
229
- ? themeTokens
230
- : tier1Tokens;
231
- transformLineHeight(dictionary, prop, outputArray, formatTokenName);
232
- } else if (!prop.path.includes("box-shadow") || prop.path.length > 3) {
233
- /**
234
- * Handle all other properties
235
- * 1) If the token is not a box-shadow or typography token, format it as a normal token
236
- */
237
- const cleanPath = prop.path
238
- .map((segment) =>
239
- segment.startsWith("@") ? segment.substring(1) : segment,
240
- )
241
- .filter((segment) => segment !== "")
242
- .join("-");
243
-
244
- const token = ` ${formatTokenName(cleanPath, prop)}: ${prop.value};`;
245
- if (isHigherTierToken(prop.filePath)) {
246
- themeTokens.push(token);
247
- } else {
248
- tier1Tokens.push(token);
249
- }
250
- }
251
- });
252
-
253
- return [...new Set([...tier1Tokens, ...themeTokens])].join("\n");
254
- };
255
-
256
- /**
257
- * Transform shadow tokens for JSON format
258
- * Combines individual shadow properties into a single value
259
- */
260
- const transformShadowTokensJSON = (dictionary, size) => {
261
- const shadowProps = dictionary.allTokens.filter(
262
- (p) =>
263
- isHigherTierToken(p.filePath) &&
264
- p.path[0] === "box-shadow" &&
265
- p.path[1] === size,
266
- );
267
-
268
- const x = shadowProps.find((p) => p.path[2] === "x")?.value || "0px";
269
- const y = shadowProps.find((p) => p.path[2] === "y")?.value || "0px";
270
- const blur = shadowProps.find((p) => p.path[2] === "blur")?.value || "0px";
271
- const spread =
272
- shadowProps.find((p) => p.path[2] === "spread")?.value || "0px";
273
- const color =
274
- shadowProps.find((p) => p.path[2] === "color")?.value || "transparent";
275
-
276
- return `${x} ${y} ${blur} ${spread} ${color}`;
277
- };
278
-
279
- /**
280
- * Generate a Theme-Specific Config
281
- * This accepts a theme parameter, which is used to control which set of
282
- * tokens to compile, and to define theme-specific compiled output.
283
- * @param {string} theme
284
- */
285
- const getStyleDictionaryConfig = (theme) => {
286
- // Register the JSON formatter
287
- StyleDictionary.registerFormat({
288
- name: "json/flat/custom",
289
- format: function (dictionary) {
290
- const transformedTokens = {};
291
-
292
- /**
293
- * Get all box-shadow values from tier 2/3
294
- * 1) Used to determine which box-shadow values to transform into a single box-shadow-sm, box-shadow-md, etc.
295
- */
296
- const shadowSizes = dictionary.tokens.shadow
297
- ? Object.keys(dictionary.tokens.shadow)
298
- .map((key) => key.split("-")[0])
299
- .filter((value, index, self) => self.indexOf(value) === index) // Get unique sizes
300
- : [];
301
-
302
- // Process regular tokens
303
- dictionary.allTokens.forEach((token) => {
304
- // Remove the isHigherTierToken check to include all tokens
305
- if (token.path[0] === "box-shadow" && token.path.length > 2) return;
306
- const prefix = isHigherTierToken(token.filePath) ? "g-theme-" : "g-";
307
- transformedTokens[`${prefix}${token.path.join("-")}`] = token.value;
308
- });
309
-
310
- // Process shadow tokens
311
- shadowSizes.forEach((size) => {
312
- transformedTokens[`g-theme-box-shadow-${size}`] =
313
- transformShadowTokensJSON(dictionary, size);
314
- });
315
-
316
- return JSON.stringify(transformedTokens, null, 2);
317
- },
318
- });
319
-
320
- /**
321
- * Register the CSS formatter
322
- * 1) Used to format the inner contents of the .[theme-name] ruleset for Storybook only or if you want to define tokens using a theme name
323
- */
324
- StyleDictionary.registerFormat({
325
- name: "css/variables-themed",
326
- format: function (dictionary) {
327
- return `.${theme} {\n${formatVariables(dictionary)}\n}\n`;
328
- },
329
- });
330
-
331
- /**
332
- * Define the base pixel value for rem conversion
333
- */
334
- const BASE_FONT_SIZE = 16; // Typically 16px = 1rem
335
-
336
- /**
337
- * Register the size/px-to-rem transform
338
- * 1) Used to convert px values to rem values
339
- * 2) Match only properties with px values
340
- * 3) Only transform if it's a valid px value
341
- */
342
- StyleDictionary.registerTransform({
343
- name: "size/px-to-rem",
344
- type: "value",
345
- matcher: function (prop) {
346
- /* 2 */
347
- return (
348
- prop &&
349
- prop.value &&
350
- typeof prop.value === "string" &&
351
- prop.value.endsWith("px")
352
- );
353
- },
354
- transform: function (prop) {
355
- if (!prop || !prop.value) return prop.value;
356
- /* 3 */
357
- const pxValue = prop.value.trim();
358
- if (!pxValue.endsWith("px")) return prop.value;
359
-
360
- const pixels = parseFloat(pxValue);
361
- if (isNaN(pixels)) return prop.value;
362
-
363
- const remValue = Number((pixels / BASE_FONT_SIZE).toFixed(4)).toString();
364
- return `${remValue}rem`;
365
- },
366
- });
367
-
368
- /**
369
- * Register the CSS formatter
370
- * 1) Used to format the inner contents of the :root ruleset for Storybook only or if you want to define tokens with theme prefix
371
- */
372
- StyleDictionary.registerFormat({
373
- name: "css/custom-variables",
374
- format: function (dictionary) {
375
- return `:root {\n${formatVariables(dictionary)}\n}`;
376
- },
377
- });
378
-
379
- /**
380
- * Register the name/theme-prefix transform
381
- * 1) Used to prefix the token name with the theme name
382
- * 2) If the token is from tier-2 or tier-3, prefix it with `GTheme` for JS
383
- * 3) Otherwise, prefix it with `G` for JS
384
- */
385
- StyleDictionary.registerTransform({
386
- name: "name/theme-prefix",
387
- type: "name",
388
- transform: function (token) {
389
- const cleanPath = token.path
390
- .map((segment) =>
391
- segment.startsWith("@") ? segment.substring(1) : segment,
392
- )
393
- .filter((segment) => segment !== "")
394
- .join("-");
395
-
396
- /* 2 */
397
- if (isHigherTierToken(token.filePath)) {
398
- return `GTheme${cleanPath
399
- .split("-")
400
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
401
- .join("")}`;
402
- }
403
-
404
- /* 3 */
405
- return `G${cleanPath
406
- .split("-")
407
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
408
- .join("")}`;
409
- },
410
- });
411
-
412
- /**
413
- * Register the custom/css transform group
414
- */
415
- StyleDictionary.registerTransformGroup({
416
- name: "custom/css",
417
- transforms: ["attribute/cti", "name/kebab", "size/px-to-rem"],
418
- });
419
-
420
- /**
421
- * Register the custom/js transform group
422
- */
423
- StyleDictionary.registerTransformGroup({
424
- name: "custom/js",
425
- transforms: ["attribute/cti", "name/theme-prefix", "size/px-to-rem"],
426
- });
427
-
428
- /**
429
- * Define the config
430
- * 1) Used to define the platforms, prefixes, etc. to build the tokens with/for
431
- */
432
- const config = {
433
- source: [`./tokens/core/**/*.json`, `./tokens/${theme}/**/*.json`],
434
- log: {
435
- // Set the log level to show errors, warnings, and info messages
436
- verbosity: "verbose",
437
- },
438
- platforms: {
439
- ts: {
440
- transformGroup: "custom/js",
441
- prefix: "G",
442
- buildPath: `./dist/js/${theme}/`,
443
- filter: {
444
- attributes: {
445
- category: "theme",
446
- },
447
- },
448
- files: [
449
- {
450
- destination: "style-dictionary.js",
451
- format: "javascript/es6",
452
- },
453
- {
454
- destination: "style-dictionary.d.ts",
455
- format: "typescript/es6-declarations",
456
- },
457
- ],
458
- },
459
- css: {
460
- transformGroup: "custom/css",
461
- prefix: "g",
462
- buildPath: `./dist/css/${theme}/`,
463
- files: [
464
- {
465
- destination: "tokens.css",
466
- format: "css/custom-variables",
467
- },
468
- {
469
- destination: `${theme}.css`,
470
- format: "css/variables-themed",
471
- },
472
- ],
473
- },
474
- json: {
475
- transformGroup: "custom/css",
476
- prefix: "g",
477
- buildPath: `./dist/json/${theme}/`,
478
- files: [
479
- {
480
- destination: "tokens.json",
481
- format: "json/flat/custom",
482
- },
483
- ],
484
- },
485
- },
486
- };
487
-
488
- return config;
489
- };
490
-
491
- /**
492
- * Build the tokens
493
- * 1) If no theme is specified, build all themes
494
- * 2) Otherwise, build the specified theme
495
- */
496
- if (!theme) {
497
- console.log("🚧 No theme specified, building all themes...");
498
- AVAILABLE_THEMES.forEach((themeName) => {
499
- console.log(`\n🏗️ Building ${themeName.toUpperCase()} theme`);
500
- const themeConfig = getStyleDictionaryConfig(themeName);
501
- const StyleDictionaryExtended = new StyleDictionary(themeConfig);
502
- StyleDictionaryExtended.buildAllPlatforms();
503
- });
504
- } else {
505
- console.log(`🚧 Building ${theme.toUpperCase()} theme`);
506
- const config = getStyleDictionaryConfig(theme);
507
- const StyleDictionaryExtended = new StyleDictionary(config);
508
- StyleDictionaryExtended.buildAllPlatforms();
509
- }
package/demo.html DELETED
@@ -1,171 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Style Dictionary Demo</title>
7
- <link rel="stylesheet" href="./dist/css/grantcodes/tokens.css" />
8
- <style>
9
- .color {
10
- display: flex;
11
- align-items: center;
12
- justify-content: center;
13
- padding: 1rem;
14
- min-height: 12rem;
15
- }
16
- </style>
17
- </head>
18
- <body>
19
- <h1>Style Dictionary Demo</h1>
20
- <p>This is a demo of the Style Dictionary design tokens.</p>
21
-
22
- <h2>Colors</h2>
23
- <span
24
- class="color"
25
- style="
26
- background-color: var(--g-theme-color-background-default);
27
- color: var(--g-theme-color-content-default);
28
- "
29
- >Default</span
30
- >
31
- <span
32
- class="color"
33
- style="
34
- background-color: var(--g-theme-color-background-default-hover);
35
- color: var(--g-theme-color-content-default-hover);
36
- "
37
- >Default Hover</span
38
- >
39
- <span
40
- class="color"
41
- style="
42
- background-color: var(--g-theme-color-background-subtle);
43
- color: var(--g-theme-color-content-subtle);
44
- "
45
- >Subtle</span
46
- >
47
- <span
48
- class="color"
49
- style="
50
- background-color: var(--g-theme-color-background-subtle-hover);
51
- color: var(--g-theme-color-content-subtle-hover);
52
- "
53
- >Subtle Hover</span
54
- >
55
- <span
56
- class="color"
57
- style="
58
- background-color: var(--g-theme-color-background-knockout);
59
- color: var(--g-theme-color-content-knockout);
60
- "
61
- >Knockout</span
62
- >
63
- <span
64
- class="color"
65
- style="
66
- background-color: var(--g-theme-color-background-brand);
67
- color: var(--g-theme-color-content-brand);
68
- "
69
- >Brand</span
70
- >
71
- <span
72
- class="color"
73
- style="
74
- background-color: var(--g-theme-color-background-brand-hover);
75
- color: var(--g-theme-color-content-brand-hover);
76
- "
77
- >Brand Hover</span
78
- >
79
- <span
80
- class="color"
81
- style="
82
- background-color: var(--g-theme-color-background-brand-knockout);
83
- color: var(--g-theme-color-content-brand-knockout);
84
- "
85
- >Brand Knockout</span
86
- >
87
- <span
88
- class="color"
89
- style="
90
- background-color: var(--g-theme-color-background-brand-knockout-hover);
91
- color: var(--g-theme-color-content-brand-knockout-hover);
92
- "
93
- >Brand Knockout Hover</span
94
- >
95
- <span
96
- class="color"
97
- style="
98
- background-color: var(--g-theme-color-background-utility-error);
99
- color: var(--g-theme-color-content-utility-error);
100
- "
101
- >Utility Error</span
102
- >
103
- <span
104
- class="color"
105
- style="
106
- background-color: var(--g-theme-color-background-utility-warning);
107
- color: var(--g-theme-color-content-utility-warning);
108
- "
109
- >Utility Warning</span
110
- >
111
- <span
112
- class="color"
113
- style="
114
- background-color: var(--g-theme-color-background-utility-success);
115
- color: var(--g-theme-color-content-utility-success);
116
- "
117
- >Utility Success</span
118
- >
119
- <span
120
- class="color"
121
- style="
122
- background-color: var(--g-theme-color-background-utility-info);
123
- color: var(--g-theme-color-content-utility-info);
124
- "
125
- >Utility Info</span
126
- >
127
- <span
128
- class="color"
129
- style="
130
- background-color: var(--g-theme-color-background-disabled);
131
- color: var(--g-theme-color-content-disabled);
132
- "
133
- >Disabled</span
134
- >
135
- <span
136
- class="color"
137
- style="
138
- background-color: var(--g-theme-color-background-transparent);
139
- color: var(--g-theme-color-content-transparent);
140
- "
141
- >Transparent</span
142
- >
143
- <span
144
- class="color"
145
- style="
146
- background-color: var(--g-theme-color-background-transparent-strong);
147
- color: var(--g-theme-color-content-transparent-strong);
148
- "
149
- >Transparent Strong</span
150
- >
151
-
152
- <h2>Typography</h2>
153
- <p style="font: var(--g-theme-typography-display-default)">
154
- Display Default
155
- </p>
156
- <p style="font: var(--g-theme-typography-display-sm)">Display Small</p>
157
- <p style="font: var(--g-theme-typography-headline-lg)">Headline Large</p>
158
- <p style="font: var(--g-theme-typography-headline-default)">
159
- Headline Default
160
- </p>
161
- <p style="font: var(--g-theme-typography-headline-sm)">Headline Small</p>
162
- <p style="font: var(--g-theme-typography-title-lg)">Title Large</p>
163
- <p style="font: var(--g-theme-typography-title-default)">Title Default</p>
164
- <p style="font: var(--g-theme-typography-title-sm)">Title Small</p>
165
- <p style="font: var(--g-theme-typography-label-lg)">Label Large</p>
166
- <p style="font: var(--g-theme-typography-label-default)">Label Default</p>
167
- <p style="font: var(--g-theme-typography-label-sm)">Label Small</p>
168
- <p style="font: var(--g-theme-typography-body-lg)">Body Large</p>
169
- <p style="font: var(--g-theme-typography-body-default)">Body Default</p>
170
- </body>
171
- </html>
@@ -1,13 +0,0 @@
1
- /**
2
- * Get a scale of lightness values
3
- * @param {number} min - The minimum lightness value
4
- * @param {number} max - The maximum lightness value
5
- * @param {number} steps - The number of steps in the scale
6
- * @returns {number[]} - The lightness steps
7
- */
8
- const getLightnessScale = (min = 26, max = 97, steps = 9) => {
9
- const step = (max - min) / steps;
10
- return Array.from({ length: steps }, (_, i) => Math.round(min + step * i));
11
- };
12
-
13
- export { getLightnessScale };