@servicetitan/hammer-token 2.3.0 → 2.5.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/.turbo/turbo-build.log +6 -1
- package/CHANGELOG.md +12 -0
- package/build/web/core/css-utils/a2-border.css +53 -0
- package/build/web/core/css-utils/a2-color.css +235 -0
- package/build/web/core/css-utils/a2-font.css +49 -0
- package/build/web/core/css-utils/a2-spacing.css +483 -0
- package/build/web/core/css-utils/a2-utils.css +785 -0
- package/build/web/core/raw.js +85 -0
- package/build/web/core/semantic-variables.scss +102 -0
- package/build/web/core/semantic.js +357 -0
- package/build/web/core/semantic.scss +51 -0
- package/config.js +151 -141
- package/eslint.config.mjs +4 -0
- package/package.json +2 -2
- package/src/theme/core/background.js +1 -1
- package/src/theme/core/border.js +1 -1
- package/src/theme/core/charts.js +439 -0
- package/src/theme/core/component/button.js +1 -1
- package/src/theme/core/component/checkbox.js +1 -1
- package/src/theme/core/focus.js +1 -1
- package/src/theme/core/foreground.js +1 -1
- package/src/theme/core/overlay.js +1 -1
- package/src/theme/core/shadow.js +1 -1
- package/src/theme/core/status.js +1 -1
- package/src/theme/core/typography.js +1 -1
- package/src/utils/copy-css-utils-cli.js +1 -1
- package/src/utils/css-utils-format-utils.js +51 -39
- package/type/types.ts +51 -0
package/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
2
2
|
const StyleDictionary = require("style-dictionary");
|
|
3
3
|
const fs = require("fs-extra");
|
|
4
4
|
const {
|
|
@@ -15,8 +15,8 @@ StyleDictionary.registerFormat({
|
|
|
15
15
|
formatter: function ({ dictionary }) {
|
|
16
16
|
return dictionary.allTokens
|
|
17
17
|
.map((token) => {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const value = token.value;
|
|
19
|
+
const name = `${token.name.replace("-default", "")}`;
|
|
20
20
|
if (token.name.includes("font-family"))
|
|
21
21
|
return `$${name}: var(--${name}, ${value});`;
|
|
22
22
|
if (token.attributes.appearance) {
|
|
@@ -50,8 +50,8 @@ StyleDictionary.registerFormat({
|
|
|
50
50
|
return isColor;
|
|
51
51
|
})
|
|
52
52
|
.map((token) => {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const value = token.value;
|
|
54
|
+
const name = `${token.name.replace("-default", "")}`;
|
|
55
55
|
return ` ${name}: ${value},`;
|
|
56
56
|
})
|
|
57
57
|
.join(`\n`);
|
|
@@ -67,8 +67,8 @@ StyleDictionary.registerFormat({
|
|
|
67
67
|
return isColor;
|
|
68
68
|
})
|
|
69
69
|
.map((token) => {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
const value = token.value;
|
|
71
|
+
const name = `${token.name.replace("-default", "")}`;
|
|
72
72
|
if (token.attributes.appearance) {
|
|
73
73
|
return ` ${name}: ${token.attributes.appearance.dark.value},`;
|
|
74
74
|
}
|
|
@@ -87,8 +87,8 @@ StyleDictionary.registerFormat({
|
|
|
87
87
|
return !isColor;
|
|
88
88
|
})
|
|
89
89
|
.map((token) => {
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
const value = token.value;
|
|
91
|
+
const name = `${token.name.replace("-default", "")}`;
|
|
92
92
|
if (token.name.includes("font-family")) return ` ${name}: "${value}",`;
|
|
93
93
|
return ` ${name}: ${value},`;
|
|
94
94
|
})
|
|
@@ -113,8 +113,8 @@ StyleDictionary.registerFormat({
|
|
|
113
113
|
formatter: function ({ dictionary }) {
|
|
114
114
|
const vars = dictionary.allTokens
|
|
115
115
|
.map((token) => {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
const value = token.value;
|
|
117
|
+
const name = `${token.name.replace("-default", "")}`;
|
|
118
118
|
if (token.name.includes("font-family")) return ` ${name}: "${value}",`;
|
|
119
119
|
return ` ${name}: ${value},`;
|
|
120
120
|
})
|
|
@@ -130,24 +130,24 @@ StyleDictionary.registerFormat({
|
|
|
130
130
|
const light = dictionary.allTokens
|
|
131
131
|
.filter((token) => !!token.attributes.appearance)
|
|
132
132
|
.map((token) => {
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
const value = JSON.stringify(token.value);
|
|
134
|
+
const name = token.name.replace("Default", "");
|
|
135
135
|
return `\t${name}: ${value}`;
|
|
136
136
|
})
|
|
137
137
|
.join(`,\n`);
|
|
138
138
|
const dark = dictionary.allTokens
|
|
139
139
|
.filter((token) => !!token.attributes.appearance)
|
|
140
140
|
.map((token) => {
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
const value = JSON.stringify(token.attributes.appearance.dark.value);
|
|
142
|
+
const name = token.name.replace("Default", "");
|
|
143
143
|
return `\t${name}: ${value}`;
|
|
144
144
|
})
|
|
145
145
|
.join(`,\n`);
|
|
146
146
|
const common = dictionary.allTokens
|
|
147
147
|
.filter((token) => !token.attributes.appearance)
|
|
148
148
|
.map((token) => {
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
const value = JSON.stringify(token.value);
|
|
150
|
+
const name = token.name.replace("Default", "");
|
|
151
151
|
return `\t${name}: ${value}`;
|
|
152
152
|
})
|
|
153
153
|
.join(`,\n`);
|
|
@@ -160,8 +160,8 @@ StyleDictionary.registerFormat({
|
|
|
160
160
|
formatter: function ({ dictionary }) {
|
|
161
161
|
return dictionary.allTokens
|
|
162
162
|
.map((token) => {
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
const value = token.value;
|
|
164
|
+
const name = `${token.name.replace("Default", "")}`;
|
|
165
165
|
if (token.attributes.appearance) {
|
|
166
166
|
return `export const ${name} = {
|
|
167
167
|
value: "${value}",
|
|
@@ -180,88 +180,91 @@ StyleDictionary.registerFormat({
|
|
|
180
180
|
},
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
name.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
183
|
+
const CSS_UTILS_PREFIXES = ["", "a2-"];
|
|
184
|
+
|
|
185
|
+
for (const prefix of CSS_UTILS_PREFIXES) {
|
|
186
|
+
StyleDictionary.registerFormat({
|
|
187
|
+
name: `custom/CSSUtils/${prefix}All`,
|
|
188
|
+
formatter: function ({ dictionary }) {
|
|
189
|
+
const colorTokens = dictionary.allTokens
|
|
190
|
+
.map((token) => {
|
|
191
|
+
const value = getVarValue(dictionary, token);
|
|
192
|
+
const name = `${token.name.replace("Default", "")}`;
|
|
193
|
+
|
|
194
|
+
if (
|
|
195
|
+
// name.startsWith("color") || // primitives
|
|
196
|
+
name.startsWith("status-color") ||
|
|
197
|
+
name.startsWith("foreground-color") ||
|
|
198
|
+
name.startsWith("background-color") ||
|
|
199
|
+
name.startsWith("overlay-color")
|
|
200
|
+
) {
|
|
201
|
+
const darkValue = getVarValue(dictionary, token, { isDark: true });
|
|
202
|
+
return generateColorClasses(name, value, { darkValue, prefix });
|
|
203
|
+
}
|
|
204
|
+
if (name.startsWith("border-color")) {
|
|
205
|
+
const darkValue = getVarValue(dictionary, token, { isDark: true });
|
|
206
|
+
return generateBorderClasses(name, value, { darkValue, prefix });
|
|
207
|
+
}
|
|
208
|
+
return null;
|
|
209
|
+
})
|
|
210
|
+
.flat()
|
|
211
|
+
.filter((t) => t != null)
|
|
212
|
+
.map((t) => `${t}`)
|
|
213
|
+
.sort((a, b) => a.localeCompare(b))
|
|
214
|
+
.join(`\n`);
|
|
215
|
+
const nonColorTokens = dictionary.allTokens
|
|
216
|
+
.map((token) => {
|
|
217
|
+
const value = getVarValue(dictionary, token);
|
|
218
|
+
const name = `${token.name.replace("Default", "")}`;
|
|
219
|
+
|
|
220
|
+
if (name.startsWith("border")) {
|
|
221
|
+
return generateBorderClasses(name, value, { prefix });
|
|
222
|
+
}
|
|
223
|
+
if (name.startsWith("typography")) {
|
|
224
|
+
return generateFontClasses(name, value, { prefix });
|
|
225
|
+
}
|
|
226
|
+
if (name.startsWith("size")) {
|
|
227
|
+
return generateSpacingClasses(name, value, { prefix });
|
|
228
|
+
}
|
|
229
|
+
return null;
|
|
230
|
+
})
|
|
231
|
+
.flat()
|
|
232
|
+
.filter((t) => t != null)
|
|
233
|
+
.map((t) => `${t}`)
|
|
234
|
+
.sort((a, b) => a.localeCompare(b))
|
|
235
|
+
.join(`\n`);
|
|
236
|
+
|
|
237
|
+
const colorFallbackTokens = dictionary.allTokens
|
|
238
|
+
.map((token) => {
|
|
239
|
+
const value = getVarValue(dictionary, token);
|
|
240
|
+
const name = `${token.name.replace("Default", "")}`;
|
|
241
|
+
|
|
242
|
+
if (
|
|
243
|
+
name.startsWith("status-color") ||
|
|
244
|
+
name.startsWith("foreground-color") ||
|
|
245
|
+
name.startsWith("background-color") ||
|
|
246
|
+
name.startsWith("overlay-color")
|
|
247
|
+
) {
|
|
248
|
+
return generateColorClasses(name, value, { prefix });
|
|
249
|
+
}
|
|
250
|
+
if (name.startsWith("border-color")) {
|
|
251
|
+
return generateBorderClasses(name, value, { prefix });
|
|
252
|
+
}
|
|
253
|
+
return null;
|
|
254
|
+
})
|
|
255
|
+
.flat()
|
|
256
|
+
.filter((t) => t != null)
|
|
257
|
+
.map((t) => `${t}`)
|
|
258
|
+
.sort((a, b) => a.localeCompare(b))
|
|
259
|
+
.join(`\n`);
|
|
260
|
+
|
|
261
|
+
// Manually adding .sr-only
|
|
262
|
+
const withSr = nonColorTokens.concat(
|
|
263
|
+
"\n",
|
|
264
|
+
".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;}",
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
return `@layer starter, reset, base, state, application;
|
|
265
268
|
|
|
266
269
|
${withSr}
|
|
267
270
|
${colorFallbackTokens}
|
|
@@ -278,36 +281,43 @@ ${colorFallbackTokens}
|
|
|
278
281
|
${colorTokens.replaceAll("\n", "\n ")}
|
|
279
282
|
}
|
|
280
283
|
}`;
|
|
281
|
-
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
StyleDictionary.registerFormat({
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
})
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
StyleDictionary.registerFormat({
|
|
288
|
+
name: `custom/CSSUtils/${prefix}Borders`,
|
|
289
|
+
formatter: function ({ dictionary }) {
|
|
290
|
+
return cssUtilsFormatter(dictionary, generateBorderClasses, {
|
|
291
|
+
hasDark: true,
|
|
292
|
+
prefix,
|
|
293
|
+
});
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
StyleDictionary.registerFormat({
|
|
298
|
+
name: `custom/CSSUtils/${prefix}Colors`,
|
|
299
|
+
formatter: function ({ dictionary }) {
|
|
300
|
+
return cssUtilsFormatter(dictionary, generateColorClasses, {
|
|
301
|
+
hasDark: true,
|
|
302
|
+
prefix,
|
|
303
|
+
});
|
|
304
|
+
},
|
|
305
|
+
});
|
|
297
306
|
|
|
298
|
-
StyleDictionary.registerFormat({
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
});
|
|
307
|
+
StyleDictionary.registerFormat({
|
|
308
|
+
name: `custom/CSSUtils/${prefix}Fonts`,
|
|
309
|
+
formatter: function ({ dictionary }) {
|
|
310
|
+
return cssUtilsFormatter(dictionary, generateFontClasses, { prefix });
|
|
311
|
+
},
|
|
312
|
+
});
|
|
304
313
|
|
|
305
|
-
StyleDictionary.registerFormat({
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
});
|
|
314
|
+
StyleDictionary.registerFormat({
|
|
315
|
+
name: `custom/CSSUtils/${prefix}Spacing`,
|
|
316
|
+
formatter: function ({ dictionary }) {
|
|
317
|
+
return cssUtilsFormatter(dictionary, generateSpacingClasses, { prefix });
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
}
|
|
311
321
|
|
|
312
322
|
const getDirectories = (source) =>
|
|
313
323
|
fs
|
|
@@ -325,21 +335,21 @@ themes.forEach((theme) => {
|
|
|
325
335
|
css: {
|
|
326
336
|
transformGroup: "css",
|
|
327
337
|
buildPath: `build/web/${theme}/css-utils/`,
|
|
328
|
-
files: [
|
|
338
|
+
files: CSS_UTILS_PREFIXES.flatMap((prefix) => [
|
|
329
339
|
{
|
|
330
|
-
destination:
|
|
331
|
-
format:
|
|
340
|
+
destination: `${prefix}utils.css`,
|
|
341
|
+
format: `custom/CSSUtils/${prefix}All`,
|
|
332
342
|
},
|
|
333
343
|
{
|
|
334
|
-
destination:
|
|
335
|
-
format:
|
|
344
|
+
destination: `${prefix}border.css`,
|
|
345
|
+
format: `custom/CSSUtils/${prefix}Borders`,
|
|
336
346
|
filter: function (token) {
|
|
337
347
|
return token.filePath.includes("border");
|
|
338
348
|
},
|
|
339
349
|
},
|
|
340
350
|
{
|
|
341
|
-
destination:
|
|
342
|
-
format:
|
|
351
|
+
destination: `${prefix}color.css`,
|
|
352
|
+
format: `custom/CSSUtils/${prefix}Colors`,
|
|
343
353
|
filter: function (token) {
|
|
344
354
|
return (
|
|
345
355
|
token.filePath.includes("primitive/color") ||
|
|
@@ -348,8 +358,8 @@ themes.forEach((theme) => {
|
|
|
348
358
|
},
|
|
349
359
|
},
|
|
350
360
|
{
|
|
351
|
-
destination:
|
|
352
|
-
format:
|
|
361
|
+
destination: `${prefix}font.css`,
|
|
362
|
+
format: `custom/CSSUtils/${prefix}Fonts`,
|
|
353
363
|
filter: function (token) {
|
|
354
364
|
return (
|
|
355
365
|
token.filePath.includes("primitive/font") ||
|
|
@@ -358,13 +368,13 @@ themes.forEach((theme) => {
|
|
|
358
368
|
},
|
|
359
369
|
},
|
|
360
370
|
{
|
|
361
|
-
destination:
|
|
362
|
-
format:
|
|
371
|
+
destination: `${prefix}spacing.css`,
|
|
372
|
+
format: `custom/CSSUtils/${prefix}Spacing`,
|
|
363
373
|
filter: function (token) {
|
|
364
374
|
return token.filePath.startsWith("src/global/primitive/size");
|
|
365
375
|
},
|
|
366
376
|
},
|
|
367
|
-
],
|
|
377
|
+
]),
|
|
368
378
|
},
|
|
369
379
|
scss: {
|
|
370
380
|
transformGroup: "scss",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/hammer-token",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/web/index.js",
|
|
6
6
|
"types": "build/web/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"build": "node ./config.js",
|
|
20
20
|
"dev": "pnpm build && chokidar \"./src\" -c \"pnpm build\"",
|
|
21
21
|
"clean": "rimraf build .turbo",
|
|
22
|
-
"lint": "eslint",
|
|
22
|
+
"lint": "eslint .",
|
|
23
23
|
"nuke": "pnpm clean && rimraf node_modules"
|
|
24
24
|
}
|
|
25
25
|
}
|
package/src/theme/core/border.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
2
2
|
const { color } = require("../../global/primitive/color");
|
|
3
3
|
const { size } = require("../../global/primitive/size");
|
|
4
4
|
const { radius } = require("../../global/primitive/radius");
|