@webmate-studio/builder 0.2.89 → 0.2.91
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/package.json +1 -1
- package/src/design-tokens.js +5 -8
- package/src/tailwind-generator.js +4 -39
package/package.json
CHANGED
package/src/design-tokens.js
CHANGED
|
@@ -7,7 +7,7 @@ function generateSemanticColorUtilities(tokens) {
|
|
|
7
7
|
if (!tokens.colors) return '';
|
|
8
8
|
|
|
9
9
|
let utilities = '\n/* Color Utilities */';
|
|
10
|
-
utilities += '\n@layer
|
|
10
|
+
utilities += '\n@layer components {';
|
|
11
11
|
|
|
12
12
|
// Map of all colors: token name -> utility class base name
|
|
13
13
|
const colorMap = {
|
|
@@ -1008,13 +1008,7 @@ export function generateTailwindConfig(tokens) {
|
|
|
1008
1008
|
* Generate CSS Variables from Design Tokens
|
|
1009
1009
|
*/
|
|
1010
1010
|
export function generateCSSFromTokens(tokens) {
|
|
1011
|
-
const lines = [];
|
|
1012
|
-
|
|
1013
|
-
// Define layer order FIRST (before any other CSS)
|
|
1014
|
-
lines.push('/* CSS Layer Order Declaration */');
|
|
1015
|
-
lines.push('@layer base, components, utilities;');
|
|
1016
|
-
lines.push('');
|
|
1017
|
-
lines.push(':root {');
|
|
1011
|
+
const lines = [':root {'];
|
|
1018
1012
|
|
|
1019
1013
|
// Colors
|
|
1020
1014
|
for (const [key, value] of Object.entries(tokens.colors || {})) {
|
|
@@ -1319,6 +1313,7 @@ export function generateCSSFromTokens(tokens) {
|
|
|
1319
1313
|
if (tokens.buttons) {
|
|
1320
1314
|
lines.push('');
|
|
1321
1315
|
lines.push('/* Button Utilities */');
|
|
1316
|
+
lines.push('@layer components {');
|
|
1322
1317
|
|
|
1323
1318
|
// Helper to convert hex to rgba with opacity
|
|
1324
1319
|
const hexToRgba = (hex, alpha) => {
|
|
@@ -1477,6 +1472,8 @@ export function generateCSSFromTokens(tokens) {
|
|
|
1477
1472
|
|
|
1478
1473
|
lines.push('}');
|
|
1479
1474
|
}
|
|
1475
|
+
|
|
1476
|
+
lines.push('}'); // Close @layer components
|
|
1480
1477
|
}
|
|
1481
1478
|
|
|
1482
1479
|
// Add semantic color utilities
|
|
@@ -68,33 +68,6 @@ function stripNonUtilityLayers(css) {
|
|
|
68
68
|
return css.trim();
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
/**
|
|
72
|
-
* Wraps utility classes in @layer components, preserving base/theme/properties layers
|
|
73
|
-
* This allows design token utilities (@layer utilities) to override component utilities
|
|
74
|
-
* @param {string} css - Full Tailwind CSS
|
|
75
|
-
* @returns {string} CSS with utilities wrapped in @layer components
|
|
76
|
-
*/
|
|
77
|
-
function wrapUtilitiesInComponentsLayer(css) {
|
|
78
|
-
// Extract @layer utilities content
|
|
79
|
-
const utilitiesMatch = css.match(/@layer\s+utilities\s*\{([\s\S]*?)\n\}/);
|
|
80
|
-
|
|
81
|
-
if (!utilitiesMatch) {
|
|
82
|
-
console.log('[Tailwind Generator] No @layer utilities found, returning CSS as-is');
|
|
83
|
-
return css;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const utilitiesContent = utilitiesMatch[1].trim();
|
|
87
|
-
|
|
88
|
-
// Replace @layer utilities with @layer components
|
|
89
|
-
const result = css.replace(
|
|
90
|
-
/@layer\s+utilities\s*\{[\s\S]*?\n\}/,
|
|
91
|
-
`@layer components {\n${utilitiesContent}\n}`
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
console.log('[Tailwind Generator] Wrapped utilities in @layer components');
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
71
|
/**
|
|
99
72
|
* Extract Tailwind classes from HTML content
|
|
100
73
|
* Supports: class="...", class='...', class={...}, and Svelte's class:xxx={...}
|
|
@@ -428,24 +401,16 @@ ${themeCSS}
|
|
|
428
401
|
let result = await compiler.build(classArray);
|
|
429
402
|
|
|
430
403
|
console.log(`[Tailwind Generator] includeBaseLayers = ${includeBaseLayers}`);
|
|
431
|
-
console.log(`[Tailwind Generator] Generated CSS length: ${result.length}`);
|
|
404
|
+
console.log(`[Tailwind Generator] Generated CSS length BEFORE stripping: ${result.length}`);
|
|
432
405
|
console.log(`[Tailwind Generator] CSS contains @layer base: ${result.includes('@layer base')}`);
|
|
433
|
-
console.log(`[Tailwind Generator] CSS contains @layer
|
|
406
|
+
console.log(`[Tailwind Generator] CSS contains @layer theme: ${result.includes('@layer theme')}`);
|
|
434
407
|
|
|
435
|
-
// If includeBaseLayers is false, strip out base/theme/properties layers
|
|
408
|
+
// If includeBaseLayers is false, strip out base/theme/properties layers
|
|
436
409
|
if (!includeBaseLayers) {
|
|
437
410
|
console.log('[Tailwind Generator] Stripping non-utility layers...');
|
|
438
411
|
result = stripNonUtilityLayers(result);
|
|
439
412
|
console.log(`[Tailwind Generator] Generated CSS length AFTER stripping: ${result.length}`);
|
|
440
|
-
|
|
441
|
-
// Wrap stripped utilities in @layer components
|
|
442
|
-
result = `@layer components {\n${result}\n}`;
|
|
443
|
-
console.log('[Tailwind Generator] Wrapped stripped utilities in @layer components');
|
|
444
|
-
} else {
|
|
445
|
-
// Keep base/theme/properties layers, but wrap utilities in @layer components
|
|
446
|
-
// This preserves CSS custom properties while allowing utilities override
|
|
447
|
-
console.log('[Tailwind Generator] Preserving base/theme/properties, wrapping utilities in @layer components...');
|
|
448
|
-
result = wrapUtilitiesInComponentsLayer(result);
|
|
413
|
+
console.log(`[Tailwind Generator] CSS contains @layer base: ${result.includes('@layer base')}`);
|
|
449
414
|
}
|
|
450
415
|
|
|
451
416
|
return result;
|