@grantcodes/style-dictionary 1.2.1 → 1.3.1

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 (70) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/css/grantcodes/grantcodes.css +367 -0
  3. package/dist/css/grantcodes/tokens.css +367 -0
  4. package/dist/css/todomap/todomap.css +200 -0
  5. package/dist/css/todomap/tokens.css +200 -0
  6. package/dist/css/wireframe/tokens.css +426 -0
  7. package/dist/css/wireframe/wireframe.css +426 -0
  8. package/dist/js/grantcodes/style-dictionary.d.ts +361 -0
  9. package/dist/js/grantcodes/style-dictionary.js +386 -0
  10. package/dist/js/todomap/style-dictionary.d.ts +202 -0
  11. package/dist/js/todomap/style-dictionary.js +220 -0
  12. package/dist/js/wireframe/style-dictionary.d.ts +414 -0
  13. package/dist/js/wireframe/style-dictionary.js +427 -0
  14. package/dist/json/grantcodes/tokens.json +351 -0
  15. package/dist/json/todomap/tokens.json +200 -0
  16. package/dist/json/wireframe/tokens.json +404 -0
  17. package/package.json +66 -61
  18. package/.turbo/turbo-build.log +0 -45
  19. package/biome.json +0 -9
  20. package/build.js +0 -10
  21. package/config.js +0 -485
  22. package/demo.html +0 -171
  23. package/lib/color-generator.js +0 -13
  24. package/lib/get-style-dictionary-config.js +0 -223
  25. package/lib/get-themes.js +0 -10
  26. package/lib/index.js +0 -3
  27. package/tests/tokens.test.js +0 -87
  28. package/tokens/core/tier-1-definitions/colors.json +0 -175
  29. package/tokens/core/tier-1-definitions/z-index.json +0 -29
  30. package/tokens/grantcodes/tier-1-definitions/animation.json +0 -27
  31. package/tokens/grantcodes/tier-1-definitions/borders.json +0 -36
  32. package/tokens/grantcodes/tier-1-definitions/colors.json +0 -35
  33. package/tokens/grantcodes/tier-1-definitions/shadows.json +0 -39
  34. package/tokens/grantcodes/tier-1-definitions/typography.json +0 -133
  35. package/tokens/grantcodes/tier-2-usage/00-colors-background.json +0 -72
  36. package/tokens/grantcodes/tier-2-usage/00-colors-border.json +0 -42
  37. package/tokens/grantcodes/tier-2-usage/00-colors-content.json +0 -45
  38. package/tokens/grantcodes/tier-2-usage/animation.json +0 -23
  39. package/tokens/grantcodes/tier-2-usage/borders.json +0 -26
  40. package/tokens/grantcodes/tier-2-usage/shadows.json +0 -39
  41. package/tokens/grantcodes/tier-2-usage/typography-usage.json +0 -277
  42. package/tokens/grantcodes/tier-3-components/button.json +0 -94
  43. package/tokens/grantcodes/tier-3-components/focus-ring.json +0 -26
  44. package/tokens/grantcodes/tier-3-components/form.json +0 -69
  45. package/tokens/grantcodes/tier-3-components/link.json +0 -39
  46. package/tokens/todomap/tier-1-definitions/colors.json +0 -92
  47. package/tokens/todomap/tier-1-definitions/typography.json +0 -10
  48. package/tokens/todomap/tier-2-usage/00-colors-background.json +0 -36
  49. package/tokens/todomap/tier-2-usage/00-colors-content.json +0 -33
  50. package/tokens/todomap/tier-2-usage/typography-usage.json +0 -20
  51. package/tokens/todomap/tier-3-components/button.json +0 -141
  52. package/tokens/todomap/tier-3-components/focus-ring.json +0 -26
  53. package/tokens/todomap/tier-3-components/form.json +0 -69
  54. package/tokens/todomap/tier-3-components/link.json +0 -39
  55. package/tokens/wireframe/tier-1-definitions/animation.json +0 -18
  56. package/tokens/wireframe/tier-1-definitions/borders.json +0 -42
  57. package/tokens/wireframe/tier-1-definitions/colors.json +0 -36
  58. package/tokens/wireframe/tier-1-definitions/shadows.json +0 -39
  59. package/tokens/wireframe/tier-1-definitions/typography.json +0 -130
  60. package/tokens/wireframe/tier-2-usage/00-colors-background.json +0 -86
  61. package/tokens/wireframe/tier-2-usage/00-colors-border.json +0 -42
  62. package/tokens/wireframe/tier-2-usage/00-colors-content.json +0 -45
  63. package/tokens/wireframe/tier-2-usage/animation.json +0 -24
  64. package/tokens/wireframe/tier-2-usage/borders.json +0 -33
  65. package/tokens/wireframe/tier-2-usage/shadows.json +0 -39
  66. package/tokens/wireframe/tier-2-usage/typography-usage.json +0 -445
  67. package/tokens/wireframe/tier-3-components/button.json +0 -94
  68. package/tokens/wireframe/tier-3-components/focus-ring.json +0 -26
  69. package/tokens/wireframe/tier-3-components/form.json +0 -69
  70. package/tokens/wireframe/tier-3-components/link.json +0 -39
@@ -1,223 +0,0 @@
1
- import { join } from "node:path";
2
- import { SYSTEM } from "../config.js";
3
-
4
- console.log("get style dictionary config");
5
-
6
- /**
7
- * Get a style dictionary config for the given brand.
8
- *
9
- * @param {string} brand The brand folder name
10
- *
11
- * @return {import("style-dictionary").Config} The style dictionary config
12
- */
13
- const getStyleDictionaryConfig = (theme) => ({
14
- source: [
15
- join(import.meta.dirname, "../tokens/core/tier-1-definitions/**/*.js"),
16
- // join(import.meta.dirname, "../tokens/tier-2-usage/**/*.js"),
17
- // join(import.meta.dirname, "../tokens/tier-3-components/**/*.js"),
18
- join(
19
- import.meta.dirname,
20
- `../tokens/themes/${theme}/tier-1-definitions/**/*.js`,
21
- ),
22
- join(import.meta.dirname, `../tokens/themes/${theme}/tier-2-usage/**/*.js`),
23
- join(
24
- import.meta.dirname,
25
- `../tokens/themes/${theme}/tier-3-components/**/*.js`,
26
- ),
27
- ],
28
- log: {
29
- verbosity: "verbose",
30
- },
31
- platforms: {
32
- css: {
33
- transformGroup: "css",
34
- buildPath: `dist/css/${theme}/`,
35
- prefix: SYSTEM,
36
- files: [
37
- {
38
- destination: "style-dictionary.css",
39
- format: "css/variables",
40
- options: {
41
- outputReferences: true,
42
- },
43
- },
44
- // {
45
- // destination: 'fonts.css',
46
- // format: 'css/fonts.css',
47
- // options: {
48
- // outputReferences: true,
49
- // },
50
- // },
51
- ],
52
- },
53
- scss: {
54
- transformGroup: "scss",
55
- buildPath: `dist/scss/${theme}/`,
56
- prefix: SYSTEM,
57
- files: [
58
- {
59
- destination: "_style-dictionary.scss",
60
- format: "css/variables",
61
- options: {
62
- outputReferences: true,
63
- selector: "@mixin css-variables",
64
- },
65
- },
66
- // {
67
- // destination: '_fonts.scss',
68
- // format: 'css/fonts.css',
69
- // options: {
70
- // outputReferences: true,
71
- // },
72
- // },
73
- ],
74
- },
75
- js: {
76
- transformGroup: "js",
77
- buildPath: `dist/js/${theme}/`,
78
- prefix: SYSTEM,
79
- files: [
80
- {
81
- format: "javascript/es6",
82
- destination: "style-dictionary.js",
83
- },
84
- ],
85
- },
86
- // android: {
87
- // transformGroup: 'android',
88
- // buildPath: `dist/android/${theme}/`,
89
- // files: [
90
- // {
91
- // destination: 'font_dimens.xml',
92
- // format: 'android/fontDimens',
93
- // },
94
- // {
95
- // destination: 'colors.xml',
96
- // format: 'android/colors',
97
- // },
98
- // ],
99
- // },
100
- // compose: {
101
- // transformGroup: 'compose',
102
- // buildPath: `dist/compose/${theme}/`,
103
- // files: [
104
- // {
105
- // destination: 'StyleDictionaryColor.kt',
106
- // format: 'compose/object',
107
- // className: 'StyleDictionaryColor',
108
- // packageName: 'StyleDictionaryColor',
109
- // filter: {
110
- // attributes: {
111
- // category: 'color',
112
- // },
113
- // },
114
- // },
115
- // {
116
- // destination: 'StyleDictionarySize.kt',
117
- // format: 'compose/object',
118
- // className: 'StyleDictionarySize',
119
- // packageName: 'StyleDictionarySize',
120
- // type: 'float',
121
- // filter: {
122
- // attributes: {
123
- // category: 'size',
124
- // },
125
- // },
126
- // },
127
- // ],
128
- // },
129
- // ios: {
130
- // transformGroup: 'ios',
131
- // buildPath: `dist/ios/${theme}/`,
132
- // files: [
133
- // {
134
- // destination: 'StyleDictionaryColor.h',
135
- // format: 'ios/colors.h',
136
- // className: 'StyleDictionaryColor',
137
- // type: 'StyleDictionaryColorName',
138
- // filter: {
139
- // attributes: {
140
- // category: 'color',
141
- // },
142
- // },
143
- // },
144
- // {
145
- // destination: 'StyleDictionaryColor.m',
146
- // format: 'ios/colors.m',
147
- // className: 'StyleDictionaryColor',
148
- // type: 'StyleDictionaryColorName',
149
- // filter: {
150
- // attributes: {
151
- // category: 'color',
152
- // },
153
- // },
154
- // },
155
- // {getStyleDictionaryConfig
156
- // destination: 'StyleDictionarySize.h',
157
- // format: 'ios/static.h',
158
- // className: 'StyleDictionarySize',
159
- // type: 'float',
160
- // filter: {
161
- // attributes: {
162
- // category: 'size',
163
- // },
164
- // },
165
- // },
166
- // {
167
- // destination: 'StyleDictionarySize.m',
168
- // format: 'ios/static.m',
169
- // className: 'StyleDictionarySize',
170
- // type: 'float',
171
- // filter: {
172
- // attributes: {
173
- // category: 'size',
174
- // },
175
- // },
176
- // },
177
- // ],
178
- // },
179
- // 'ios-swift': {
180
- // transformGroup: 'ios-swift',
181
- // buildPath: `dist/ios-swift/${theme}/`,
182
- // files: [
183
- // {
184
- // destination: 'StyleDictionary.swift',
185
- // format: 'ios-swift/class.swift',
186
- // className: 'StyleDictionary',
187
- // filter: {},
188
- // },
189
- // ],
190
- // },
191
- // 'ios-swift-separate-enums': {
192
- // transformGroup: 'ios-swift-separate',
193
- // buildPath: `dist/ios-swift/${theme}/`,
194
- // files: [
195
- // {
196
- // destination: 'StyleDictionaryColor.swift',
197
- // format: 'ios-swift/enum.swift',
198
- // className: 'StyleDictionaryColor',
199
- // filter: {
200
- // attributes: {
201
- // category: 'color',
202
- // },
203
- // },
204
- // },
205
- // {
206
- // destination: 'StyleDictionarySize.swift',
207
- // format: 'ios-swift/enum.swift',
208
- // className: 'StyleDictionarySize',
209
- // type: 'float',
210
- // filter: {
211
- // attributes: {
212
- // category: 'size',
213
- // },
214
- // },
215
- // },
216
- // ],
217
- // },
218
- },
219
- });
220
-
221
- console.log("get style dictionary config");
222
-
223
- export { getStyleDictionaryConfig };
package/lib/get-themes.js DELETED
@@ -1,10 +0,0 @@
1
- import { readdirSync } from "node:fs";
2
-
3
- /**
4
- * Helper functions to get a list of supported brands.
5
- *
6
- * @return {string[]} List of brands found in the tokens/brands folder
7
- */
8
- const getThemes = () => readdirSync("./tokens/themes");
9
-
10
- export { getThemes };
package/lib/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from "./color-generator.js";
2
- export * from "./get-themes.js";
3
- export * from "./get-style-dictionary-config.js";
@@ -1,87 +0,0 @@
1
- import { describe, it } from "node:test";
2
- import test from "node:test";
3
- import assert from "node:assert";
4
- import StyleDictionaryPackage from "style-dictionary";
5
-
6
- import { TOKEN_TREE } from "../config.js";
7
- import { getThemes, getStyleDictionaryConfig } from "../lib/index.js";
8
-
9
- const getTokens = async () => {
10
- const themes = getThemes();
11
-
12
- const tokens = {};
13
-
14
- for (const brand of brands) {
15
- const config = getStyleDictionaryConfig(brand);
16
- const dictionary = new StyleDictionaryPackage(config);
17
- const brandTokens = await dictionary.getPlatformTokens("css");
18
-
19
- tokens[brand] = brandTokens.allTokens;
20
- }
21
-
22
- return tokens;
23
- };
24
-
25
- const tokens = await getTokens();
26
-
27
- describe("Token formatting", () => {
28
- it("Should have multiple tokens", () => {
29
- for (const brandTokens of Object.values(tokens)) {
30
- assert.ok(Object.keys(brandTokens).length > 1);
31
- }
32
- });
33
-
34
- it("Should be prefixed", () => {
35
- if (SYSTEM) {
36
- for (const brandTokens of Object.values(tokens)) {
37
- const tokenNames = brandTokens.map((token) => token.name);
38
- for (const tokenName of tokenNames) {
39
- assert.ok(tokenName.startsWith(`${SYSTEM}-`));
40
- }
41
- }
42
- }
43
- });
44
-
45
- it("Should have a category", () => {
46
- for (const brandTokens of Object.values(tokens)) {
47
- for (const token of brandTokens) {
48
- assert.ok(
49
- TOKEN_LEVELS.category.includes(token?.attributes?.category),
50
- `The token ${token.name} has the category ${token?.attributes?.category} which is not in the defined categories (${TOKEN_LEVELS.category.join(", ")}).`,
51
- );
52
- }
53
- }
54
- });
55
-
56
- it("Should have a valid css value", () => {
57
- for (const brandTokens of Object.values(tokens)) {
58
- for (const token of brandTokens) {
59
- const tokenType = typeof token.value;
60
-
61
- assert.ok(
62
- ["string", "number"].includes(tokenType),
63
- `The token ${token.name} has an invalid type (${tokenType}).`,
64
- );
65
- }
66
- }
67
- });
68
-
69
- // it("Should have valid references", () => {
70
- // for (const brandTokens of Object.values(tokens)) {
71
- // for (const token of brandTokens) {
72
- // if (token?.original?.value?.includes?.("{")) {
73
- // const references = token.original.value
74
- // .replace(/{/g, "")
75
- // .replace(/}/g, "")
76
- // .trim()
77
- // .split(", ");
78
- // console.log(reference);
79
- // // assert.ok(
80
- // // brandTokens.find((t) => t.name === token.attributes.reference),
81
- // // `The token ${token.name} references a token that does not exist (${token.attributes.reference}).`,
82
- // // );
83
- // }
84
- // }
85
- // }
86
- // });
87
- });
@@ -1,175 +0,0 @@
1
- {
2
- "color": {
3
- "neutral": {
4
- "white": {
5
- "value": "oklch(100% 0 0)"
6
- },
7
- "100": {
8
- "value": "oklch(95% 0 0)"
9
- },
10
- "200": {
11
- "value": "oklch(90% 0 0)"
12
- },
13
- "300": {
14
- "value": "oklch(80% 0 0)"
15
- },
16
- "400": {
17
- "value": "oklch(70% 0 0)"
18
- },
19
- "500": {
20
- "value": "oklch(60% 0 0)"
21
- },
22
- "600": {
23
- "value": "oklch(50% 0 0)"
24
- },
25
- "700": {
26
- "value": "oklch(40% 0 0)"
27
- },
28
- "800": {
29
- "value": "oklch(30% 0 0)"
30
- },
31
- "900": {
32
- "value": "oklch(20% 0 0)"
33
- },
34
- "black": {
35
- "value": "oklch(0% 0 0)"
36
- }
37
- },
38
- "utility": {
39
- "green": {
40
- "100": {
41
- "value": "oklch(96.73% 0.0537 129.1)"
42
- },
43
- "200": {
44
- "value": "oklch(93.45% 0.107 131.96)"
45
- },
46
- "300": {
47
- "value": "oklch(87.97% 0.1546 135.05)"
48
- },
49
- "400": {
50
- "value": "oklch(81.78% 0.1827 137.62)"
51
- },
52
- "500": {
53
- "value": "oklch(74.01% 0.2132 139.87)"
54
- },
55
- "600": {
56
- "value": "oklch(65.44% 0.1981 141.12)"
57
- },
58
- "700": {
59
- "value": "oklch(57.11% 0.1795 142.12)"
60
- },
61
- "800": {
62
- "value": "oklch(48.67% 0.1572 142.68)"
63
- },
64
- "900": {
65
- "value": "oklch(42.59% 0.1358 143.3)"
66
- }
67
- },
68
- "blue": {
69
- "100": {
70
- "value": "oklch(95.86% 0.0542 179.13)"
71
- },
72
- "200": {
73
- "value": "oklch(92.82% 0.0973 184.41)"
74
- },
75
- "300": {
76
- "value": "oklch(90.54% 0.1282 189.63)"
77
- },
78
- "500": {
79
- "value": "oklch(81.86% 0.141005 208.7047)"
80
- },
81
- "600": {
82
- "value": "oklch(68.89% 0.125872 220.4932)"
83
- },
84
- "700": {
85
- "value": "oklch(56.7% 0.116289 232.4331)"
86
- },
87
- "800": {
88
- "value": "oklch(45.75% 0.107158 241.2805)"
89
- },
90
- "900": {
91
- "value": "oklch(37.55% 0.1037 249.04)"
92
- }
93
- },
94
- "yellow": {
95
- "100": {
96
- "value": "oklch(97.66% 0.0606 103.43)"
97
- },
98
- "200": {
99
- "value": "oklch(95.72% 0.1147 103.53)"
100
- },
101
- "300": {
102
- "value": "oklch(93.47% 0.1552 102.21)"
103
- },
104
- "400": {
105
- "value": "oklch(91.68% 0.1745 101.08)"
106
- },
107
- "500": {
108
- "value": "oklch(88.99% 0.183778 97.6996)"
109
- },
110
- "600": {
111
- "value": "oklch(78.68% 0.162 96.43)"
112
- },
113
- "700": {
114
- "value": "oklch(68.35% 0.14027 94.7302)"
115
- },
116
- "800": {
117
- "value": "oklch(58.04% 0.1189 93.71)"
118
- },
119
- "900": {
120
- "value": "oklch(50.09% 0.1025 92.6)"
121
- }
122
- },
123
- "red": {
124
- "100": {
125
- "value": "oklch(94.96% 0.0395 73.45)"
126
- },
127
- "200": {
128
- "value": "oklch(89.21% 0.076552 65.9429)"
129
- },
130
- "300": {
131
- "value": "oklch(82.67% 0.1156 57.65)"
132
- },
133
- "400": {
134
- "value": "oklch(77.04% 0.1486 49.15)"
135
- },
136
- "500": {
137
- "value": "oklch(69.31% 0.203172 39.994)"
138
- },
139
- "600": {
140
- "value": "oklch(60.03% 0.1938 35.81)"
141
- },
142
- "700": {
143
- "value": "oklch(51.18% 0.1802 32.56)"
144
- },
145
- "800": {
146
- "value": "oklch(42.79% 0.16 30.38)"
147
- },
148
- "900": {
149
- "value": "oklch(36.89% 0.1443 28.98)"
150
- }
151
- }
152
- },
153
- "transparent": {
154
- "0": {
155
- "value": "oklch(100% 0 0 / 0)"
156
- },
157
- "10": {
158
- "value": "oklch(100% 0 0 / 0.1)"
159
- },
160
- "25": {
161
- "value": "oklch(100% 0 0 / 0.25)"
162
- },
163
- "50": {
164
- "value": "oklch(100% 0 0 / 0.5)"
165
- },
166
- "75": {
167
- "value": "oklch(100% 0 0 / 0.75)"
168
- },
169
- "90": {
170
- "value": "oklch(100% 0 0 / 0.9)"
171
- }
172
- }
173
- }
174
- }
175
-
@@ -1,29 +0,0 @@
1
- {
2
- "z-index": {
3
- "top": {
4
- "value": "99999"
5
- },
6
- "500": {
7
- "value": "500"
8
- },
9
- "400": {
10
- "value": "400"
11
- },
12
- "300": {
13
- "value": "300"
14
- },
15
- "200": {
16
- "value": "200"
17
- },
18
- "100": {
19
- "value": "100"
20
- },
21
- "0": {
22
- "value": "0"
23
- },
24
- "bottom": {
25
- "value": "-100"
26
- }
27
- }
28
- }
29
-
@@ -1,27 +0,0 @@
1
- {
2
- "animation": {
3
- "duration": {
4
- "10": {
5
- "value": "100ms"
6
- },
7
- "20": {
8
- "value": "200ms"
9
- },
10
- "30": {
11
- "value": "300ms"
12
- },
13
- "40": {
14
- "value": "400ms"
15
- }
16
- },
17
- "timing-function": {
18
- "ease": {
19
- "value": "ease-in-out"
20
- },
21
- "linear": {
22
- "value": "linear"
23
- }
24
- }
25
- }
26
- }
27
-
@@ -1,36 +0,0 @@
1
- {
2
- "border": {
3
- "radius": {
4
- "square": {
5
- "value": "0"
6
- },
7
- "125": {
8
- "value": "0.125rem"
9
- },
10
- "250": {
11
- "value": "0.25rem"
12
- },
13
- "500": {
14
- "value": "0.5rem"
15
- },
16
- "1000": {
17
- "value": "1rem"
18
- },
19
- "rounded": {
20
- "value": "50%"
21
- }
22
- },
23
- "width": {
24
- "1": {
25
- "value": "1px"
26
- },
27
- "2": {
28
- "value": "2px"
29
- },
30
- "4": {
31
- "value": "4px"
32
- }
33
- }
34
- }
35
- }
36
-
@@ -1,35 +0,0 @@
1
- {
2
- "color": {
3
- "brand": {
4
- "purple": {
5
- "100": {
6
- "value": "oklch(95% 0.04 279.42)"
7
- },
8
- "200": {
9
- "value": "oklch(90% 0.08 279.42)"
10
- },
11
- "300": {
12
- "value": "oklch(82% 0.12 279.42)"
13
- },
14
- "400": {
15
- "value": "oklch(74% 0.17 279.42)"
16
- },
17
- "500": {
18
- "value": "oklch(65% 0.22 279.42)"
19
- },
20
- "600": {
21
- "value": "oklch(55% 0.26 279.42)"
22
- },
23
- "700": {
24
- "value": "oklch(45% 0.24 279.42)"
25
- },
26
- "800": {
27
- "value": "oklch(35% 0.18 279.42)"
28
- },
29
- "900": {
30
- "value": "oklch(25% 0.12 279.42)"
31
- }
32
- }
33
- }
34
- }
35
- }
@@ -1,39 +0,0 @@
1
- {
2
- "shadow": {
3
- "sm": {
4
- "x": {
5
- "value": "0px"
6
- },
7
- "y": {
8
- "value": "4px"
9
- },
10
- "blur": {
11
- "value": "4px"
12
- },
13
- "spread": {
14
- "value": "0px"
15
- },
16
- "color": {
17
- "value": "#00000040"
18
- }
19
- },
20
- "md": {
21
- "x": {
22
- "value": "0px"
23
- },
24
- "y": {
25
- "value": "8px"
26
- },
27
- "blur": {
28
- "value": "6px"
29
- },
30
- "spread": {
31
- "value": "-6px"
32
- },
33
- "color": {
34
- "value": "#0000001a"
35
- }
36
- }
37
- }
38
- }
39
-