@servicetitan/hammer-token 0.0.0-rc-20250807234739
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 +37 -0
- package/CHANGELOG.md +385 -0
- package/build/web/core/component-variables.scss +139 -0
- package/build/web/core/component.js +645 -0
- package/build/web/core/component.scss +69 -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/css-utils/border.css +53 -0
- package/build/web/core/css-utils/color.css +235 -0
- package/build/web/core/css-utils/font.css +49 -0
- package/build/web/core/css-utils/spacing.css +483 -0
- package/build/web/core/css-utils/utils.css +785 -0
- package/build/web/core/index.js +5 -0
- package/build/web/core/primitive-variables.scss +126 -0
- package/build/web/core/primitive.js +124 -0
- package/build/web/core/primitive.scss +124 -0
- package/build/web/core/raw.js +229 -0
- package/build/web/core/semantic-variables.scss +246 -0
- package/build/web/core/semantic.js +911 -0
- package/build/web/core/semantic.scss +137 -0
- package/build/web/index.d.ts +4 -0
- package/build/web/index.js +3 -0
- package/config.js +504 -0
- package/eslint.config.mjs +4 -0
- package/package.json +25 -0
- package/src/global/primitive/breakpoint.js +19 -0
- package/src/global/primitive/color.js +231 -0
- package/src/global/primitive/duration.js +16 -0
- package/src/global/primitive/font.js +60 -0
- package/src/global/primitive/radius.js +31 -0
- package/src/global/primitive/size.js +55 -0
- package/src/global/primitive/transition.js +16 -0
- package/src/theme/core/background.js +170 -0
- package/src/theme/core/border.js +103 -0
- package/src/theme/core/charts.js +439 -0
- package/src/theme/core/component/button.js +708 -0
- package/src/theme/core/component/checkbox.js +405 -0
- package/src/theme/core/focus.js +35 -0
- package/src/theme/core/foreground.js +148 -0
- package/src/theme/core/overlay.js +137 -0
- package/src/theme/core/shadow.js +29 -0
- package/src/theme/core/status.js +49 -0
- package/src/theme/core/typography.js +82 -0
- package/src/utils/copy-css-utils-cli.js +37 -0
- package/src/utils/css-utils-format-utils.js +267 -0
- package/type/types.ts +341 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
$background-color: var(--background-color, #ffffff);
|
|
2
|
+
$background-color-strong: var(--background-color-strong, #f7f7f7);
|
|
3
|
+
$background-color-stronger: var(--background-color-stronger, #eeeeee);
|
|
4
|
+
$background-color-strongest: var(--background-color-strongest, #bcbcbd);
|
|
5
|
+
$background-color-primary: var(--background-color-primary, #0265DC);
|
|
6
|
+
$background-color-primary-subdued: var(--background-color-primary-subdued, #E0F2FF);
|
|
7
|
+
$background-color-success: var(--background-color-success, #007A4D);
|
|
8
|
+
$background-color-success-subdued: var(--background-color-success-subdued, #CEF8E0);
|
|
9
|
+
$background-color-danger: var(--background-color-danger, #e13212);
|
|
10
|
+
$background-color-danger-subdued: var(--background-color-danger-subdued, #ffece9);
|
|
11
|
+
$background-color-warning: var(--background-color-warning, #ffbe00);
|
|
12
|
+
$background-color-disabled: var(--background-color-disabled, #606162);
|
|
13
|
+
$background-color-inverted: var(--background-color-inverted, #2d2e31);
|
|
14
|
+
$background-color-inverted-strong: var(--background-color-inverted-strong, #141414);
|
|
15
|
+
$border-radius-none: 0;
|
|
16
|
+
$border-radius-small: 0.1875rem;
|
|
17
|
+
$border-radius-medium: 0.375rem;
|
|
18
|
+
$border-radius-large: 0.75rem;
|
|
19
|
+
$border-radius-xlarge: 1.5rem;
|
|
20
|
+
$border-radius-circular: 100%;
|
|
21
|
+
$border-width-none: 0rem;
|
|
22
|
+
$border-width: 0.0625rem;
|
|
23
|
+
$border-width-strong: 0.125rem;
|
|
24
|
+
$border-color: var(--border-color, #949596);
|
|
25
|
+
$border-color-subdued: var(--border-color-subdued, #dfe0e1);
|
|
26
|
+
$border-color-strong: var(--border-color-strong, #444445);
|
|
27
|
+
$border-color-primary: var(--border-color-primary, #0265DC);
|
|
28
|
+
$border-color-success: var(--border-color-success, #007A4D);
|
|
29
|
+
$border-color-danger: var(--border-color-danger, #e13212);
|
|
30
|
+
$charts-monochrome-1: var(--charts-monochrome-1, #3892F3);
|
|
31
|
+
$charts-monochrome-1-stroke: var(--charts-monochrome-1-stroke, transparent);
|
|
32
|
+
$charts-monochrome-1-pattern: solid;
|
|
33
|
+
$charts-monochrome-2: var(--charts-monochrome-2, #08389c);
|
|
34
|
+
$charts-monochrome-2-stroke: var(--charts-monochrome-2-stroke, transparent);
|
|
35
|
+
$charts-monochrome-2-pattern: solid;
|
|
36
|
+
$charts-monochrome-3: var(--charts-monochrome-3, #F2F9FF);
|
|
37
|
+
$charts-monochrome-3-stroke: var(--charts-monochrome-3-stroke, #3892F3);
|
|
38
|
+
$charts-monochrome-3-pattern: striped;
|
|
39
|
+
$charts-monochrome-4: var(--charts-monochrome-4, #F2F9FF);
|
|
40
|
+
$charts-monochrome-4-stroke: var(--charts-monochrome-4-stroke, #3892F3);
|
|
41
|
+
$charts-monochrome-4-pattern: solid;
|
|
42
|
+
$charts-categorical-1: var(--charts-categorical-1, #3892F3);
|
|
43
|
+
$charts-categorical-1-stroke: var(--charts-categorical-1-stroke, transparent);
|
|
44
|
+
$charts-categorical-1-pattern: solid;
|
|
45
|
+
$charts-categorical-2: var(--charts-categorical-2, #0FA2B8);
|
|
46
|
+
$charts-categorical-2-stroke: var(--charts-categorical-2-stroke, transparent);
|
|
47
|
+
$charts-categorical-2-pattern: solid;
|
|
48
|
+
$charts-categorical-3: var(--charts-categorical-3, #907AF5);
|
|
49
|
+
$charts-categorical-3-stroke: var(--charts-categorical-3-stroke, transparent);
|
|
50
|
+
$charts-categorical-3-pattern: solid;
|
|
51
|
+
$charts-categorical-4: var(--charts-categorical-4, #DE52CE);
|
|
52
|
+
$charts-categorical-4-stroke: var(--charts-categorical-4-stroke, transparent);
|
|
53
|
+
$charts-categorical-4-pattern: solid;
|
|
54
|
+
$charts-categorical-5: var(--charts-categorical-5, #C2185B);
|
|
55
|
+
$charts-categorical-5-stroke: var(--charts-categorical-5-stroke, transparent);
|
|
56
|
+
$charts-categorical-5-pattern: solid;
|
|
57
|
+
$charts-categorical-6: var(--charts-categorical-6, #759E15);
|
|
58
|
+
$charts-categorical-6-stroke: var(--charts-categorical-6-stroke, transparent);
|
|
59
|
+
$charts-categorical-6-pattern: solid;
|
|
60
|
+
$charts-categorical-7: var(--charts-categorical-7, #AC6400);
|
|
61
|
+
$charts-categorical-7-stroke: var(--charts-categorical-7-stroke, transparent);
|
|
62
|
+
$charts-categorical-7-pattern: solid;
|
|
63
|
+
$charts-categorical-8: var(--charts-categorical-8, #EB7200);
|
|
64
|
+
$charts-categorical-8-stroke: var(--charts-categorical-8-stroke, transparent);
|
|
65
|
+
$charts-categorical-8-pattern: solid;
|
|
66
|
+
$charts-categorical-9: var(--charts-categorical-9, #D57A5C);
|
|
67
|
+
$charts-categorical-9-stroke: var(--charts-categorical-9-stroke, transparent);
|
|
68
|
+
$charts-categorical-9-pattern: solid;
|
|
69
|
+
$charts-status-success: var(--charts-status-success, #007A4D);
|
|
70
|
+
$charts-status-success-stroke: var(--charts-status-success-stroke, transparent);
|
|
71
|
+
$charts-status-success-pattern: solid;
|
|
72
|
+
$charts-status-warning: var(--charts-status-warning, #ffbe00);
|
|
73
|
+
$charts-status-warning-stroke: var(--charts-status-warning-stroke, transparent);
|
|
74
|
+
$charts-status-warning-pattern: solid;
|
|
75
|
+
$charts-status-danger: var(--charts-status-danger, #e13212);
|
|
76
|
+
$charts-status-danger-stroke: var(--charts-status-danger-stroke, transparent);
|
|
77
|
+
$charts-status-danger-pattern: solid;
|
|
78
|
+
$charts-status-neutral: var(--charts-status-neutral, #ffffff);
|
|
79
|
+
$charts-status-neutral-stroke: var(--charts-status-neutral-stroke, #8C9CA5);
|
|
80
|
+
$charts-status-neutral-pattern: striped;
|
|
81
|
+
$focus-ring-color: var(--focus-ring-color, #0265DC);
|
|
82
|
+
$focus-ring-color-danger: var(--focus-ring-color-danger, #e13212);
|
|
83
|
+
$focus-ring-width: 0.25rem;
|
|
84
|
+
$foreground-color: var(--foreground-color, #141414);
|
|
85
|
+
$foreground-color-subdued: var(--foreground-color-subdued, #737475);
|
|
86
|
+
$foreground-color-primary: var(--foreground-color-primary, #0265DC);
|
|
87
|
+
$foreground-color-danger: var(--foreground-color-danger, #e13212);
|
|
88
|
+
$foreground-color-inverted: var(--foreground-color-inverted, #ffffff);
|
|
89
|
+
$foreground-color-on-primary: var(--foreground-color-on-primary, #ffffff);
|
|
90
|
+
$foreground-color-on-danger: var(--foreground-color-on-danger, #ffffff);
|
|
91
|
+
$foreground-color-on-danger-subdued: var(--foreground-color-on-danger-subdued, #bf2a00);
|
|
92
|
+
$foreground-color-on-warning: var(--foreground-color-on-warning, #141414);
|
|
93
|
+
$foreground-color-active-primary: var(--foreground-color-active-primary, #004491);
|
|
94
|
+
$foreground-color-active-danger: var(--foreground-color-active-danger, #bf2a00);
|
|
95
|
+
$foreground-color-hover-primary: var(--foreground-color-hover-primary, #004491);
|
|
96
|
+
$foreground-color-hover-danger: var(--foreground-color-hover-danger, #bf2a00);
|
|
97
|
+
$overlay-color-active: var(--overlay-color-active, #14141429);
|
|
98
|
+
$overlay-color-active-primary: var(--overlay-color-active-primary, #0265DC4D);
|
|
99
|
+
$overlay-color-active-danger: var(--overlay-color-active-danger, #e132124D);
|
|
100
|
+
$overlay-color-active-on: var(--overlay-color-active-on, #14141429);
|
|
101
|
+
$overlay-color-active-on-primary: var(--overlay-color-active-on-primary, #14141466);
|
|
102
|
+
$overlay-color-active-on-danger: var(--overlay-color-active-on-danger, #14141466);
|
|
103
|
+
$overlay-color-hover: var(--overlay-color-hover, #14141414);
|
|
104
|
+
$overlay-color-hover-primary: var(--overlay-color-hover-primary, #0265DC1A);
|
|
105
|
+
$overlay-color-hover-danger: var(--overlay-color-hover-danger, #e132121A);
|
|
106
|
+
$overlay-color-hover-on: var(--overlay-color-hover-on, #14141414);
|
|
107
|
+
$overlay-color-hover-on-primary: var(--overlay-color-hover-on-primary, #14141433);
|
|
108
|
+
$overlay-color-hover-on-danger: var(--overlay-color-hover-on-danger, #14141433);
|
|
109
|
+
$shadow-color: var(--shadow-color, #14141414);
|
|
110
|
+
$shadow-size-flat: 0rem 0rem 0rem;
|
|
111
|
+
$shadow-size-float: 0rem 0.125rem 0.5rem;
|
|
112
|
+
$shadow-size-overlay: 0rem 0.5rem 1.5rem;
|
|
113
|
+
$status-color-info: var(--status-color-info, #0265DC);
|
|
114
|
+
$status-color-danger: var(--status-color-danger, #e13212);
|
|
115
|
+
$status-color-success: var(--status-color-success, #007A4D);
|
|
116
|
+
$status-color-warning: var(--status-color-warning, #ffbe00);
|
|
117
|
+
$typography-paragraph-size-xsmall: 0.75rem;
|
|
118
|
+
$typography-paragraph-size-small: 0.875rem;
|
|
119
|
+
$typography-paragraph-size: 1rem;
|
|
120
|
+
$typography-paragraph-size-large: 1.25rem;
|
|
121
|
+
$typography-paragraph-size-xlarge: 1.5rem;
|
|
122
|
+
$typography-paragraph-font-weight: 400;
|
|
123
|
+
$typography-paragraph-font-family: var(--typography-paragraph-font-family, 'Nunito Sans', sans-serif);
|
|
124
|
+
$typography-heading-size-xsmall: 0.875rem;
|
|
125
|
+
$typography-heading-size-small: 1rem;
|
|
126
|
+
$typography-heading-size: 1.25rem;
|
|
127
|
+
$typography-heading-size-large: 1.5rem;
|
|
128
|
+
$typography-heading-size-xlarge: 2rem;
|
|
129
|
+
$typography-heading-font-weight: 700;
|
|
130
|
+
$typography-heading-font-family: var(--typography-heading-font-family, 'Sofia Pro', SofiaPro, sans-serif);
|
|
131
|
+
$typography-label-size-xsmall: 0.625rem;
|
|
132
|
+
$typography-label-size-small: 0.75rem;
|
|
133
|
+
$typography-label-size: 0.875rem;
|
|
134
|
+
$typography-label-size-large: 1rem;
|
|
135
|
+
$typography-label-size-xlarge: 1.25rem;
|
|
136
|
+
$typography-label-font-weight: 600;
|
|
137
|
+
$typography-label-font-family: var(--typography-label-font-family, 'Nunito Sans', sans-serif);
|
package/config.js
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
2
|
+
const StyleDictionary = require("style-dictionary");
|
|
3
|
+
const fs = require("fs-extra");
|
|
4
|
+
const {
|
|
5
|
+
cssUtilsFormatter,
|
|
6
|
+
getVarValue,
|
|
7
|
+
generateBorderClasses,
|
|
8
|
+
generateColorClasses,
|
|
9
|
+
generateFontClasses,
|
|
10
|
+
generateSpacingClasses,
|
|
11
|
+
} = require("./src/utils/css-utils-format-utils");
|
|
12
|
+
|
|
13
|
+
StyleDictionary.registerFormat({
|
|
14
|
+
name: `custom/SCSSVariable`,
|
|
15
|
+
formatter: function ({ dictionary }) {
|
|
16
|
+
return dictionary.allTokens
|
|
17
|
+
.map((token) => {
|
|
18
|
+
const value = token.value;
|
|
19
|
+
const name = `${token.name.replace("-default", "")}`;
|
|
20
|
+
if (token.name.includes("font-family"))
|
|
21
|
+
return `$${name}: var(--${name}, ${value});`;
|
|
22
|
+
if (token.attributes.appearance) {
|
|
23
|
+
return `$${name}: var(--${name}, ${value});`;
|
|
24
|
+
}
|
|
25
|
+
return `$${name}: ${value};`;
|
|
26
|
+
})
|
|
27
|
+
.join(`\n`);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const nonColorTokens = [
|
|
32
|
+
"border-radius",
|
|
33
|
+
"font-family",
|
|
34
|
+
"font-weight",
|
|
35
|
+
"size",
|
|
36
|
+
"width",
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
StyleDictionary.registerFormat({
|
|
40
|
+
name: `custom/variables-map`,
|
|
41
|
+
formatter: function ({ dictionary }) {
|
|
42
|
+
const light = dictionary.allTokens
|
|
43
|
+
.filter((token) => {
|
|
44
|
+
let isColor = true;
|
|
45
|
+
nonColorTokens.forEach((t) => {
|
|
46
|
+
if (token.name.includes(t)) {
|
|
47
|
+
isColor = false;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return isColor;
|
|
51
|
+
})
|
|
52
|
+
.map((token) => {
|
|
53
|
+
const value = token.value;
|
|
54
|
+
const name = `${token.name.replace("-default", "")}`;
|
|
55
|
+
return ` ${name}: ${value},`;
|
|
56
|
+
})
|
|
57
|
+
.join(`\n`);
|
|
58
|
+
|
|
59
|
+
const dark = dictionary.allTokens
|
|
60
|
+
.filter((token) => {
|
|
61
|
+
let isColor = true;
|
|
62
|
+
nonColorTokens.forEach((t) => {
|
|
63
|
+
if (token.name.includes(t)) {
|
|
64
|
+
isColor = false;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return isColor;
|
|
68
|
+
})
|
|
69
|
+
.map((token) => {
|
|
70
|
+
const value = token.value;
|
|
71
|
+
const name = `${token.name.replace("-default", "")}`;
|
|
72
|
+
if (token.attributes.appearance) {
|
|
73
|
+
return ` ${name}: ${token.attributes.appearance.dark.value},`;
|
|
74
|
+
}
|
|
75
|
+
return ` ${name}: ${value},`;
|
|
76
|
+
})
|
|
77
|
+
.join(`\n`);
|
|
78
|
+
|
|
79
|
+
const nonColor = dictionary.allTokens
|
|
80
|
+
.filter((token) => {
|
|
81
|
+
let isColor = true;
|
|
82
|
+
nonColorTokens.forEach((t) => {
|
|
83
|
+
if (token.name.includes(t)) {
|
|
84
|
+
isColor = false;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return !isColor;
|
|
88
|
+
})
|
|
89
|
+
.map((token) => {
|
|
90
|
+
const value = token.value;
|
|
91
|
+
const name = `${token.name.replace("-default", "")}`;
|
|
92
|
+
if (token.name.includes("font-family")) return ` ${name}: "${value}",`;
|
|
93
|
+
return ` ${name}: ${value},`;
|
|
94
|
+
})
|
|
95
|
+
.join(`\n`);
|
|
96
|
+
|
|
97
|
+
return [
|
|
98
|
+
`$light: (`,
|
|
99
|
+
light,
|
|
100
|
+
`);`,
|
|
101
|
+
`$dark: (`,
|
|
102
|
+
dark,
|
|
103
|
+
`);`,
|
|
104
|
+
`$nonColor: (`,
|
|
105
|
+
nonColor,
|
|
106
|
+
`);`,
|
|
107
|
+
].join(`\n`);
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
StyleDictionary.registerFormat({
|
|
112
|
+
name: `custom/primitive-variables`,
|
|
113
|
+
formatter: function ({ dictionary }) {
|
|
114
|
+
const vars = dictionary.allTokens
|
|
115
|
+
.map((token) => {
|
|
116
|
+
const value = token.value;
|
|
117
|
+
const name = `${token.name.replace("-default", "")}`;
|
|
118
|
+
if (token.name.includes("font-family")) return ` ${name}: "${value}",`;
|
|
119
|
+
return ` ${name}: ${value},`;
|
|
120
|
+
})
|
|
121
|
+
.join(`\n`);
|
|
122
|
+
|
|
123
|
+
return [`$token: (`, vars, `);`].join(`\n`);
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
StyleDictionary.registerFormat({
|
|
128
|
+
name: `custom/es6`,
|
|
129
|
+
formatter: function ({ dictionary }) {
|
|
130
|
+
const light = dictionary.allTokens
|
|
131
|
+
.filter((token) => !!token.attributes.appearance)
|
|
132
|
+
.map((token) => {
|
|
133
|
+
const value = JSON.stringify(token.value);
|
|
134
|
+
const name = token.name.replace("Default", "");
|
|
135
|
+
return `\t${name}: ${value}`;
|
|
136
|
+
})
|
|
137
|
+
.join(`,\n`);
|
|
138
|
+
const dark = dictionary.allTokens
|
|
139
|
+
.filter((token) => !!token.attributes.appearance)
|
|
140
|
+
.map((token) => {
|
|
141
|
+
const value = JSON.stringify(token.attributes.appearance.dark.value);
|
|
142
|
+
const name = token.name.replace("Default", "");
|
|
143
|
+
return `\t${name}: ${value}`;
|
|
144
|
+
})
|
|
145
|
+
.join(`,\n`);
|
|
146
|
+
const common = dictionary.allTokens
|
|
147
|
+
.filter((token) => !token.attributes.appearance)
|
|
148
|
+
.map((token) => {
|
|
149
|
+
const value = JSON.stringify(token.value);
|
|
150
|
+
const name = token.name.replace("Default", "");
|
|
151
|
+
return `\t${name}: ${value}`;
|
|
152
|
+
})
|
|
153
|
+
.join(`,\n`);
|
|
154
|
+
return `export const common = {\n${common}\n}\nexport const light = {\n${light}\n}\nexport const dark = {\n${dark}\n}\n`;
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
StyleDictionary.registerFormat({
|
|
159
|
+
name: `custom/es6Variable`,
|
|
160
|
+
formatter: function ({ dictionary }) {
|
|
161
|
+
return dictionary.allTokens
|
|
162
|
+
.map((token) => {
|
|
163
|
+
const value = token.value;
|
|
164
|
+
const name = `${token.name.replace("Default", "")}`;
|
|
165
|
+
if (token.attributes.appearance) {
|
|
166
|
+
return `export const ${name} = {
|
|
167
|
+
value: "${value}",
|
|
168
|
+
attributes: {
|
|
169
|
+
appearance: {
|
|
170
|
+
dark: {
|
|
171
|
+
value: "${token.attributes.appearance.dark.value}"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};`;
|
|
176
|
+
}
|
|
177
|
+
return `export const ${name} = { value: "${value}" };`;
|
|
178
|
+
})
|
|
179
|
+
.join(`\n`);
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
|
|
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;
|
|
268
|
+
|
|
269
|
+
${withSr}
|
|
270
|
+
${colorFallbackTokens}
|
|
271
|
+
|
|
272
|
+
@supports (color: light-dark(#fff, #000)) {
|
|
273
|
+
${colorTokens.replaceAll("\n", "\n ")}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
@layer application {
|
|
277
|
+
${withSr.replaceAll("\n", "\n ")}
|
|
278
|
+
${colorFallbackTokens.replaceAll("\n", "\n ")}
|
|
279
|
+
|
|
280
|
+
@supports (color: light-dark(#fff, #000)) {
|
|
281
|
+
${colorTokens.replaceAll("\n", "\n ")}
|
|
282
|
+
}
|
|
283
|
+
}`;
|
|
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
|
+
});
|
|
306
|
+
|
|
307
|
+
StyleDictionary.registerFormat({
|
|
308
|
+
name: `custom/CSSUtils/${prefix}Fonts`,
|
|
309
|
+
formatter: function ({ dictionary }) {
|
|
310
|
+
return cssUtilsFormatter(dictionary, generateFontClasses, { prefix });
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
StyleDictionary.registerFormat({
|
|
315
|
+
name: `custom/CSSUtils/${prefix}Spacing`,
|
|
316
|
+
formatter: function ({ dictionary }) {
|
|
317
|
+
return cssUtilsFormatter(dictionary, generateSpacingClasses, { prefix });
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const getDirectories = (source) =>
|
|
323
|
+
fs
|
|
324
|
+
.readdirSync(source, { withFileTypes: true })
|
|
325
|
+
.filter((dirent) => dirent.isDirectory())
|
|
326
|
+
.map((dirent) => dirent.name);
|
|
327
|
+
|
|
328
|
+
const themes = getDirectories(`src/theme`);
|
|
329
|
+
|
|
330
|
+
themes.forEach((theme) => {
|
|
331
|
+
StyleDictionary.extend({
|
|
332
|
+
source: [`src/theme/${theme}/*.js`, `src/theme/${theme}/component/*.js`],
|
|
333
|
+
include: ["src/global/primitive/*.js"],
|
|
334
|
+
platforms: {
|
|
335
|
+
css: {
|
|
336
|
+
transformGroup: "css",
|
|
337
|
+
buildPath: `build/web/${theme}/css-utils/`,
|
|
338
|
+
files: CSS_UTILS_PREFIXES.flatMap((prefix) => [
|
|
339
|
+
{
|
|
340
|
+
destination: `${prefix}utils.css`,
|
|
341
|
+
format: `custom/CSSUtils/${prefix}All`,
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
destination: `${prefix}border.css`,
|
|
345
|
+
format: `custom/CSSUtils/${prefix}Borders`,
|
|
346
|
+
filter: function (token) {
|
|
347
|
+
return token.filePath.includes("border");
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
destination: `${prefix}color.css`,
|
|
352
|
+
format: `custom/CSSUtils/${prefix}Colors`,
|
|
353
|
+
filter: function (token) {
|
|
354
|
+
return (
|
|
355
|
+
token.filePath.includes("primitive/color") ||
|
|
356
|
+
token.name.includes("color")
|
|
357
|
+
);
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
destination: `${prefix}font.css`,
|
|
362
|
+
format: `custom/CSSUtils/${prefix}Fonts`,
|
|
363
|
+
filter: function (token) {
|
|
364
|
+
return (
|
|
365
|
+
token.filePath.includes("primitive/font") ||
|
|
366
|
+
token.filePath.includes("typography")
|
|
367
|
+
);
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
destination: `${prefix}spacing.css`,
|
|
372
|
+
format: `custom/CSSUtils/${prefix}Spacing`,
|
|
373
|
+
filter: function (token) {
|
|
374
|
+
return token.filePath.startsWith("src/global/primitive/size");
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
]),
|
|
378
|
+
},
|
|
379
|
+
scss: {
|
|
380
|
+
transformGroup: "scss",
|
|
381
|
+
buildPath: `build/web/${theme}/`,
|
|
382
|
+
files: [
|
|
383
|
+
{
|
|
384
|
+
destination: "primitive.scss",
|
|
385
|
+
format: "custom/SCSSVariable",
|
|
386
|
+
filter: function (token) {
|
|
387
|
+
return token.filePath.startsWith("src/global/primitive");
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
destination: "primitive-variables.scss",
|
|
392
|
+
format: "custom/primitive-variables",
|
|
393
|
+
filter: function (token) {
|
|
394
|
+
return token.filePath.startsWith("src/global/primitive");
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
destination: "semantic.scss",
|
|
399
|
+
format: "custom/SCSSVariable",
|
|
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: "semantic-variables.scss",
|
|
409
|
+
format: "custom/variables-map",
|
|
410
|
+
filter: function (token) {
|
|
411
|
+
return (
|
|
412
|
+
token.filePath.startsWith(`src/theme/${theme}`) &&
|
|
413
|
+
!token.filePath.startsWith(`src/theme/${theme}/component`)
|
|
414
|
+
);
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
destination: "component.scss",
|
|
419
|
+
format: "custom/SCSSVariable",
|
|
420
|
+
filter: function (token) {
|
|
421
|
+
return token.filePath.startsWith(`src/theme/${theme}/component`);
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
destination: "component-variables.scss",
|
|
426
|
+
format: "custom/variables-map",
|
|
427
|
+
filter: function (token) {
|
|
428
|
+
return token.filePath.startsWith(`src/theme/${theme}/component`);
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
],
|
|
432
|
+
},
|
|
433
|
+
tsLight: {
|
|
434
|
+
transformGroup: "js",
|
|
435
|
+
buildPath: `build/web/${theme}/`,
|
|
436
|
+
files: [
|
|
437
|
+
{
|
|
438
|
+
format: "custom/es6Variable",
|
|
439
|
+
destination: "primitive.js",
|
|
440
|
+
filter: function (token) {
|
|
441
|
+
return token.filePath.startsWith("src/global/primitive");
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
format: "custom/es6",
|
|
446
|
+
destination: "raw.js",
|
|
447
|
+
filter: function (token) {
|
|
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: "semantic.js",
|
|
457
|
+
filter: function (token) {
|
|
458
|
+
return (
|
|
459
|
+
token.filePath.startsWith(`src/theme/${theme}`) &&
|
|
460
|
+
!token.filePath.startsWith(`src/theme/${theme}/component`)
|
|
461
|
+
);
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
format: "custom/es6Variable",
|
|
466
|
+
destination: "component.js",
|
|
467
|
+
filter: function (token) {
|
|
468
|
+
return token.filePath.startsWith(`src/theme/${theme}/component`);
|
|
469
|
+
},
|
|
470
|
+
},
|
|
471
|
+
],
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
}).buildAllPlatforms();
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
console.log("\n==============================================");
|
|
478
|
+
console.log("Building index files...\n");
|
|
479
|
+
const mainJS = fs.createWriteStream(`build/web/index.js`);
|
|
480
|
+
|
|
481
|
+
const mainType = fs.createWriteStream(`build/web/index.d.ts`);
|
|
482
|
+
mainType.write(`import Token from '../../type/types';\n`);
|
|
483
|
+
|
|
484
|
+
themes.forEach((theme) => {
|
|
485
|
+
const indexJS = fs.createWriteStream(`build/web/${theme}/index.js`);
|
|
486
|
+
indexJS.write(`import * as semantic from './semantic';\n`);
|
|
487
|
+
indexJS.write(`import * as primitive from './primitive';\n`);
|
|
488
|
+
indexJS.write(`import * as component from './component';\n`);
|
|
489
|
+
indexJS.write(`const name = '${theme}';\n`);
|
|
490
|
+
indexJS.write(`export { primitive, semantic, component, name };\n`);
|
|
491
|
+
indexJS.end();
|
|
492
|
+
mainType.write(`declare const ${theme}: Token;\n`);
|
|
493
|
+
mainJS.write(`import * as ${theme} from './${theme}';\n`);
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
mainType.write(`export { Token }\n`);
|
|
497
|
+
mainType.write(`export { ${themes.join(", ")} }\n`);
|
|
498
|
+
mainType.end();
|
|
499
|
+
|
|
500
|
+
mainJS.write(`export * as Token from '../../type/types';\n`);
|
|
501
|
+
mainJS.write(`export { ${themes.join(", ")} };\n`);
|
|
502
|
+
mainJS.end();
|
|
503
|
+
console.log(`Index built!`);
|
|
504
|
+
console.log("==============================================\n");
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@servicetitan/hammer-token",
|
|
3
|
+
"version": "0.0.0-rc-20250807234739",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "build/web/index.js",
|
|
6
|
+
"types": "build/web/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"hammer-token": "./src/utils/copy-css-utils-cli.js"
|
|
9
|
+
},
|
|
10
|
+
"optionalDependencies": {
|
|
11
|
+
"commander": "^12.1.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"fs-extra": "^11.2.0",
|
|
15
|
+
"style-dictionary": "^3",
|
|
16
|
+
"tinycolor2": "^1.6.0"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "node ./config.js",
|
|
20
|
+
"dev": "pnpm build && chokidar \"./src\" -c \"pnpm build\"",
|
|
21
|
+
"clean": "rimraf build .turbo",
|
|
22
|
+
"lint": "eslint .",
|
|
23
|
+
"nuke": "pnpm clean && rimraf node_modules"
|
|
24
|
+
}
|
|
25
|
+
}
|