omgkit 2.30.0 → 2.31.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/README.md +68 -10
- package/lib/generators/css.generator.js +151 -0
- package/lib/generators/figma.generator.js +311 -0
- package/lib/generators/index.js +135 -0
- package/lib/generators/scss.generator.js +249 -0
- package/lib/generators/style-dictionary.generator.js +456 -0
- package/lib/generators/tailwind.generator.js +251 -0
- package/lib/theme-v2.js +755 -0
- package/lib/theme.js +97 -4
- package/package.json +2 -2
- package/plugin/commands/design/export.md +232 -0
- package/plugin/commands/design/rebuild.md +46 -0
- package/plugin/commands/design/validate.md +223 -0
- package/plugin/registry.yaml +2 -2
- package/templates/design/schema/theme-v2.schema.json +384 -0
- package/templates/design/themes/tech-ai/electric-cyan-v2.json +362 -0
package/README.md
CHANGED
|
@@ -37,11 +37,11 @@ All coordinated through **Omega-level thinking** - a framework for finding break
|
|
|
37
37
|
| Component | Count | Description |
|
|
38
38
|
|-----------|-------|-------------|
|
|
39
39
|
| **Agents** | 41 | Specialized AI team members with distinct roles |
|
|
40
|
-
| **Commands** |
|
|
40
|
+
| **Commands** | 174 | Slash commands for every development task |
|
|
41
41
|
| **Workflows** | 69 | Complete development processes from idea to deploy |
|
|
42
|
-
| **Skills** |
|
|
42
|
+
| **Skills** | 162 | Domain expertise modules across 24 categories |
|
|
43
43
|
| **Modes** | 10 | Behavioral configurations for different contexts |
|
|
44
|
-
| **Themes** |
|
|
44
|
+
| **Themes** | 31 | Curated design system themes (V1 + V2 schemas) |
|
|
45
45
|
| **Archetypes** | 14 | Project templates for autonomous development |
|
|
46
46
|
|
|
47
47
|
---
|
|
@@ -166,23 +166,38 @@ testing:
|
|
|
166
166
|
target: 85
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
### 6. Design System (
|
|
169
|
+
### 6. Design System (Enhanced in 2.30.0)
|
|
170
170
|
|
|
171
|
-
OMGKIT includes a complete design system with
|
|
171
|
+
OMGKIT includes a complete design system with 31 curated themes for shadcn/ui integration. Now supports both **V1** (flat colors) and **V2** (color scales, effects, animations) theme schemas.
|
|
172
172
|
|
|
173
173
|
```bash
|
|
174
174
|
# Initialize with a theme (opt-in)
|
|
175
175
|
omgkit init --theme neo-tokyo
|
|
176
176
|
|
|
177
|
+
# Or use a V2 theme with advanced features
|
|
178
|
+
omgkit init --theme electric-cyan-v2
|
|
179
|
+
|
|
177
180
|
# Or explore themes first
|
|
178
181
|
omgkit init --with-design
|
|
179
182
|
```
|
|
180
183
|
|
|
184
|
+
#### Theme Schema Versions
|
|
185
|
+
|
|
186
|
+
| Feature | V1 | V2 |
|
|
187
|
+
|---------|----|----|
|
|
188
|
+
| Flat colors | ✓ | ✓ |
|
|
189
|
+
| 12-step color scales | - | ✓ |
|
|
190
|
+
| $ref token references | - | ✓ |
|
|
191
|
+
| Status colors (success/warning/info) | - | ✓ |
|
|
192
|
+
| Effects (glass, glow, gradient) | - | ✓ |
|
|
193
|
+
| Animations (keyframes) | - | ✓ |
|
|
194
|
+
| Alpha variants | - | ✓ |
|
|
195
|
+
|
|
181
196
|
#### 5 Theme Categories
|
|
182
197
|
|
|
183
198
|
| Category | Themes | Description |
|
|
184
199
|
|----------|--------|-------------|
|
|
185
|
-
| **Tech & AI** | neo-tokyo, electric-cyan, neural-dark, matrix-green, quantum-purple, hologram | Futuristic, cyberpunk-inspired |
|
|
200
|
+
| **Tech & AI** | neo-tokyo, electric-cyan, electric-cyan-v2, neural-dark, matrix-green, quantum-purple, hologram | Futuristic, cyberpunk-inspired |
|
|
186
201
|
| **Minimal & Clean** | minimal-slate, paper, mono, zen, nordic, swiss | Simple, elegant, distraction-free |
|
|
187
202
|
| **Corporate** | ocean-blue, corporate-indigo, finance, legal, healthcare, consulting | Professional, trustworthy |
|
|
188
203
|
| **Creative & Bold** | coral-sunset, candy, neon, gradient-dream, retro, studio | Vibrant, expressive |
|
|
@@ -192,7 +207,7 @@ omgkit init --with-design
|
|
|
192
207
|
|
|
193
208
|
| Command | Description |
|
|
194
209
|
|---------|-------------|
|
|
195
|
-
| `/design:themes` | List all
|
|
210
|
+
| `/design:themes` | List all 31 curated themes |
|
|
196
211
|
| `/design:theme <id>` | Apply a theme to your project |
|
|
197
212
|
| `/design:preview` | Preview current theme colors |
|
|
198
213
|
| `/design:builder` | Build custom theme interactively |
|
|
@@ -203,6 +218,25 @@ omgkit init --with-design
|
|
|
203
218
|
| `/design:rebuild <id>` | Rebuild entire project with new theme |
|
|
204
219
|
| `/design:scan` | Scan for non-compliant colors |
|
|
205
220
|
| `/design:rollback` | Rollback to previous theme |
|
|
221
|
+
| `/design:export <format>` | Export to CSS, SCSS, Tailwind, Figma, Style Dictionary |
|
|
222
|
+
| `/design:validate` | Validate theme structure |
|
|
223
|
+
|
|
224
|
+
#### Theme Export (New in 2.30.0)
|
|
225
|
+
|
|
226
|
+
Export your theme to various design tools and framework formats:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# Export CSS
|
|
230
|
+
/design:export css
|
|
231
|
+
|
|
232
|
+
# Export Figma tokens
|
|
233
|
+
/design:export figma --output ./tokens/
|
|
234
|
+
|
|
235
|
+
# Export all formats
|
|
236
|
+
/design:export --all
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Supported formats: `css`, `scss`, `tailwind`, `figma`, `style-dictionary`
|
|
206
240
|
|
|
207
241
|
#### Theme Rebuild
|
|
208
242
|
|
|
@@ -212,6 +246,9 @@ Rebuild your entire project's UI with a single command:
|
|
|
212
246
|
# Rebuild with new theme (scans and fixes hardcoded colors)
|
|
213
247
|
omgkit design:rebuild neo-tokyo
|
|
214
248
|
|
|
249
|
+
# Use V2 theme for advanced features
|
|
250
|
+
omgkit design:rebuild electric-cyan-v2
|
|
251
|
+
|
|
215
252
|
# Scan for non-compliant colors
|
|
216
253
|
omgkit design:scan
|
|
217
254
|
|
|
@@ -224,6 +261,27 @@ The rebuild feature:
|
|
|
224
261
|
- Scans `app/`, `components/`, `src/`, `pages/` directories
|
|
225
262
|
- Replaces hardcoded colors (`bg-blue-500`) with theme variables (`bg-primary`)
|
|
226
263
|
- Reports unfixable patterns for manual review
|
|
264
|
+
- V2 themes generate 12-step color scales and status colors
|
|
265
|
+
|
|
266
|
+
#### V2 Theme Features
|
|
267
|
+
|
|
268
|
+
V2 themes provide additional CSS variables:
|
|
269
|
+
|
|
270
|
+
```css
|
|
271
|
+
/* 12-step color scales */
|
|
272
|
+
--cyan-1 through --cyan-12
|
|
273
|
+
--cyan-a1 through --cyan-a12 /* Alpha variants */
|
|
274
|
+
|
|
275
|
+
/* Status colors */
|
|
276
|
+
--success, --warning, --info
|
|
277
|
+
|
|
278
|
+
/* Effects */
|
|
279
|
+
--glass-blur, --glow
|
|
280
|
+
|
|
281
|
+
/* Animations */
|
|
282
|
+
@keyframes shimmer { ... }
|
|
283
|
+
--animation-shimmer
|
|
284
|
+
```
|
|
227
285
|
|
|
228
286
|
#### How It Works
|
|
229
287
|
|
|
@@ -370,7 +428,7 @@ Agents are specialized AI team members, each with distinct expertise and respons
|
|
|
370
428
|
|
|
371
429
|
---
|
|
372
430
|
|
|
373
|
-
## Commands (
|
|
431
|
+
## Commands (174)
|
|
374
432
|
|
|
375
433
|
Commands are slash-prefixed actions organized by namespace.
|
|
376
434
|
|
|
@@ -635,7 +693,7 @@ Workflows are orchestrated sequences of agents, commands, and skills.
|
|
|
635
693
|
|
|
636
694
|
---
|
|
637
695
|
|
|
638
|
-
## Skills (
|
|
696
|
+
## Skills (162)
|
|
639
697
|
|
|
640
698
|
Skills are domain expertise modules organized in 24 categories.
|
|
641
699
|
|
|
@@ -987,7 +1045,7 @@ If any sync issue is detected (missing pages, wrong counts, broken links), the v
|
|
|
987
1045
|
|
|
988
1046
|
## Validation & Testing
|
|
989
1047
|
|
|
990
|
-
OMGKIT has
|
|
1048
|
+
OMGKIT has 8200+ automated tests ensuring system integrity.
|
|
991
1049
|
|
|
992
1050
|
### Run Tests
|
|
993
1051
|
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS Generator
|
|
3
|
+
* Generates CSS variables from theme (v1 and v2 compatible)
|
|
4
|
+
*
|
|
5
|
+
* @module lib/generators/css
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { detectThemeVersion, isV2Theme } from '../theme.js';
|
|
9
|
+
import {
|
|
10
|
+
processTheme,
|
|
11
|
+
processAnimations,
|
|
12
|
+
generateKeyframesCSS
|
|
13
|
+
} from '../theme-v2.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Generate CSS from theme
|
|
17
|
+
* @param {Object} theme - Theme object (v1 or v2)
|
|
18
|
+
* @param {Object} options - Generation options
|
|
19
|
+
* @param {boolean} options.includeBase - Include @layer base wrapper (default: true)
|
|
20
|
+
* @param {boolean} options.includeReset - Include border-box reset (default: true)
|
|
21
|
+
* @param {boolean} options.includeAnimations - Include keyframes (default: true)
|
|
22
|
+
* @returns {string} CSS content
|
|
23
|
+
*/
|
|
24
|
+
export function generateCSS(theme, options = {}) {
|
|
25
|
+
const {
|
|
26
|
+
includeBase = true,
|
|
27
|
+
includeReset = true,
|
|
28
|
+
includeAnimations = true
|
|
29
|
+
} = options;
|
|
30
|
+
|
|
31
|
+
const result = processTheme(theme);
|
|
32
|
+
const { light: lightVars, dark: darkVars } = result.variables;
|
|
33
|
+
|
|
34
|
+
// Generate variable declarations
|
|
35
|
+
const generateVars = (vars) => {
|
|
36
|
+
return Object.entries(vars)
|
|
37
|
+
.map(([key, value]) => ` --${key}: ${value};`)
|
|
38
|
+
.join('\n');
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const lightCSS = generateVars(lightVars);
|
|
42
|
+
const darkCSS = generateVars(darkVars);
|
|
43
|
+
|
|
44
|
+
// Typography
|
|
45
|
+
const fontSans = theme.typography?.fontFamily?.sans ||
|
|
46
|
+
theme.fontFamily?.sans ||
|
|
47
|
+
'Inter, system-ui, sans-serif';
|
|
48
|
+
const fontMono = theme.typography?.fontFamily?.mono ||
|
|
49
|
+
theme.fontFamily?.mono ||
|
|
50
|
+
'JetBrains Mono, monospace';
|
|
51
|
+
const radius = theme.spacing?.radius || theme.radius || '0.5rem';
|
|
52
|
+
|
|
53
|
+
// Animations
|
|
54
|
+
let keyframesCSS = '';
|
|
55
|
+
let animationVars = '';
|
|
56
|
+
|
|
57
|
+
if (includeAnimations && theme.animations) {
|
|
58
|
+
const { keyframes, animations } = processAnimations(theme.animations);
|
|
59
|
+
keyframesCSS = generateKeyframesCSS(keyframes);
|
|
60
|
+
animationVars = Object.entries(animations)
|
|
61
|
+
.map(([name, value]) => ` --animation-${name}: ${value};`)
|
|
62
|
+
.join('\n');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Build CSS
|
|
66
|
+
const version = detectThemeVersion(theme);
|
|
67
|
+
let css = `/* OMGKIT Theme: ${theme.name} */
|
|
68
|
+
/* Theme ID: ${theme.id} */
|
|
69
|
+
/* Category: ${theme.category} */
|
|
70
|
+
/* Version: ${version} */
|
|
71
|
+
/* Generated by OMGKIT Design System */
|
|
72
|
+
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
// Add keyframes
|
|
76
|
+
if (keyframesCSS) {
|
|
77
|
+
css += keyframesCSS + '\n';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Root variables
|
|
81
|
+
if (includeBase) {
|
|
82
|
+
css += `@layer base {
|
|
83
|
+
:root {
|
|
84
|
+
${lightCSS}
|
|
85
|
+
--radius: ${radius};
|
|
86
|
+
--font-sans: ${fontSans};
|
|
87
|
+
--font-mono: ${fontMono};
|
|
88
|
+
${animationVars ? animationVars + '\n' : ''}}
|
|
89
|
+
|
|
90
|
+
.dark {
|
|
91
|
+
${darkCSS}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
95
|
+
} else {
|
|
96
|
+
css += `:root {
|
|
97
|
+
${lightCSS}
|
|
98
|
+
--radius: ${radius};
|
|
99
|
+
--font-sans: ${fontSans};
|
|
100
|
+
--font-mono: ${fontMono};
|
|
101
|
+
${animationVars ? animationVars + '\n' : ''}}
|
|
102
|
+
|
|
103
|
+
.dark {
|
|
104
|
+
${darkCSS}
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Reset styles
|
|
110
|
+
if (includeReset && includeBase) {
|
|
111
|
+
css += `
|
|
112
|
+
@layer base {
|
|
113
|
+
* {
|
|
114
|
+
@apply border-border;
|
|
115
|
+
}
|
|
116
|
+
body {
|
|
117
|
+
@apply bg-background text-foreground;
|
|
118
|
+
font-family: var(--font-sans);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
} else if (includeReset) {
|
|
123
|
+
css += `
|
|
124
|
+
* {
|
|
125
|
+
border-color: hsl(var(--border));
|
|
126
|
+
}
|
|
127
|
+
body {
|
|
128
|
+
background-color: hsl(var(--background));
|
|
129
|
+
color: hsl(var(--foreground));
|
|
130
|
+
font-family: var(--font-sans);
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return css;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Generate CSS for a specific mode only
|
|
140
|
+
* @param {Object} theme - Theme object
|
|
141
|
+
* @param {string} mode - 'light' or 'dark'
|
|
142
|
+
* @returns {string} CSS content for that mode
|
|
143
|
+
*/
|
|
144
|
+
export function generateCSSForMode(theme, mode = 'light') {
|
|
145
|
+
const result = processTheme(theme, { mode });
|
|
146
|
+
const vars = result.variables[mode] || {};
|
|
147
|
+
|
|
148
|
+
return Object.entries(vars)
|
|
149
|
+
.map(([key, value]) => `--${key}: ${value};`)
|
|
150
|
+
.join('\n');
|
|
151
|
+
}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Figma Tokens Generator
|
|
3
|
+
* Generates Figma design tokens format
|
|
4
|
+
*
|
|
5
|
+
* @module lib/generators/figma
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { detectThemeVersion } from '../theme.js';
|
|
9
|
+
import { processTheme, hslToHex } from '../theme-v2.js';
|
|
10
|
+
|
|
11
|
+
// Import hex converter from theme.js
|
|
12
|
+
import { hslToHex as themeHslToHex } from '../theme.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Convert HSL string to hex
|
|
16
|
+
* @param {string} hsl - HSL string (e.g., '220 14.3% 95.9%')
|
|
17
|
+
* @returns {string} Hex color
|
|
18
|
+
*/
|
|
19
|
+
function convertHslToHex(hsl) {
|
|
20
|
+
if (!hsl || typeof hsl !== 'string') return '#000000';
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
// Handle HSL with alpha
|
|
24
|
+
if (hsl.includes('/')) {
|
|
25
|
+
const [hslPart] = hsl.split('/');
|
|
26
|
+
return themeHslToHex(hslPart.trim());
|
|
27
|
+
}
|
|
28
|
+
return themeHslToHex(hsl);
|
|
29
|
+
} catch {
|
|
30
|
+
return '#000000';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Generate Figma design tokens
|
|
36
|
+
* @param {Object} theme - Theme object (v1 or v2)
|
|
37
|
+
* @param {Object} options - Generation options
|
|
38
|
+
* @param {string} options.format - 'figma' or 'tokens-studio' (default: 'figma')
|
|
39
|
+
* @param {boolean} options.includeHex - Include hex values (default: true)
|
|
40
|
+
* @param {boolean} options.includeMeta - Include metadata (default: true)
|
|
41
|
+
* @returns {string} JSON string of Figma tokens
|
|
42
|
+
*/
|
|
43
|
+
export function generateFigmaTokens(theme, options = {}) {
|
|
44
|
+
const {
|
|
45
|
+
format = 'figma',
|
|
46
|
+
includeHex = true,
|
|
47
|
+
includeMeta = true
|
|
48
|
+
} = options;
|
|
49
|
+
|
|
50
|
+
const version = detectThemeVersion(theme);
|
|
51
|
+
const result = processTheme(theme);
|
|
52
|
+
const { light: lightVars, dark: darkVars } = result.variables;
|
|
53
|
+
|
|
54
|
+
const tokens = {
|
|
55
|
+
$themes: [],
|
|
56
|
+
$metadata: includeMeta ? {
|
|
57
|
+
tokenSetOrder: ['global', 'light', 'dark'],
|
|
58
|
+
generator: 'OMGKIT Design System',
|
|
59
|
+
themeId: theme.id,
|
|
60
|
+
themeName: theme.name,
|
|
61
|
+
version: version
|
|
62
|
+
} : undefined
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Global tokens
|
|
66
|
+
tokens.global = {
|
|
67
|
+
typography: buildTypographyTokens(theme),
|
|
68
|
+
spacing: buildSpacingTokens(theme),
|
|
69
|
+
borderRadius: buildRadiusTokens(theme)
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Light mode tokens
|
|
73
|
+
tokens.light = {
|
|
74
|
+
colors: buildColorTokens(lightVars, includeHex)
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// Dark mode tokens
|
|
78
|
+
tokens.dark = {
|
|
79
|
+
colors: buildColorTokens(darkVars, includeHex)
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// Add effects if present
|
|
83
|
+
if (theme.effects) {
|
|
84
|
+
tokens.global.effects = buildEffectTokens(theme.effects);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Theme sets for Figma
|
|
88
|
+
tokens.$themes = [
|
|
89
|
+
{
|
|
90
|
+
id: `${theme.id}-light`,
|
|
91
|
+
name: `${theme.name} Light`,
|
|
92
|
+
selectedTokenSets: { global: 'enabled', light: 'enabled' }
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: `${theme.id}-dark`,
|
|
96
|
+
name: `${theme.name} Dark`,
|
|
97
|
+
selectedTokenSets: { global: 'enabled', dark: 'enabled' }
|
|
98
|
+
}
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
// Remove undefined values
|
|
102
|
+
if (!includeMeta) {
|
|
103
|
+
delete tokens.$metadata;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return JSON.stringify(tokens, null, 2);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Build color tokens from variables
|
|
111
|
+
* @param {Object} vars - Color variables
|
|
112
|
+
* @param {boolean} includeHex - Include hex conversion
|
|
113
|
+
* @returns {Object} Color tokens
|
|
114
|
+
*/
|
|
115
|
+
function buildColorTokens(vars, includeHex) {
|
|
116
|
+
const tokens = {};
|
|
117
|
+
|
|
118
|
+
for (const [name, value] of Object.entries(vars)) {
|
|
119
|
+
const token = {
|
|
120
|
+
value: value,
|
|
121
|
+
type: 'color'
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
if (includeHex) {
|
|
125
|
+
token.$extensions = {
|
|
126
|
+
'figma': {
|
|
127
|
+
hexValue: convertHslToHex(value)
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Organize by category
|
|
133
|
+
const category = getColorCategory(name);
|
|
134
|
+
if (!tokens[category]) {
|
|
135
|
+
tokens[category] = {};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Clean name for token path
|
|
139
|
+
const cleanName = name.replace(category + '-', '').replace('-', '.');
|
|
140
|
+
|
|
141
|
+
if (cleanName === category || cleanName === '') {
|
|
142
|
+
tokens[category].DEFAULT = token;
|
|
143
|
+
} else {
|
|
144
|
+
tokens[category][cleanName] = token;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return tokens;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Get color category from token name
|
|
153
|
+
* @param {string} name - Token name
|
|
154
|
+
* @returns {string} Category
|
|
155
|
+
*/
|
|
156
|
+
function getColorCategory(name) {
|
|
157
|
+
const categories = [
|
|
158
|
+
'background', 'foreground', 'primary', 'secondary',
|
|
159
|
+
'muted', 'accent', 'destructive', 'border', 'input',
|
|
160
|
+
'ring', 'card', 'popover', 'sidebar', 'chart',
|
|
161
|
+
'success', 'warning', 'info', 'surface', 'panel', 'overlay'
|
|
162
|
+
];
|
|
163
|
+
|
|
164
|
+
for (const cat of categories) {
|
|
165
|
+
if (name.startsWith(cat)) return cat;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Color scales (e.g., teal-1, teal-9)
|
|
169
|
+
const scaleMatch = name.match(/^([a-z]+)-\d+$/);
|
|
170
|
+
if (scaleMatch) {
|
|
171
|
+
return scaleMatch[1];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return 'other';
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Build typography tokens
|
|
179
|
+
* @param {Object} theme - Theme object
|
|
180
|
+
* @returns {Object} Typography tokens
|
|
181
|
+
*/
|
|
182
|
+
function buildTypographyTokens(theme) {
|
|
183
|
+
const fontSans = theme.typography?.fontFamily?.sans ||
|
|
184
|
+
theme.fontFamily?.sans ||
|
|
185
|
+
'Inter, system-ui, sans-serif';
|
|
186
|
+
const fontMono = theme.typography?.fontFamily?.mono ||
|
|
187
|
+
theme.fontFamily?.mono ||
|
|
188
|
+
'JetBrains Mono, monospace';
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
fontFamily: {
|
|
192
|
+
sans: {
|
|
193
|
+
value: fontSans,
|
|
194
|
+
type: 'fontFamilies'
|
|
195
|
+
},
|
|
196
|
+
mono: {
|
|
197
|
+
value: fontMono,
|
|
198
|
+
type: 'fontFamilies'
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
fontSize: {
|
|
202
|
+
xs: { value: '0.75rem', type: 'fontSizes' },
|
|
203
|
+
sm: { value: '0.875rem', type: 'fontSizes' },
|
|
204
|
+
base: { value: '1rem', type: 'fontSizes' },
|
|
205
|
+
lg: { value: '1.125rem', type: 'fontSizes' },
|
|
206
|
+
xl: { value: '1.25rem', type: 'fontSizes' },
|
|
207
|
+
'2xl': { value: '1.5rem', type: 'fontSizes' },
|
|
208
|
+
'3xl': { value: '1.875rem', type: 'fontSizes' },
|
|
209
|
+
'4xl': { value: '2.25rem', type: 'fontSizes' }
|
|
210
|
+
},
|
|
211
|
+
fontWeight: {
|
|
212
|
+
normal: { value: '400', type: 'fontWeights' },
|
|
213
|
+
medium: { value: '500', type: 'fontWeights' },
|
|
214
|
+
semibold: { value: '600', type: 'fontWeights' },
|
|
215
|
+
bold: { value: '700', type: 'fontWeights' }
|
|
216
|
+
},
|
|
217
|
+
lineHeight: {
|
|
218
|
+
none: { value: '1', type: 'lineHeights' },
|
|
219
|
+
tight: { value: '1.25', type: 'lineHeights' },
|
|
220
|
+
snug: { value: '1.375', type: 'lineHeights' },
|
|
221
|
+
normal: { value: '1.5', type: 'lineHeights' },
|
|
222
|
+
relaxed: { value: '1.625', type: 'lineHeights' },
|
|
223
|
+
loose: { value: '2', type: 'lineHeights' }
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Build spacing tokens
|
|
230
|
+
* @param {Object} theme - Theme object
|
|
231
|
+
* @returns {Object} Spacing tokens
|
|
232
|
+
*/
|
|
233
|
+
function buildSpacingTokens(theme) {
|
|
234
|
+
return {
|
|
235
|
+
'0': { value: '0', type: 'spacing' },
|
|
236
|
+
'1': { value: '0.25rem', type: 'spacing' },
|
|
237
|
+
'2': { value: '0.5rem', type: 'spacing' },
|
|
238
|
+
'3': { value: '0.75rem', type: 'spacing' },
|
|
239
|
+
'4': { value: '1rem', type: 'spacing' },
|
|
240
|
+
'5': { value: '1.25rem', type: 'spacing' },
|
|
241
|
+
'6': { value: '1.5rem', type: 'spacing' },
|
|
242
|
+
'8': { value: '2rem', type: 'spacing' },
|
|
243
|
+
'10': { value: '2.5rem', type: 'spacing' },
|
|
244
|
+
'12': { value: '3rem', type: 'spacing' },
|
|
245
|
+
'16': { value: '4rem', type: 'spacing' },
|
|
246
|
+
'20': { value: '5rem', type: 'spacing' },
|
|
247
|
+
'24': { value: '6rem', type: 'spacing' }
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Build border radius tokens
|
|
253
|
+
* @param {Object} theme - Theme object
|
|
254
|
+
* @returns {Object} Radius tokens
|
|
255
|
+
*/
|
|
256
|
+
function buildRadiusTokens(theme) {
|
|
257
|
+
const radius = theme.spacing?.radius || theme.radius || '0.5rem';
|
|
258
|
+
|
|
259
|
+
return {
|
|
260
|
+
none: { value: '0', type: 'borderRadius' },
|
|
261
|
+
sm: { value: `calc(${radius} - 4px)`, type: 'borderRadius' },
|
|
262
|
+
md: { value: `calc(${radius} - 2px)`, type: 'borderRadius' },
|
|
263
|
+
DEFAULT: { value: radius, type: 'borderRadius' },
|
|
264
|
+
lg: { value: radius, type: 'borderRadius' },
|
|
265
|
+
xl: { value: `calc(${radius} + 4px)`, type: 'borderRadius' },
|
|
266
|
+
'2xl': { value: `calc(${radius} + 8px)`, type: 'borderRadius' },
|
|
267
|
+
full: { value: '9999px', type: 'borderRadius' }
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Build effect tokens
|
|
273
|
+
* @param {Object} effects - Theme effects
|
|
274
|
+
* @returns {Object} Effect tokens
|
|
275
|
+
*/
|
|
276
|
+
function buildEffectTokens(effects) {
|
|
277
|
+
const tokens = {};
|
|
278
|
+
|
|
279
|
+
if (effects.glassMorphism) {
|
|
280
|
+
tokens.glass = {
|
|
281
|
+
blur: {
|
|
282
|
+
value: effects.glassMorphism.backdropBlur || '12px',
|
|
283
|
+
type: 'dimension'
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (effects.glow) {
|
|
289
|
+
tokens.glow = {
|
|
290
|
+
DEFAULT: {
|
|
291
|
+
value: effects.glow.default || '0 0 20px',
|
|
292
|
+
type: 'boxShadow'
|
|
293
|
+
},
|
|
294
|
+
lg: {
|
|
295
|
+
value: effects.glow.lg || '0 0 40px',
|
|
296
|
+
type: 'boxShadow'
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return tokens;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Generate Tokens Studio format (alternative Figma plugin)
|
|
306
|
+
* @param {Object} theme - Theme object
|
|
307
|
+
* @returns {string} JSON string
|
|
308
|
+
*/
|
|
309
|
+
export function generateTokensStudio(theme) {
|
|
310
|
+
return generateFigmaTokens(theme, { format: 'tokens-studio' });
|
|
311
|
+
}
|