@webmate-studio/builder 0.2.117 → 0.2.119
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 +63 -98
package/package.json
CHANGED
package/src/design-tokens.js
CHANGED
|
@@ -59,7 +59,12 @@ function generateSemanticColorUtilities(tokens) {
|
|
|
59
59
|
// Text-on-background colors
|
|
60
60
|
'textOnPrimary': 'text-on-primary',
|
|
61
61
|
'textOnSecondary': 'text-on-secondary',
|
|
62
|
-
'textOnAccent': 'text-on-accent'
|
|
62
|
+
'textOnAccent': 'text-on-accent',
|
|
63
|
+
|
|
64
|
+
// Border-on-background colors (borders on colored backgrounds)
|
|
65
|
+
'borderOnPrimary': 'border-on-primary',
|
|
66
|
+
'borderOnSecondary': 'border-on-secondary',
|
|
67
|
+
'borderOnAccent': 'border-on-accent'
|
|
63
68
|
};
|
|
64
69
|
|
|
65
70
|
// Collect unique class names (deduplicate)
|
|
@@ -74,108 +79,58 @@ function generateSemanticColorUtilities(tokens) {
|
|
|
74
79
|
// If className already has prefix (bg-, text-, border-), generate only that variant
|
|
75
80
|
// Otherwise generate all three variants
|
|
76
81
|
|
|
82
|
+
/** Helper: generate base + hover + focus for a single class */
|
|
83
|
+
function addUtility(cls, prop, varRef) {
|
|
84
|
+
if (processedClasses.has(cls)) return;
|
|
85
|
+
processedClasses.add(cls);
|
|
86
|
+
utilities += `\n.${cls} {\n ${prop}: var(${varRef});\n}`;
|
|
87
|
+
utilities += `\n.hover\\:${cls}:hover {\n ${prop}: var(${varRef});\n}`;
|
|
88
|
+
utilities += `\n.focus\\:${cls}:focus {\n ${prop}: var(${varRef});\n}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
77
91
|
if (className.startsWith('bg-')) {
|
|
78
|
-
|
|
79
|
-
if (!processedClasses.has(className)) {
|
|
80
|
-
processedClasses.add(className);
|
|
81
|
-
// Base class
|
|
82
|
-
utilities += `\n.${className} {`;
|
|
83
|
-
utilities += `\n background-color: var(${colorVar});`;
|
|
84
|
-
utilities += `\n}`;
|
|
85
|
-
// Hover variant
|
|
86
|
-
utilities += `\n.hover\\:${className}:hover {`;
|
|
87
|
-
utilities += `\n background-color: var(${colorVar});`;
|
|
88
|
-
utilities += `\n}`;
|
|
89
|
-
// Focus variant
|
|
90
|
-
utilities += `\n.focus\\:${className}:focus {`;
|
|
91
|
-
utilities += `\n background-color: var(${colorVar});`;
|
|
92
|
-
utilities += `\n}`;
|
|
93
|
-
}
|
|
92
|
+
addUtility(className, 'background-color', colorVar);
|
|
94
93
|
} else if (className.startsWith('text-')) {
|
|
95
|
-
|
|
96
|
-
if (!processedClasses.has(className)) {
|
|
97
|
-
processedClasses.add(className);
|
|
98
|
-
// Base class
|
|
99
|
-
utilities += `\n.${className} {`;
|
|
100
|
-
utilities += `\n color: var(${colorVar});`;
|
|
101
|
-
utilities += `\n}`;
|
|
102
|
-
// Hover variant
|
|
103
|
-
utilities += `\n.hover\\:${className}:hover {`;
|
|
104
|
-
utilities += `\n color: var(${colorVar});`;
|
|
105
|
-
utilities += `\n}`;
|
|
106
|
-
// Focus variant
|
|
107
|
-
utilities += `\n.focus\\:${className}:focus {`;
|
|
108
|
-
utilities += `\n color: var(${colorVar});`;
|
|
109
|
-
utilities += `\n}`;
|
|
110
|
-
}
|
|
94
|
+
addUtility(className, 'color', colorVar);
|
|
111
95
|
} else if (className.startsWith('border-')) {
|
|
112
|
-
|
|
113
|
-
if (!processedClasses.has(className)) {
|
|
114
|
-
processedClasses.add(className);
|
|
115
|
-
// Base class
|
|
116
|
-
utilities += `\n.${className} {`;
|
|
117
|
-
utilities += `\n border-color: var(${colorVar});`;
|
|
118
|
-
utilities += `\n}`;
|
|
119
|
-
// Hover variant
|
|
120
|
-
utilities += `\n.hover\\:${className}:hover {`;
|
|
121
|
-
utilities += `\n border-color: var(${colorVar});`;
|
|
122
|
-
utilities += `\n}`;
|
|
123
|
-
// Focus variant
|
|
124
|
-
utilities += `\n.focus\\:${className}:focus {`;
|
|
125
|
-
utilities += `\n border-color: var(${colorVar});`;
|
|
126
|
-
utilities += `\n}`;
|
|
127
|
-
}
|
|
96
|
+
addUtility(className, 'border-color', colorVar);
|
|
128
97
|
} else {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (!processedClasses.has(textClass)) {
|
|
135
|
-
processedClasses.add(textClass);
|
|
136
|
-
// Base class
|
|
137
|
-
utilities += `\n.${textClass} {`;
|
|
138
|
-
utilities += `\n color: var(${colorVar});`;
|
|
139
|
-
utilities += `\n}`;
|
|
140
|
-
// Hover variant
|
|
141
|
-
utilities += `\n.hover\\:${textClass}:hover {`;
|
|
142
|
-
utilities += `\n color: var(${colorVar});`;
|
|
143
|
-
utilities += `\n}`;
|
|
144
|
-
// Focus variant
|
|
145
|
-
utilities += `\n.focus\\:${textClass}:focus {`;
|
|
146
|
-
utilities += `\n color: var(${colorVar});`;
|
|
147
|
-
utilities += `\n}`;
|
|
148
|
-
}
|
|
98
|
+
addUtility(`text-${className}`, 'color', colorVar);
|
|
99
|
+
addUtility(`bg-${className}`, 'background-color', colorVar);
|
|
100
|
+
addUtility(`border-${className}`, 'border-color', colorVar);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
149
103
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// Base class
|
|
153
|
-
utilities += `\n.${bgClass} {`;
|
|
154
|
-
utilities += `\n background-color: var(${colorVar});`;
|
|
155
|
-
utilities += `\n}`;
|
|
156
|
-
// Hover variant
|
|
157
|
-
utilities += `\n.hover\\:${bgClass}:hover {`;
|
|
158
|
-
utilities += `\n background-color: var(${colorVar});`;
|
|
159
|
-
utilities += `\n}`;
|
|
160
|
-
// Focus variant
|
|
161
|
-
utilities += `\n.focus\\:${bgClass}:focus {`;
|
|
162
|
-
utilities += `\n background-color: var(${colorVar});`;
|
|
163
|
-
utilities += `\n}`;
|
|
164
|
-
}
|
|
104
|
+
// Generate opacity variants for all color utilities using color-mix()
|
|
105
|
+
const opacitySteps = [10, 20, 30, 40, 50, 60, 70, 80, 90];
|
|
165
106
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
107
|
+
for (const [tokenKey, className] of Object.entries(colorMap)) {
|
|
108
|
+
if (!tokens.colors[tokenKey]) continue;
|
|
109
|
+
const colorVar = `--color-${tokenKey.replace(/([A-Z])/g, '-$1').toLowerCase()}`;
|
|
110
|
+
|
|
111
|
+
// Determine which CSS property(ies) to use
|
|
112
|
+
let entries;
|
|
113
|
+
if (className.startsWith('bg-')) {
|
|
114
|
+
entries = [[className, 'background-color']];
|
|
115
|
+
} else if (className.startsWith('text-')) {
|
|
116
|
+
entries = [[className, 'color']];
|
|
117
|
+
} else if (className.startsWith('border-')) {
|
|
118
|
+
entries = [[className, 'border-color']];
|
|
119
|
+
} else {
|
|
120
|
+
entries = [
|
|
121
|
+
[`text-${className}`, 'color'],
|
|
122
|
+
[`bg-${className}`, 'background-color'],
|
|
123
|
+
[`border-${className}`, 'border-color']
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
for (const [cls, prop] of entries) {
|
|
128
|
+
for (const step of opacitySteps) {
|
|
129
|
+
const opacityCls = `${cls}\\/${step}`;
|
|
130
|
+
if (processedClasses.has(opacityCls)) continue;
|
|
131
|
+
processedClasses.add(opacityCls);
|
|
132
|
+
utilities += `\n.${opacityCls} {`;
|
|
133
|
+
utilities += `\n ${prop}: color-mix(in srgb, var(${colorVar}) ${step}%, transparent);`;
|
|
179
134
|
utilities += `\n}`;
|
|
180
135
|
}
|
|
181
136
|
}
|
|
@@ -252,7 +207,12 @@ export const defaultDesignTokens = {
|
|
|
252
207
|
// Text-on-Background Colors (for text on colored backgrounds)
|
|
253
208
|
textOnPrimary: '#ffffff', // Text on bg-primary
|
|
254
209
|
textOnSecondary: '#ffffff', // Text on bg-secondary
|
|
255
|
-
textOnAccent: '#ffffff'
|
|
210
|
+
textOnAccent: '#ffffff', // Text on bg-accent
|
|
211
|
+
|
|
212
|
+
// Border-on-Background Colors (for borders on colored backgrounds)
|
|
213
|
+
borderOnPrimary: '#ffffff', // Border on bg-primary
|
|
214
|
+
borderOnSecondary: '#ffffff', // Border on bg-secondary
|
|
215
|
+
borderOnAccent: '#ffffff' // Border on bg-accent
|
|
256
216
|
},
|
|
257
217
|
|
|
258
218
|
typography: {
|
|
@@ -686,6 +646,11 @@ export function generateTailwindV4Theme(tokens) {
|
|
|
686
646
|
if (tokens.colors.textOnSecondary) lines.push(` --color-text-on-secondary: ${tokens.colors.textOnSecondary};`);
|
|
687
647
|
if (tokens.colors.textOnAccent) lines.push(` --color-text-on-accent: ${tokens.colors.textOnAccent};`);
|
|
688
648
|
|
|
649
|
+
// Border-on-background colors
|
|
650
|
+
if (tokens.colors.borderOnPrimary) lines.push(` --color-border-on-primary: ${tokens.colors.borderOnPrimary};`);
|
|
651
|
+
if (tokens.colors.borderOnSecondary) lines.push(` --color-border-on-secondary: ${tokens.colors.borderOnSecondary};`);
|
|
652
|
+
if (tokens.colors.borderOnAccent) lines.push(` --color-border-on-accent: ${tokens.colors.borderOnAccent};`);
|
|
653
|
+
|
|
689
654
|
// Basic colors
|
|
690
655
|
if (tokens.colors.white) lines.push(` --color-white: ${tokens.colors.white};`);
|
|
691
656
|
if (tokens.colors.black) lines.push(` --color-black: ${tokens.colors.black};`);
|