@servicetitan/hammer-token 2.1.1 → 2.2.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 (51) hide show
  1. package/.turbo/turbo-build.log +4 -1
  2. package/CHANGELOG.md +14 -0
  3. package/build/web/core/component-variables.scss +139 -0
  4. package/build/web/core/component.js +645 -0
  5. package/build/web/core/component.scss +69 -0
  6. package/build/web/core/css-utils/border.css +45 -29
  7. package/build/web/core/css-utils/color.css +219 -103
  8. package/build/web/core/css-utils/font.css +45 -43
  9. package/build/web/core/css-utils/spacing.css +71 -1
  10. package/build/web/core/css-utils/utils.css +562 -368
  11. package/build/web/core/index.js +2 -1
  12. package/build/web/core/raw.js +28 -24
  13. package/build/web/core/semantic-variables.scss +28 -24
  14. package/build/web/core/semantic.js +44 -24
  15. package/build/web/core/semantic.scss +13 -11
  16. package/config.js +97 -23
  17. package/package.json +3 -2
  18. package/src/global/primitive/breakpoint.js +19 -0
  19. package/src/global/primitive/color.js +231 -0
  20. package/src/global/primitive/duration.js +16 -0
  21. package/src/global/primitive/font.js +60 -0
  22. package/src/global/primitive/radius.js +31 -0
  23. package/src/global/primitive/size.js +55 -0
  24. package/src/global/primitive/transition.js +16 -0
  25. package/src/theme/core/background.js +148 -0
  26. package/src/theme/core/border.js +93 -0
  27. package/src/theme/core/component/button.js +708 -0
  28. package/src/theme/core/component/checkbox.js +405 -0
  29. package/src/theme/core/focus.js +35 -0
  30. package/src/theme/core/foreground.js +148 -0
  31. package/src/theme/core/overlay.js +137 -0
  32. package/src/theme/core/shadow.js +29 -0
  33. package/src/theme/core/status.js +49 -0
  34. package/src/theme/core/typography.js +82 -0
  35. package/src/utils/css-utils-format-utils.js +104 -34
  36. package/type/types.ts +75 -0
  37. package/src/global/primitive/breakpoint.json +0 -19
  38. package/src/global/primitive/color.json +0 -231
  39. package/src/global/primitive/duration.json +0 -16
  40. package/src/global/primitive/font.json +0 -60
  41. package/src/global/primitive/radius.json +0 -31
  42. package/src/global/primitive/size.json +0 -55
  43. package/src/global/primitive/transition.json +0 -16
  44. package/src/theme/core/background.json +0 -144
  45. package/src/theme/core/border.json +0 -87
  46. package/src/theme/core/focus.json +0 -31
  47. package/src/theme/core/foreground.json +0 -132
  48. package/src/theme/core/overlay.json +0 -134
  49. package/src/theme/core/shadow.json +0 -25
  50. package/src/theme/core/status.json +0 -46
  51. package/src/theme/core/typography.json +0 -79
package/config.js CHANGED
@@ -37,7 +37,7 @@ const nonColorTokens = [
37
37
  ];
38
38
 
39
39
  StyleDictionary.registerFormat({
40
- name: `custom/semantic-variables`,
40
+ name: `custom/variables-map`,
41
41
  formatter: function ({ dictionary }) {
42
42
  const light = dictionary.allTokens
43
43
  .filter((token) => {
@@ -183,7 +183,7 @@ StyleDictionary.registerFormat({
183
183
  StyleDictionary.registerFormat({
184
184
  name: `custom/CSSUtils/All`,
185
185
  formatter: function ({ dictionary }) {
186
- const allTokens = dictionary.allTokens
186
+ const colorTokens = dictionary.allTokens
187
187
  .map((token) => {
188
188
  let value = getVarValue(dictionary, token);
189
189
  let name = `${token.name.replace("Default", "")}`;
@@ -202,6 +202,18 @@ StyleDictionary.registerFormat({
202
202
  let darkValue = getVarValue(dictionary, token, true);
203
203
  return generateBorderClasses(name, value, darkValue);
204
204
  }
205
+ return null;
206
+ })
207
+ .flat()
208
+ .filter((t) => t != null)
209
+ .map((t) => `${t}`)
210
+ .sort((a, b) => a.localeCompare(b))
211
+ .join(`\n`);
212
+ const nonColorTokens = dictionary.allTokens
213
+ .map((token) => {
214
+ let value = getVarValue(dictionary, token);
215
+ let name = `${token.name.replace("Default", "")}`;
216
+
205
217
  if (name.startsWith("border")) {
206
218
  return generateBorderClasses(name, value);
207
219
  }
@@ -219,17 +231,52 @@ StyleDictionary.registerFormat({
219
231
  .sort((a, b) => a.localeCompare(b))
220
232
  .join(`\n`);
221
233
 
234
+ const colorFallbackTokens = dictionary.allTokens
235
+ .map((token) => {
236
+ let value = getVarValue(dictionary, token);
237
+ let name = `${token.name.replace("Default", "")}`;
238
+
239
+ if (
240
+ name.startsWith("status-color") ||
241
+ name.startsWith("foreground-color") ||
242
+ name.startsWith("background-color") ||
243
+ name.startsWith("overlay-color")
244
+ ) {
245
+ return generateColorClasses(name, value);
246
+ }
247
+ if (name.startsWith("border-color")) {
248
+ return generateBorderClasses(name, value);
249
+ }
250
+ return null;
251
+ })
252
+ .flat()
253
+ .filter((t) => t != null)
254
+ .map((t) => `${t}`)
255
+ .sort((a, b) => a.localeCompare(b))
256
+ .join(`\n`);
257
+
222
258
  // Manually adding .sr-only
223
- const withSr = allTokens.concat(
259
+ const withSr = nonColorTokens.concat(
224
260
  "\n",
225
261
  ".sr-only {border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding-block: 0; padding-inline: 0; position: absolute; white-space: nowrap; width: 1px;}",
226
262
  );
227
- return `${withSr}
228
263
 
229
- @layer starter, reset, base, state, application;
264
+ return `@layer starter, reset, base, state, application;
265
+
266
+ ${withSr}
267
+ ${colorFallbackTokens}
268
+
269
+ @supports (color: light-dark(#fff, #000)) {
270
+ ${colorTokens.replaceAll("\n", "\n ")}
271
+ }
230
272
 
231
273
  @layer application {
232
- ${withSr.replaceAll("\n", "\n ")}
274
+ ${withSr.replaceAll("\n", "\n ")}
275
+ ${colorFallbackTokens.replaceAll("\n", "\n ")}
276
+
277
+ @supports (color: light-dark(#fff, #000)) {
278
+ ${colorTokens.replaceAll("\n", "\n ")}
279
+ }
233
280
  }`;
234
281
  },
235
282
  });
@@ -272,8 +319,8 @@ const themes = getDirectories(`src/theme`);
272
319
 
273
320
  themes.forEach((theme) => {
274
321
  StyleDictionary.extend({
275
- source: [`src/theme/${theme}/*.json`],
276
- include: ["src/global/primitive/*.json"],
322
+ source: [`src/theme/${theme}/*.js`, `src/theme/${theme}/component/*.js`],
323
+ include: ["src/global/primitive/*.js"],
277
324
  platforms: {
278
325
  css: {
279
326
  transformGroup: "css",
@@ -287,14 +334,7 @@ themes.forEach((theme) => {
287
334
  destination: "border.css",
288
335
  format: "custom/CSSUtils/Borders",
289
336
  filter: function (token) {
290
- return (
291
- token.filePath.includes("border") ||
292
- // referenced tokens
293
- token.filePath.includes("primitive/color") ||
294
- token.filePath.includes("primitive/size") ||
295
- token.filePath.includes("primitive/radius") ||
296
- token.filePath.includes("status")
297
- );
337
+ return token.filePath.includes("border");
298
338
  },
299
339
  },
300
340
  {
@@ -321,7 +361,7 @@ themes.forEach((theme) => {
321
361
  destination: "spacing.css",
322
362
  format: "custom/CSSUtils/Spacing",
323
363
  filter: function (token) {
324
- return token.filePath.includes("primitive/size");
364
+ return token.filePath.startsWith("src/global/primitive/size");
325
365
  },
326
366
  },
327
367
  ],
@@ -348,14 +388,34 @@ themes.forEach((theme) => {
348
388
  destination: "semantic.scss",
349
389
  format: "custom/SCSSVariable",
350
390
  filter: function (token) {
351
- return token.filePath.startsWith(`src/theme/${theme}`);
391
+ return (
392
+ token.filePath.startsWith(`src/theme/${theme}`) &&
393
+ !token.filePath.startsWith(`src/theme/${theme}/component`)
394
+ );
352
395
  },
353
396
  },
354
397
  {
355
398
  destination: "semantic-variables.scss",
356
- format: "custom/semantic-variables",
399
+ format: "custom/variables-map",
400
+ filter: function (token) {
401
+ return (
402
+ token.filePath.startsWith(`src/theme/${theme}`) &&
403
+ !token.filePath.startsWith(`src/theme/${theme}/component`)
404
+ );
405
+ },
406
+ },
407
+ {
408
+ destination: "component.scss",
409
+ format: "custom/SCSSVariable",
410
+ filter: function (token) {
411
+ return token.filePath.startsWith(`src/theme/${theme}/component`);
412
+ },
413
+ },
414
+ {
415
+ destination: "component-variables.scss",
416
+ format: "custom/variables-map",
357
417
  filter: function (token) {
358
- return token.filePath.startsWith(`src/theme/${theme}`);
418
+ return token.filePath.startsWith(`src/theme/${theme}/component`);
359
419
  },
360
420
  },
361
421
  ],
@@ -375,14 +435,27 @@ themes.forEach((theme) => {
375
435
  format: "custom/es6",
376
436
  destination: "raw.js",
377
437
  filter: function (token) {
378
- return token.filePath.startsWith(`src/theme/${theme}`);
438
+ return (
439
+ token.filePath.startsWith(`src/theme/${theme}`) &&
440
+ !token.filePath.startsWith(`src/theme/${theme}/component`)
441
+ );
379
442
  },
380
443
  },
381
444
  {
382
445
  format: "custom/es6Variable",
383
446
  destination: "semantic.js",
384
447
  filter: function (token) {
385
- return token.filePath.startsWith(`src/theme/${theme}`);
448
+ return (
449
+ token.filePath.startsWith(`src/theme/${theme}`) &&
450
+ !token.filePath.startsWith(`src/theme/${theme}/component`)
451
+ );
452
+ },
453
+ },
454
+ {
455
+ format: "custom/es6Variable",
456
+ destination: "component.js",
457
+ filter: function (token) {
458
+ return token.filePath.startsWith(`src/theme/${theme}/component`);
386
459
  },
387
460
  },
388
461
  ],
@@ -402,8 +475,9 @@ themes.forEach((theme) => {
402
475
  const indexJS = fs.createWriteStream(`build/web/${theme}/index.js`);
403
476
  indexJS.write(`import * as semantic from './semantic';\n`);
404
477
  indexJS.write(`import * as primitive from './primitive';\n`);
478
+ indexJS.write(`import * as component from './component';\n`);
405
479
  indexJS.write(`const name = '${theme}';\n`);
406
- indexJS.write(`export { primitive, semantic, name };\n`);
480
+ indexJS.write(`export { primitive, semantic, component, name };\n`);
407
481
  indexJS.end();
408
482
  mainType.write(`declare const ${theme}: Token;\n`);
409
483
  mainJS.write(`import * as ${theme} from './${theme}';\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/hammer-token",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "",
5
5
  "main": "build/web/index.js",
6
6
  "types": "build/web/index.d.ts",
@@ -12,7 +12,8 @@
12
12
  },
13
13
  "devDependencies": {
14
14
  "fs-extra": "^11.2.0",
15
- "style-dictionary": "^3"
15
+ "style-dictionary": "^3",
16
+ "tinycolor2": "^1.6.0"
16
17
  },
17
18
  "scripts": {
18
19
  "build": "node ./config.js",
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ breakpoint: {
3
+ sm: {
4
+ value: "640px",
5
+ },
6
+ md: {
7
+ value: "768px",
8
+ },
9
+ lg: {
10
+ value: "1024px",
11
+ },
12
+ xl: {
13
+ value: "1280px",
14
+ },
15
+ xxl: {
16
+ value: "1536px",
17
+ },
18
+ },
19
+ };
@@ -0,0 +1,231 @@
1
+ module.exports = {
2
+ color: {
3
+ blue: {
4
+ 100: {
5
+ value: "#E0F2FF",
6
+ },
7
+ 200: {
8
+ value: "#B5DEFF",
9
+ },
10
+ 300: {
11
+ value: "#78BBFA",
12
+ },
13
+ 400: {
14
+ value: "#3892F3",
15
+ },
16
+ 500: {
17
+ value: "#0265DC",
18
+ },
19
+ 600: {
20
+ value: "#004491",
21
+ },
22
+ },
23
+ neutral: {
24
+ 0: {
25
+ value: "#ffffff",
26
+ },
27
+ 10: {
28
+ value: "#fcfcfc",
29
+ },
30
+ 20: {
31
+ value: "#fafafa",
32
+ },
33
+ 30: {
34
+ value: "#f7f7f7",
35
+ },
36
+ 40: {
37
+ value: "#f5f5f5",
38
+ },
39
+ 50: {
40
+ value: "#eeeeee",
41
+ },
42
+ 60: {
43
+ value: "#dfe0e1",
44
+ },
45
+ 70: {
46
+ value: "#bcbcbd",
47
+ },
48
+ 80: {
49
+ value: "#949596",
50
+ },
51
+ 90: {
52
+ value: "#737475",
53
+ },
54
+ 100: {
55
+ value: "#606162",
56
+ },
57
+ 200: {
58
+ value: "#444445",
59
+ },
60
+ 300: {
61
+ value: "#2d2e31",
62
+ },
63
+ 400: {
64
+ value: "#141414",
65
+ },
66
+ 500: {
67
+ value: "#040404",
68
+ },
69
+ },
70
+ "blue-grey": {
71
+ 100: {
72
+ value: "#eaeff2",
73
+ },
74
+ 200: {
75
+ value: "#d0d8dd",
76
+ },
77
+ 300: {
78
+ value: "#b4c1c8",
79
+ },
80
+ 400: {
81
+ value: "#8c9ca5",
82
+ },
83
+ 500: {
84
+ value: "#6a7a85",
85
+ },
86
+ 600: {
87
+ value: "#576671",
88
+ },
89
+ },
90
+ orange: {
91
+ 100: {
92
+ value: "#ffeccc",
93
+ },
94
+ 200: {
95
+ value: "#fdd291",
96
+ },
97
+ 300: {
98
+ value: "#ffa037",
99
+ },
100
+ 400: {
101
+ value: "#e46f00",
102
+ },
103
+ 500: {
104
+ value: "#b14c00",
105
+ },
106
+ 600: {
107
+ value: "#7a2f00",
108
+ },
109
+ },
110
+ yellow: {
111
+ 100: {
112
+ value: "#fff9e2",
113
+ },
114
+ 200: {
115
+ value: "#fff0b1",
116
+ },
117
+ 300: {
118
+ value: "#ffe278",
119
+ },
120
+ 400: {
121
+ value: "#ffc902",
122
+ },
123
+ 500: {
124
+ value: "#ffbe00",
125
+ },
126
+ 600: {
127
+ value: "#de9500",
128
+ },
129
+ },
130
+ green: {
131
+ 100: {
132
+ value: "#CEF8E0",
133
+ },
134
+ 200: {
135
+ value: "#89ECBC",
136
+ },
137
+ 300: {
138
+ value: "#49CC93",
139
+ },
140
+ 400: {
141
+ value: "#15A46E",
142
+ },
143
+ 500: {
144
+ value: "#007A4D",
145
+ },
146
+ 600: {
147
+ value: "#005132",
148
+ },
149
+ },
150
+ cyan: {
151
+ 100: {
152
+ value: "#e3fcff",
153
+ },
154
+ 200: {
155
+ value: "#b1f3fa",
156
+ },
157
+ 300: {
158
+ value: "#13ceea",
159
+ },
160
+ 400: {
161
+ value: "#08bfdf",
162
+ },
163
+ 500: {
164
+ value: "#0ca5c0",
165
+ },
166
+ 600: {
167
+ value: "#038299",
168
+ },
169
+ },
170
+ purple: {
171
+ 100: {
172
+ value: "#f1edff",
173
+ },
174
+ 200: {
175
+ value: "#c1b6f2",
176
+ },
177
+ 300: {
178
+ value: "#8772e5",
179
+ },
180
+ 400: {
181
+ value: "#6954c0",
182
+ },
183
+ 500: {
184
+ value: "#4f3a9e",
185
+ },
186
+ 600: {
187
+ value: "#422799",
188
+ },
189
+ },
190
+ red: {
191
+ 100: {
192
+ value: "#ffece9",
193
+ },
194
+ 200: {
195
+ value: "#ffb2a0",
196
+ },
197
+ 300: {
198
+ value: "#ff745f",
199
+ },
200
+ 400: {
201
+ value: "#f94d32",
202
+ },
203
+ 500: {
204
+ value: "#e13212",
205
+ },
206
+ 600: {
207
+ value: "#bf2a00",
208
+ },
209
+ },
210
+ magenta: {
211
+ 100: {
212
+ value: "#fbeaf5",
213
+ },
214
+ 200: {
215
+ value: "#faafe2",
216
+ },
217
+ 300: {
218
+ value: "#d949a9",
219
+ },
220
+ 400: {
221
+ value: "#b52d88",
222
+ },
223
+ 500: {
224
+ value: "#982071",
225
+ },
226
+ 600: {
227
+ value: "#7d165b",
228
+ },
229
+ },
230
+ },
231
+ };
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ duration: {
3
+ default: {
4
+ value: "200ms",
5
+ },
6
+ instant: {
7
+ value: "0ms",
8
+ },
9
+ fast: {
10
+ value: "100ms",
11
+ },
12
+ slow: {
13
+ value: "300ms",
14
+ },
15
+ },
16
+ };
@@ -0,0 +1,60 @@
1
+ module.exports = {
2
+ font: {
3
+ family: {
4
+ base: {
5
+ value: "'Nunito Sans', sans-serif",
6
+ },
7
+ display: {
8
+ value: "'Sofia Pro', SofiaPro, sans-serif",
9
+ },
10
+ },
11
+ "line-height": {
12
+ base: {
13
+ value: 1.5,
14
+ },
15
+ display: {
16
+ value: 1.25,
17
+ },
18
+ },
19
+ weight: {
20
+ normal: {
21
+ value: 400,
22
+ },
23
+ semibold: {
24
+ value: 600,
25
+ },
26
+ bold: {
27
+ value: 700,
28
+ },
29
+ },
30
+ size: {
31
+ 100: {
32
+ value: "0.625rem",
33
+ },
34
+ 200: {
35
+ value: "0.75rem",
36
+ },
37
+ 300: {
38
+ value: "0.875rem",
39
+ },
40
+ 400: {
41
+ value: "1rem",
42
+ },
43
+ 500: {
44
+ value: "1.25rem",
45
+ },
46
+ 600: {
47
+ value: "1.5rem",
48
+ },
49
+ 700: {
50
+ value: "1.75rem",
51
+ },
52
+ 800: {
53
+ value: "2rem",
54
+ },
55
+ 900: {
56
+ value: "2.25rem",
57
+ },
58
+ },
59
+ },
60
+ };
@@ -0,0 +1,31 @@
1
+ module.exports = {
2
+ radius: {
3
+ 0: {
4
+ value: "0",
5
+ },
6
+ 1: {
7
+ value: "0.1875rem",
8
+ },
9
+ 2: {
10
+ value: "0.375rem",
11
+ },
12
+ 3: {
13
+ value: "0.5625rem",
14
+ },
15
+ 4: {
16
+ value: "0.75rem",
17
+ },
18
+ 5: {
19
+ value: "0.9375rem",
20
+ },
21
+ 6: {
22
+ value: "1.125rem",
23
+ },
24
+ 7: {
25
+ value: "1.3125rem",
26
+ },
27
+ 8: {
28
+ value: "1.5rem",
29
+ },
30
+ },
31
+ };
@@ -0,0 +1,55 @@
1
+ module.exports = {
2
+ size: {
3
+ 0: {
4
+ value: "0rem",
5
+ },
6
+ quarter: {
7
+ value: "0.0625rem",
8
+ },
9
+ half: {
10
+ value: "0.125rem",
11
+ },
12
+ 1: {
13
+ value: "0.25rem",
14
+ },
15
+ 2: {
16
+ value: "0.5rem",
17
+ },
18
+ 3: {
19
+ value: "0.75rem",
20
+ },
21
+ 4: {
22
+ value: "1rem",
23
+ },
24
+ 5: {
25
+ value: "1.25rem",
26
+ },
27
+ 6: {
28
+ value: "1.5rem",
29
+ },
30
+ 7: {
31
+ value: "1.75rem",
32
+ },
33
+ 8: {
34
+ value: "2rem",
35
+ },
36
+ 9: {
37
+ value: "2.25rem",
38
+ },
39
+ 10: {
40
+ value: "2.5rem",
41
+ },
42
+ 11: {
43
+ value: "2.75rem",
44
+ },
45
+ 12: {
46
+ value: "3rem",
47
+ },
48
+ 13: {
49
+ value: "3.25rem",
50
+ },
51
+ 14: {
52
+ value: "3.5rem",
53
+ },
54
+ },
55
+ };
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ transition: {
3
+ ease: {
4
+ value: "cubic-bezier(.4, 0, .2, 1)",
5
+ },
6
+ "ease-in": {
7
+ value: "cubic-bezier(.4, 0, 1, 1)",
8
+ },
9
+ "ease-out": {
10
+ value: "cubic-bezier(0, 0, .4, 1)",
11
+ },
12
+ "ease-in-out": {
13
+ value: "cubic-bezier(.4, 0, .6, 1)",
14
+ },
15
+ },
16
+ };