@tac-ui/tokens 0.1.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.
@@ -0,0 +1,336 @@
1
+ import { semanticTokens, chart, elevation, motion, typography, px, component, rem, unitless, zIndex, ms, radius, spacing } from '../chunk-T3JFXTDW.mjs';
2
+
3
+ // src/web/css-variables.ts
4
+ function generateCSSVariables(mode) {
5
+ const colors = semanticTokens[mode];
6
+ const chartTokens = chart[mode];
7
+ const elevationMode = elevation[mode];
8
+ return {
9
+ // Font
10
+ "--font-primary": `'${typography.fontFamily.primary}', -apple-system, BlinkMacSystemFont, system-ui, sans-serif`,
11
+ "--font-secondary": `'${typography.fontFamily.secondary}', sans-serif`,
12
+ "--font-display": `'${typography.fontFamily.display}', '${typography.fontFamily.primary}', sans-serif`,
13
+ // Colors
14
+ "--background": colors.background,
15
+ "--background-subtle": colors.backgroundSubtle,
16
+ "--foreground": colors.foreground,
17
+ "--surface": colors.surface,
18
+ "--surface-hover": colors.surfaceHover,
19
+ "--primary": colors.primary,
20
+ "--primary-hover": colors.primaryHover,
21
+ "--primary-foreground": colors.primaryForeground,
22
+ "--secondary": colors.secondary,
23
+ "--secondary-foreground": colors.secondaryForeground,
24
+ "--muted": colors.muted,
25
+ "--muted-foreground": colors.mutedForeground,
26
+ "--card": colors.card,
27
+ "--card-foreground": colors.cardForeground,
28
+ "--border": colors.border,
29
+ "--input": colors.input,
30
+ "--ring": colors.ring,
31
+ "--point": colors.point,
32
+ "--point-hover": colors.pointHover,
33
+ "--point-foreground": colors.pointForeground,
34
+ "--point-subtle": colors.pointSubtle,
35
+ "--accent-glow": colors.accentGlow,
36
+ // Glass
37
+ "--glass-bg": colors.glassBg,
38
+ "--glass-border": colors.glassBorder,
39
+ // Gradients
40
+ "--gradient-brand": colors.gradientBrand,
41
+ "--gradient-brand-hover": colors.gradientBrandHover,
42
+ "--gradient-subtle": colors.gradientSubtle,
43
+ "--gradient-accent": colors.gradientAccent,
44
+ "--gradient-accent-vivid": colors.gradientAccentVivid,
45
+ "--gradient-glow": colors.gradientGlow,
46
+ "--gradient-mesh": colors.gradientMesh,
47
+ "--gradient-surface": colors.gradientSurface,
48
+ "--gradient-glow-shadow": colors.gradientGlowShadow,
49
+ // Status
50
+ "--success": colors.success,
51
+ "--success-bg": colors.successBg,
52
+ "--success-foreground": colors.successForeground,
53
+ "--warning": colors.warning,
54
+ "--warning-bg": colors.warningBg,
55
+ "--warning-foreground": colors.warningForeground,
56
+ "--error": colors.error,
57
+ "--error-bg": colors.errorBg,
58
+ "--error-foreground": colors.errorForeground,
59
+ "--info": colors.info,
60
+ "--info-bg": colors.infoBg,
61
+ "--info-foreground": colors.infoForeground,
62
+ "--shadow-color": colors.shadowColor,
63
+ // Gray scale
64
+ "--gray-50": colors.gray50,
65
+ "--gray-100": colors.gray100,
66
+ "--gray-200": colors.gray200,
67
+ "--gray-300": colors.gray300,
68
+ "--gray-400": colors.gray400,
69
+ "--gray-500": colors.gray500,
70
+ "--gray-600": colors.gray600,
71
+ "--gray-700": colors.gray700,
72
+ "--gray-800": colors.gray800,
73
+ "--gray-900": colors.gray900,
74
+ // Surface layers
75
+ "--surface-base": colors.surfaceBase,
76
+ "--surface-elevated-low": colors.surfaceElevatedLow,
77
+ "--surface-elevated-mid": colors.surfaceElevatedMid,
78
+ "--surface-elevated-high": colors.surfaceElevatedHigh,
79
+ // Interaction states
80
+ "--interactive-hover": colors.interactiveHover,
81
+ "--interactive-pressed": colors.interactivePressed,
82
+ "--interactive-focus": colors.interactiveFocus,
83
+ // Button tokens
84
+ "--btn-primary-surface": colors.btnPrimarySurface,
85
+ "--btn-primary-hover": colors.btnPrimaryHover,
86
+ "--btn-primary-energy": colors.btnPrimaryEnergy,
87
+ "--btn-primary-inset": colors.btnPrimaryInset,
88
+ "--btn-secondary-surface": colors.btnSecondarySurface,
89
+ "--btn-secondary-hover": colors.btnSecondaryHover,
90
+ "--btn-outline-border": colors.btnOutlineBorder,
91
+ "--btn-outline-border-hover": colors.btnOutlineBorderHover,
92
+ "--btn-outline-hover-bg": colors.btnOutlineHoverBg,
93
+ "--btn-ghost-hover": colors.btnGhostHover,
94
+ "--btn-point-surface": colors.btnPointSurface,
95
+ "--btn-point-border": colors.btnPointBorder,
96
+ "--btn-point-hover-surface": colors.btnPointHoverSurface,
97
+ "--btn-point-hover-border": colors.btnPointHoverBorder,
98
+ "--btn-point-energy": colors.btnPointEnergy,
99
+ "--btn-destructive-surface": colors.btnDestructiveSurface,
100
+ "--btn-destructive-hover": colors.btnDestructiveHover,
101
+ // Shared interactive tokens
102
+ "--interactive-surface-tint": colors.interactiveSurfaceTint,
103
+ "--interactive-hover-tint": colors.interactiveHoverTint,
104
+ "--focus-glow": colors.focusGlow,
105
+ "--point-glow": colors.pointGlow,
106
+ "--glass-inset": colors.glassInset,
107
+ "--glass-panel-shadow": colors.glassPanelShadow,
108
+ // Input tokens
109
+ "--input-bg": colors.inputBg,
110
+ "--input-border-rest": colors.inputBorderRest,
111
+ "--input-border-hover": colors.inputBorderHover,
112
+ "--input-hover-glow": colors.inputHoverGlow,
113
+ "--input-focus-glow": colors.inputFocusGlow,
114
+ "--input-error-glow": colors.inputErrorGlow,
115
+ // Dropdown tokens
116
+ "--dropdown-bg": colors.dropdownBg,
117
+ "--dropdown-shadow": colors.dropdownShadow,
118
+ "--dropdown-item-hover": colors.dropdownItemHover,
119
+ // Card accent tokens
120
+ "--card-accent-border": colors.cardAccentBorder,
121
+ "--card-accent-glow": colors.cardAccentGlow,
122
+ "--card-accent-hover-border": colors.cardAccentHoverBorder,
123
+ "--card-accent-hover-glow": colors.cardAccentHoverGlow,
124
+ // Spacing
125
+ "--spacing-2xs": rem(spacing["2xs"]),
126
+ "--spacing-xs": rem(spacing.xs),
127
+ "--spacing-sm": rem(spacing.sm),
128
+ "--spacing-m": rem(spacing.m),
129
+ "--spacing-lg": rem(spacing.lg),
130
+ "--spacing-xl": rem(spacing.xl),
131
+ "--spacing-2xl": rem(spacing["2xl"]),
132
+ "--spacing-3xl": rem(spacing["3xl"]),
133
+ // Radius
134
+ "--radius-none": unitless(radius.none),
135
+ "--radius-xs": rem(radius.xs),
136
+ "--radius-sm": rem(radius.sm),
137
+ "--radius-m": rem(radius.m),
138
+ "--radius-lg": rem(radius.lg),
139
+ "--radius-xl": rem(radius.xl),
140
+ "--radius-2xl": rem(radius["2xl"]),
141
+ "--radius-pill": px(radius.pill),
142
+ // Elevation
143
+ "--shadow-sm": elevationMode.sm,
144
+ "--shadow-m": elevationMode.m,
145
+ "--shadow-lg": elevationMode.lg,
146
+ "--shadow-xl": elevationMode.xl,
147
+ "--shadow-glass": elevationMode.glass,
148
+ "--shadow-glass-lg": elevationMode.glassLg,
149
+ // Motion
150
+ "--duration-instant": ms(motion.duration.instant),
151
+ "--duration-fast": ms(motion.duration.fast),
152
+ "--duration-normal": ms(motion.duration.normal),
153
+ "--duration-slow": ms(motion.duration.slow),
154
+ "--duration-complex": ms(motion.duration.complex),
155
+ "--ease-standard": motion.easing.standard,
156
+ "--ease-in": motion.easing.easeIn,
157
+ "--ease-out": motion.easing.easeOut,
158
+ "--ease-in-out": motion.easing.easeInOut,
159
+ "--ease-bounce": motion.easing.bounce,
160
+ "--ease-spring": motion.easing.spring,
161
+ "--ease-elastic": motion.easing.elastic,
162
+ // Chart
163
+ "--chart-1": chartTokens.colors[0],
164
+ "--chart-2": chartTokens.colors[1],
165
+ "--chart-3": chartTokens.colors[2],
166
+ "--chart-4": chartTokens.colors[3],
167
+ "--chart-5": chartTokens.colors[4],
168
+ "--chart-6": chartTokens.colors[5],
169
+ "--chart-7": chartTokens.colors[6],
170
+ "--chart-8": chartTokens.colors[7],
171
+ "--chart-grid": chartTokens.grid,
172
+ "--chart-axis": chartTokens.axis,
173
+ "--chart-label": chartTokens.label,
174
+ "--chart-tooltip-bg": chartTokens.tooltipBg,
175
+ "--chart-line-width": px(chart.lineWidth),
176
+ "--chart-dot-size": px(chart.dotSize),
177
+ "--chart-bar-radius": px(chart.barRadius),
178
+ "--chart-area-opacity": unitless(chart.areaOpacity),
179
+ // Tooltip
180
+ "--tooltip-delay": ms(motion.duration.fast),
181
+ "--tooltip-padding": rem(16),
182
+ "--tooltip-radius": rem(12),
183
+ // Z-Index
184
+ "--z-dropdown": unitless(zIndex.dropdown),
185
+ "--z-sticky": unitless(zIndex.sticky),
186
+ "--z-overlay": unitless(zIndex.overlay),
187
+ "--z-modal": unitless(zIndex.modal),
188
+ "--z-popover": unitless(zIndex.popover),
189
+ "--z-tooltip": unitless(zIndex.tooltip),
190
+ "--z-toast": unitless(zIndex.toast),
191
+ // Component: Button
192
+ "--btn-sm-height": rem(component.button.sm.height),
193
+ "--btn-sm-px": rem(component.button.sm.paddingX),
194
+ "--btn-sm-font-size": rem(component.button.sm.fontSize),
195
+ "--btn-sm-radius": px(component.button.sm.borderRadius),
196
+ "--btn-md-height": rem(component.button.md.height),
197
+ "--btn-md-px": rem(component.button.md.paddingX),
198
+ "--btn-md-font-size": rem(component.button.md.fontSize),
199
+ "--btn-md-radius": px(component.button.md.borderRadius),
200
+ "--btn-lg-height": rem(component.button.lg.height),
201
+ "--btn-lg-px": rem(component.button.lg.paddingX),
202
+ "--btn-lg-font-size": rem(component.button.lg.fontSize),
203
+ "--btn-lg-radius": px(component.button.lg.borderRadius),
204
+ "--btn-icon-size": px(component.button.md.iconSize),
205
+ // Component: Input
206
+ "--input-height": rem(component.input.height),
207
+ "--input-px": rem(component.input.paddingX),
208
+ "--input-py": rem(component.input.paddingY),
209
+ "--input-font-size": rem(component.input.fontSize),
210
+ "--input-radius": px(component.input.borderRadius),
211
+ "--input-icon-size": px(component.input.iconSize),
212
+ "--input-icon-padding": rem(component.input.iconPadding),
213
+ // Component: Card
214
+ "--card-padding": rem(component.card.padding),
215
+ "--card-gap": rem(component.card.gap),
216
+ "--card-radius": px(component.card.borderRadius),
217
+ "--card-title-size": rem(component.card.titleSize),
218
+ "--card-body-size": rem(component.card.bodySize),
219
+ // Component: Badge
220
+ "--badge-px": rem(component.badge.paddingX),
221
+ "--badge-py": rem(component.badge.paddingY),
222
+ "--badge-font-size": rem(component.badge.fontSize),
223
+ "--badge-radius": px(component.badge.borderRadius),
224
+ // Component: Checkbox
225
+ "--checkbox-size": px(component.checkbox.size),
226
+ "--checkbox-radius": px(component.checkbox.borderRadius),
227
+ "--checkbox-border-width": px(component.checkbox.borderWidth),
228
+ "--checkbox-icon-size": px(component.checkbox.iconSize),
229
+ "--checkbox-gap": rem(component.checkbox.gap),
230
+ "--checkbox-label-size": rem(component.checkbox.labelSize),
231
+ // Component: Radio
232
+ "--radio-size": px(component.radio.size),
233
+ "--radio-border-width": px(component.radio.borderWidth),
234
+ "--radio-checked-border-width": px(component.radio.checkedBorderWidth),
235
+ "--radio-gap": rem(component.radio.gap),
236
+ "--radio-label-size": rem(component.radio.labelSize),
237
+ // Component: Switch
238
+ "--switch-width": px(component.switch.width),
239
+ "--switch-height": px(component.switch.height),
240
+ "--switch-thumb-size": px(component.switch.thumbSize),
241
+ "--switch-thumb-offset": px(component.switch.thumbOffset),
242
+ "--switch-thumb-translate-on": px(component.switch.thumbTranslateOn),
243
+ "--switch-thumb-translate-off": px(component.switch.thumbTranslateOff),
244
+ // Component: Chip
245
+ "--chip-px": rem(component.chip.paddingX),
246
+ "--chip-py": rem(component.chip.paddingY),
247
+ "--chip-font-size": rem(component.chip.fontSize),
248
+ "--chip-radius": px(component.chip.borderRadius),
249
+ "--chip-icon-size": px(component.chip.iconSize),
250
+ // Component: Tabs
251
+ "--tab-primary-px": rem(component.tabs.primary.paddingX),
252
+ "--tab-primary-py": rem(component.tabs.primary.paddingY),
253
+ "--tab-primary-font-size": rem(component.tabs.primary.fontSize),
254
+ "--tab-primary-indicator": px(component.tabs.primary.indicatorHeight),
255
+ "--tab-secondary-px": rem(component.tabs.secondary.paddingX),
256
+ "--tab-secondary-py": rem(component.tabs.secondary.paddingY),
257
+ "--tab-secondary-font-size": rem(component.tabs.secondary.fontSize),
258
+ "--tab-secondary-container-padding": px(component.tabs.secondary.containerPadding),
259
+ "--tab-secondary-container-radius": px(component.tabs.secondary.containerRadius),
260
+ "--tab-secondary-item-radius": px(component.tabs.secondary.itemRadius),
261
+ // Component: Slider
262
+ "--slider-track-height": px(component.slider.trackHeight),
263
+ "--slider-thumb-size": px(component.slider.thumbSize),
264
+ "--slider-thumb-border": px(component.slider.thumbBorderWidth),
265
+ // Component: Tooltip
266
+ "--tooltip-simple-px": rem(component.tooltip.simple.paddingX),
267
+ "--tooltip-simple-py": rem(component.tooltip.simple.paddingY),
268
+ "--tooltip-simple-font-size": rem(component.tooltip.simple.fontSize),
269
+ "--tooltip-simple-radius": px(component.tooltip.simple.borderRadius),
270
+ "--tooltip-rich-px": rem(component.tooltip.rich.paddingX),
271
+ "--tooltip-rich-py": rem(component.tooltip.rich.paddingY),
272
+ "--tooltip-rich-max-width": px(component.tooltip.rich.maxWidth),
273
+ "--tooltip-rich-radius": px(component.tooltip.rich.borderRadius),
274
+ // Component: Avatar
275
+ "--avatar-sm": px(component.avatar.sm.size),
276
+ "--avatar-md": px(component.avatar.md.size),
277
+ "--avatar-lg": px(component.avatar.lg.size),
278
+ "--avatar-xl": px(component.avatar.xl.size),
279
+ "--avatar-status-dot": px(component.avatar.statusDot),
280
+ "--avatar-status-border": px(component.avatar.statusBorder),
281
+ // Component: Divider
282
+ "--divider-thickness": px(component.divider.thickness),
283
+ "--divider-thick": px(component.divider.thickThickness),
284
+ "--divider-inset-margin": px(component.divider.insetMargin),
285
+ "--divider-label-size": rem(component.divider.labelSize),
286
+ // Component: Progress
287
+ "--progress-height": px(component.progress.linear.height),
288
+ "--progress-radius": px(component.progress.linear.borderRadius),
289
+ "--progress-circular-stroke": px(component.progress.circular.strokeWidth),
290
+ "--progress-circular-text": rem(component.progress.circular.textSize),
291
+ // Component: Snackbar
292
+ "--snackbar-radius": px(component.snackbar.borderRadius),
293
+ "--snackbar-gap": rem(component.snackbar.gap),
294
+ "--snackbar-icon-size": px(component.snackbar.iconSize),
295
+ "--snackbar-message-size": rem(component.snackbar.messageSize),
296
+ "--snackbar-action-px": rem(component.snackbar.actionPaddingX),
297
+ "--snackbar-action-py": rem(component.snackbar.actionPaddingY),
298
+ "--snackbar-action-radius": px(component.snackbar.actionRadius),
299
+ "--snackbar-action-size": rem(component.snackbar.actionSize),
300
+ // Component: Dialog
301
+ "--dialog-width": px(component.dialog.width),
302
+ "--dialog-radius": px(component.dialog.borderRadius),
303
+ "--dialog-header-px": rem(component.dialog.headerPaddingX),
304
+ "--dialog-header-py": rem(component.dialog.headerPaddingY),
305
+ "--dialog-footer-px": rem(component.dialog.footerPaddingX),
306
+ "--dialog-footer-py": rem(component.dialog.footerPaddingY),
307
+ "--dialog-title-size": rem(component.dialog.titleSize),
308
+ "--dialog-desc-size": rem(component.dialog.descSize),
309
+ "--dialog-footer-gap": rem(component.dialog.footerGap),
310
+ // Component: AnimatedToggle
311
+ "--toggle-size": px(component.animatedToggle.size),
312
+ "--toggle-radius": px(component.animatedToggle.borderRadius),
313
+ "--toggle-icon-size": px(component.animatedToggle.iconSize)
314
+ };
315
+ }
316
+ function generateCSSBlock(mode) {
317
+ const vars = generateCSSVariables(mode);
318
+ return Object.entries(vars).map(([key, value]) => ` ${key}: ${value};`).join("\n");
319
+ }
320
+ function generateKeyframes() {
321
+ const { keyframes } = motion;
322
+ return Object.entries(keyframes).map(([name, frames]) => {
323
+ const kebab = name.replace(/([A-Z])/g, "-$1").toLowerCase();
324
+ const body = Object.entries(frames).map(([key, props]) => {
325
+ const cssProps = Object.entries(props).map(([p, v]) => ` ${p.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${v};`).join("\n");
326
+ return ` ${key} {
327
+ ${cssProps}
328
+ }`;
329
+ }).join("\n");
330
+ return `@keyframes ${kebab} {
331
+ ${body}
332
+ }`;
333
+ }).join("\n\n");
334
+ }
335
+
336
+ export { generateCSSBlock, generateCSSVariables, generateKeyframes };
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@tac-ui/tokens",
3
+ "version": "0.1.0",
4
+ "description": "Design tokens for Tac UI",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ },
14
+ "./web": {
15
+ "types": "./dist/web/css-variables.d.ts",
16
+ "import": "./dist/web/css-variables.mjs",
17
+ "require": "./dist/web/css-variables.js"
18
+ }
19
+ },
20
+ "files": ["dist"],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "scripts": {
25
+ "build": "tsup",
26
+ "dev": "tsup --watch",
27
+ "lint": "eslint src/",
28
+ "typecheck": "tsc --noEmit",
29
+ "clean": "rm -rf dist"
30
+ },
31
+ "dependencies": {
32
+ "@tac-ui/shared": "workspace:*"
33
+ },
34
+ "devDependencies": {
35
+ "tsup": "^8.3.0",
36
+ "typescript": "^5.7.0"
37
+ }
38
+ }