@servicetitan/hammer-token 0.0.0-rc-1.48.0-20251104214834 → 0.0.0-rc-3.0.0-20260114215531
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/CHANGELOG.md +29 -1
- package/README.md +222 -0
- package/build/web/core/component-variables.scss +114 -130
- package/build/web/core/component.d.ts +65 -0
- package/build/web/core/component.js +248 -267
- package/build/web/core/component.scss +63 -69
- package/build/web/core/css-utils/a2-border.css +39 -41
- package/build/web/core/css-utils/a2-color.css +351 -227
- package/build/web/core/css-utils/a2-font.css +0 -2
- package/build/web/core/css-utils/a2-spacing.css +0 -2
- package/build/web/core/css-utils/a2-utils.css +418 -292
- package/build/web/core/css-utils/border.css +39 -41
- package/build/web/core/css-utils/color.css +351 -227
- package/build/web/core/css-utils/font.css +0 -2
- package/build/web/core/css-utils/spacing.css +0 -2
- package/build/web/core/css-utils/utils.css +418 -292
- package/build/web/core/index.d.ts +6 -0
- package/build/web/core/index.js +1 -1
- package/build/web/core/primitive-variables.scss +130 -71
- package/build/web/core/primitive.d.ts +185 -0
- package/build/web/core/primitive.js +328 -72
- package/build/web/core/primitive.scss +183 -124
- package/build/web/core/semantic-variables.scss +287 -220
- package/build/web/core/semantic.d.ts +194 -0
- package/build/web/core/semantic.js +875 -347
- package/build/web/core/semantic.scss +192 -140
- package/build/web/index.d.ts +3 -4
- package/build/web/index.js +0 -1
- package/build/web/types.d.ts +17 -0
- package/config.js +121 -496
- package/package.json +5 -4
- package/src/global/primitive/breakpoint.tokens.json +39 -0
- package/src/global/primitive/color.tokens.json +536 -0
- package/src/global/primitive/duration.tokens.json +32 -0
- package/src/global/primitive/font.tokens.json +103 -0
- package/src/global/primitive/radius.tokens.json +67 -0
- package/src/global/primitive/size.tokens.json +123 -0
- package/src/global/primitive/transition.tokens.json +20 -0
- package/src/theme/core/background.tokens.json +981 -0
- package/src/theme/core/border.tokens.json +148 -0
- package/src/theme/core/charts.tokens.json +802 -0
- package/src/theme/core/component/button.tokens.json +752 -0
- package/src/theme/core/component/checkbox.tokens.json +292 -0
- package/src/theme/core/focus.tokens.json +48 -0
- package/src/theme/core/foreground.tokens.json +288 -0
- package/src/theme/core/shadow.tokens.json +43 -0
- package/src/theme/core/status.tokens.json +70 -0
- package/src/theme/core/typography.tokens.json +100 -0
- package/src/utils/copy-css-utils-cli.js +13 -0
- package/src/utils/css-utils-format-utils.js +98 -1
- package/src/utils/sd-build-configs.js +372 -0
- package/src/utils/sd-formats.js +752 -0
- package/src/utils/sd-transforms.js +126 -0
- package/src/utils/token-helpers.js +555 -0
- package/tsconfig.json +18 -0
- package/.turbo/turbo-build.log +0 -37
- package/build/web/core/raw.js +0 -234
- package/src/global/primitive/breakpoint.js +0 -19
- package/src/global/primitive/color.js +0 -231
- package/src/global/primitive/duration.js +0 -16
- package/src/global/primitive/font.js +0 -60
- package/src/global/primitive/radius.js +0 -31
- package/src/global/primitive/size.js +0 -55
- package/src/global/primitive/transition.js +0 -16
- package/src/theme/core/background.js +0 -170
- package/src/theme/core/border.js +0 -103
- package/src/theme/core/charts.js +0 -464
- package/src/theme/core/component/button.js +0 -708
- package/src/theme/core/component/checkbox.js +0 -405
- package/src/theme/core/focus.js +0 -35
- package/src/theme/core/foreground.js +0 -148
- package/src/theme/core/overlay.js +0 -137
- package/src/theme/core/shadow.js +0 -29
- package/src/theme/core/status.js +0 -49
- package/src/theme/core/typography.js +0 -82
- package/type/types.ts +0 -344
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"status": {
|
|
3
|
+
"color": {
|
|
4
|
+
"info": {
|
|
5
|
+
"$type": "color",
|
|
6
|
+
"$value": "{color.blue.500}",
|
|
7
|
+
"$extensions": {
|
|
8
|
+
"appearance": {
|
|
9
|
+
"light": {
|
|
10
|
+
"$type": "color",
|
|
11
|
+
"$value": "{color.blue.500}"
|
|
12
|
+
},
|
|
13
|
+
"dark": {
|
|
14
|
+
"$type": "color",
|
|
15
|
+
"$value": "{color.blue.100}"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"danger": {
|
|
21
|
+
"$type": "color",
|
|
22
|
+
"$value": "{color.red.500}",
|
|
23
|
+
"$extensions": {
|
|
24
|
+
"appearance": {
|
|
25
|
+
"light": {
|
|
26
|
+
"$type": "color",
|
|
27
|
+
"$value": "{color.red.500}"
|
|
28
|
+
},
|
|
29
|
+
"dark": {
|
|
30
|
+
"$type": "color",
|
|
31
|
+
"$value": "{color.red.100}"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"success": {
|
|
37
|
+
"$type": "color",
|
|
38
|
+
"$value": "{color.green.500}",
|
|
39
|
+
"$extensions": {
|
|
40
|
+
"appearance": {
|
|
41
|
+
"light": {
|
|
42
|
+
"$type": "color",
|
|
43
|
+
"$value": "{color.green.500}"
|
|
44
|
+
},
|
|
45
|
+
"dark": {
|
|
46
|
+
"$type": "color",
|
|
47
|
+
"$value": "{color.green.100}"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"warning": {
|
|
53
|
+
"$type": "color",
|
|
54
|
+
"$value": "{color.yellow.500}",
|
|
55
|
+
"$extensions": {
|
|
56
|
+
"appearance": {
|
|
57
|
+
"light": {
|
|
58
|
+
"$type": "color",
|
|
59
|
+
"$value": "{color.yellow.500}"
|
|
60
|
+
},
|
|
61
|
+
"dark": {
|
|
62
|
+
"$type": "color",
|
|
63
|
+
"$value": "{color.yellow.100}"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"typography": {
|
|
3
|
+
"paragraph": {
|
|
4
|
+
"size": {
|
|
5
|
+
"xsmall": {
|
|
6
|
+
"$type": "dimension",
|
|
7
|
+
"$value": "{font.size.200}"
|
|
8
|
+
},
|
|
9
|
+
"small": {
|
|
10
|
+
"$type": "dimension",
|
|
11
|
+
"$value": "{font.size.300}"
|
|
12
|
+
},
|
|
13
|
+
"default": {
|
|
14
|
+
"$type": "dimension",
|
|
15
|
+
"$value": "{font.size.400}"
|
|
16
|
+
},
|
|
17
|
+
"large": {
|
|
18
|
+
"$type": "dimension",
|
|
19
|
+
"$value": "{font.size.500}"
|
|
20
|
+
},
|
|
21
|
+
"xlarge": {
|
|
22
|
+
"$type": "dimension",
|
|
23
|
+
"$value": "{font.size.600}"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"font-weight": {
|
|
27
|
+
"$type": "number",
|
|
28
|
+
"$value": "{font.weight.normal}"
|
|
29
|
+
},
|
|
30
|
+
"font-family": {
|
|
31
|
+
"$type": "string",
|
|
32
|
+
"$value": "{font.family.base}"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"heading": {
|
|
36
|
+
"size": {
|
|
37
|
+
"xsmall": {
|
|
38
|
+
"$type": "dimension",
|
|
39
|
+
"$value": "{font.size.300}"
|
|
40
|
+
},
|
|
41
|
+
"small": {
|
|
42
|
+
"$type": "dimension",
|
|
43
|
+
"$value": "{font.size.400}"
|
|
44
|
+
},
|
|
45
|
+
"default": {
|
|
46
|
+
"$type": "dimension",
|
|
47
|
+
"$value": "{font.size.500}"
|
|
48
|
+
},
|
|
49
|
+
"large": {
|
|
50
|
+
"$type": "dimension",
|
|
51
|
+
"$value": "{font.size.600}"
|
|
52
|
+
},
|
|
53
|
+
"xlarge": {
|
|
54
|
+
"$type": "dimension",
|
|
55
|
+
"$value": "{font.size.800}"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"font-weight": {
|
|
59
|
+
"$type": "number",
|
|
60
|
+
"$value": "{font.weight.bold}"
|
|
61
|
+
},
|
|
62
|
+
"font-family": {
|
|
63
|
+
"$type": "string",
|
|
64
|
+
"$value": "{font.family.display}"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"label": {
|
|
68
|
+
"size": {
|
|
69
|
+
"xsmall": {
|
|
70
|
+
"$type": "dimension",
|
|
71
|
+
"$value": "{font.size.100}"
|
|
72
|
+
},
|
|
73
|
+
"small": {
|
|
74
|
+
"$type": "dimension",
|
|
75
|
+
"$value": "{font.size.200}"
|
|
76
|
+
},
|
|
77
|
+
"default": {
|
|
78
|
+
"$type": "dimension",
|
|
79
|
+
"$value": "{font.size.300}"
|
|
80
|
+
},
|
|
81
|
+
"large": {
|
|
82
|
+
"$type": "dimension",
|
|
83
|
+
"$value": "{font.size.400}"
|
|
84
|
+
},
|
|
85
|
+
"xlarge": {
|
|
86
|
+
"$type": "dimension",
|
|
87
|
+
"$value": "{font.size.500}"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"font-weight": {
|
|
91
|
+
"$type": "number",
|
|
92
|
+
"$value": "{font.weight.semibold}"
|
|
93
|
+
},
|
|
94
|
+
"font-family": {
|
|
95
|
+
"$type": "string",
|
|
96
|
+
"$value": "{font.family.base}"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
3
|
+
/**
|
|
4
|
+
* CLI tool for copying CSS utility files from hammer-token to a target project
|
|
5
|
+
* @module copy-css-utils-cli
|
|
6
|
+
*/
|
|
3
7
|
const { program } = require("commander");
|
|
4
8
|
const path = require("path");
|
|
5
9
|
const fs = require("fs");
|
|
6
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Runs the CLI program that provides the copy-css-utils command.
|
|
13
|
+
* This command copies all CSS utility files from the hammer-token build directory
|
|
14
|
+
* to a specified destination directory in the user's project.
|
|
15
|
+
* @returns {void}
|
|
16
|
+
* @example
|
|
17
|
+
* // From command line:
|
|
18
|
+
* // npx hammer-token copy-css-utils ./src/styles
|
|
19
|
+
*/
|
|
7
20
|
function run() {
|
|
8
21
|
program
|
|
9
22
|
.command("copy-css-utils")
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS utility class generation functions for Style Dictionary
|
|
3
|
+
* @module css-utils-format-utils
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Formats a dictionary of tokens into CSS utility classes with layer structure and @supports blocks.
|
|
8
|
+
* This is a legacy formatter that handles both light and dark mode tokens.
|
|
9
|
+
* @param {Object} dictionary - The Style Dictionary dictionary object
|
|
10
|
+
* @param {Function} generateFn - The function to generate CSS classes for each token
|
|
11
|
+
* @param {Object} options - Formatter options
|
|
12
|
+
* @param {boolean} options.hasDark - Whether the tokens include dark mode variants
|
|
13
|
+
* @param {string} [options.prefix=''] - CSS class prefix
|
|
14
|
+
* @returns {string} The complete CSS output with layer declarations and @supports blocks
|
|
15
|
+
*/
|
|
1
16
|
const cssUtilsFormatter = (
|
|
2
17
|
dictionary,
|
|
3
18
|
generateFn,
|
|
@@ -54,6 +69,14 @@ ${
|
|
|
54
69
|
}`;
|
|
55
70
|
};
|
|
56
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new value string by replacing a reference with a CSS var() fallback.
|
|
74
|
+
* @param {string} value - The original value string containing the reference
|
|
75
|
+
* @param {Object} ref - The reference object from Style Dictionary
|
|
76
|
+
* @param {string} [ref.value] - The resolved value of the reference
|
|
77
|
+
* @param {string} [ref.name] - The name of the referenced token
|
|
78
|
+
* @returns {string} The value with the reference replaced by var(--name, value) or just the value
|
|
79
|
+
*/
|
|
57
80
|
const getNewValueFromRef = (value, ref) => {
|
|
58
81
|
return value.replace(ref.value, function () {
|
|
59
82
|
// fallback for nested vars
|
|
@@ -65,13 +88,28 @@ const getNewValueFromRef = (value, ref) => {
|
|
|
65
88
|
});
|
|
66
89
|
};
|
|
67
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Checks if a color value has an alpha value appended after a CSS var.
|
|
93
|
+
* This pattern (e.g., var(--something)44) is invalid in CSS.
|
|
94
|
+
* @param {string} value - The value to check
|
|
95
|
+
* @returns {boolean} True if the value contains an invalid alpha pattern
|
|
96
|
+
* @example
|
|
97
|
+
* colorHasAlphaValue('var(--color)44') // true
|
|
98
|
+
* colorHasAlphaValue('var(--color, #fff)') // false
|
|
99
|
+
*/
|
|
68
100
|
const colorHasAlphaValue = (value) => {
|
|
69
101
|
// e.g. var(--something)44 isn't valid
|
|
70
102
|
return /\)[\d]+/.test(value);
|
|
71
103
|
};
|
|
72
104
|
|
|
73
105
|
/**
|
|
74
|
-
*
|
|
106
|
+
* Gets the value of a token with CSS variable references resolved to var() syntax.
|
|
107
|
+
* Supports both light and dark mode values.
|
|
108
|
+
* @param {Object} dictionary - The Style Dictionary dictionary object
|
|
109
|
+
* @param {Object} token - The token to get the value for
|
|
110
|
+
* @param {Object} [options] - Options for value resolution
|
|
111
|
+
* @param {boolean} [options.isDark=false] - Whether to get the dark mode value
|
|
112
|
+
* @returns {string} The token value with references converted to CSS var() syntax
|
|
75
113
|
*/
|
|
76
114
|
const getVarValue = (dictionary, token, { isDark } = {}) => {
|
|
77
115
|
let value;
|
|
@@ -107,10 +145,29 @@ const getVarValue = (dictionary, token, { isDark } = {}) => {
|
|
|
107
145
|
return value.replaceAll('"', "");
|
|
108
146
|
};
|
|
109
147
|
|
|
148
|
+
/**
|
|
149
|
+
* Removes the '-default' suffix from a token name.
|
|
150
|
+
* @param {string} name - The token name
|
|
151
|
+
* @returns {string} The name without the '-default' suffix
|
|
152
|
+
* @example
|
|
153
|
+
* removeDefaultFromName('color-primary-default') // 'color-primary'
|
|
154
|
+
*/
|
|
110
155
|
const removeDefaultFromName = (name) => {
|
|
111
156
|
return name.replace("-default", "");
|
|
112
157
|
};
|
|
113
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Generates CSS utility classes for border tokens (radius, width, color).
|
|
161
|
+
* @param {string} name - The token name
|
|
162
|
+
* @param {string} value - The token value
|
|
163
|
+
* @param {Object} [options] - Generation options
|
|
164
|
+
* @param {string} [options.darkValue] - The dark mode value for light-dark() support
|
|
165
|
+
* @param {string} [options.prefix=''] - CSS class prefix
|
|
166
|
+
* @returns {string[]} Array of CSS class declarations
|
|
167
|
+
* @example
|
|
168
|
+
* generateBorderClasses('border-radius-small', '4px', { prefix: 'a2-' })
|
|
169
|
+
* // Returns: ['.a2-border-radius-small {border-radius: var(--border-radius-small, 4px)}']
|
|
170
|
+
*/
|
|
114
171
|
const generateBorderClasses = (
|
|
115
172
|
name,
|
|
116
173
|
value,
|
|
@@ -140,6 +197,19 @@ const generateBorderClasses = (
|
|
|
140
197
|
return classes;
|
|
141
198
|
};
|
|
142
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Generates CSS utility classes for color tokens (background, foreground, status, overlay, border).
|
|
202
|
+
* Creates appropriate class names based on the token type (bg-, c-, bg-status-, etc.).
|
|
203
|
+
* @param {string} name - The token name
|
|
204
|
+
* @param {string} value - The token value
|
|
205
|
+
* @param {Object} [options] - Generation options
|
|
206
|
+
* @param {string} [options.darkValue] - The dark mode value for light-dark() support
|
|
207
|
+
* @param {string} [options.prefix=''] - CSS class prefix
|
|
208
|
+
* @returns {string[]} Array of CSS class declarations
|
|
209
|
+
* @example
|
|
210
|
+
* generateColorClasses('background-color-primary', '#fff', { prefix: 'a2-' })
|
|
211
|
+
* // Returns: ['.a2-bg-primary {background-color: var(--background-color-primary, #fff)}']
|
|
212
|
+
*/
|
|
143
213
|
const generateColorClasses = (name, value, { darkValue, prefix = "" } = {}) => {
|
|
144
214
|
const classes = [];
|
|
145
215
|
|
|
@@ -204,6 +274,18 @@ const generateColorClasses = (name, value, { darkValue, prefix = "" } = {}) => {
|
|
|
204
274
|
return classes;
|
|
205
275
|
};
|
|
206
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Generates CSS utility classes for typography tokens (font-family, font-weight, font-size).
|
|
279
|
+
* Creates class names with ff-, fw-, fs- prefixes based on the typography property.
|
|
280
|
+
* @param {string} name - The token name
|
|
281
|
+
* @param {string} value - The token value
|
|
282
|
+
* @param {Object} [options] - Generation options
|
|
283
|
+
* @param {string} [options.prefix=''] - CSS class prefix
|
|
284
|
+
* @returns {string[]} Array of CSS class declarations
|
|
285
|
+
* @example
|
|
286
|
+
* generateFontClasses('typography-body-font-family', 'Arial', { prefix: 'a2-' })
|
|
287
|
+
* // Returns: ['.a2-ff-body {font-family: Arial}']
|
|
288
|
+
*/
|
|
207
289
|
const generateFontClasses = (name, value, { prefix = "" } = {}) => {
|
|
208
290
|
const classes = [];
|
|
209
291
|
|
|
@@ -226,6 +308,21 @@ const generateFontClasses = (name, value, { prefix = "" } = {}) => {
|
|
|
226
308
|
return classes;
|
|
227
309
|
};
|
|
228
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Generates CSS utility classes for spacing/size tokens (margin, padding).
|
|
313
|
+
* Creates classes for all logical property directions (inline-start, inline-end, block-start, etc.).
|
|
314
|
+
* @param {string} name - The token name (e.g., 'size-4')
|
|
315
|
+
* @param {string} value - The token value (e.g., '1rem')
|
|
316
|
+
* @param {Object} [options] - Generation options
|
|
317
|
+
* @param {string} [options.prefix=''] - CSS class prefix
|
|
318
|
+
* @returns {string[]} Array of CSS class declarations for margin and padding utilities
|
|
319
|
+
* @example
|
|
320
|
+
* generateSpacingClasses('size-4', '1rem', { prefix: 'a2-' })
|
|
321
|
+
* // Returns array including:
|
|
322
|
+
* // '.a2-m-inline-start-4 {margin-inline-start: var(--size-4, 1rem)}'
|
|
323
|
+
* // '.a2-p-inline-start-4 {padding-inline-start: var(--size-4, 1rem)}'
|
|
324
|
+
* // ... and more for each direction
|
|
325
|
+
*/
|
|
229
326
|
const generateSpacingClasses = (name, value, { prefix = "" } = {}) => {
|
|
230
327
|
const nameWithoutPrefix = name.substring(name.indexOf("-"));
|
|
231
328
|
|