@webmate-studio/builder 0.2.82 → 0.2.83
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 +23 -15
package/package.json
CHANGED
package/src/design-tokens.js
CHANGED
|
@@ -7,6 +7,7 @@ function generateSemanticColorUtilities(tokens) {
|
|
|
7
7
|
if (!tokens.colors) return '';
|
|
8
8
|
|
|
9
9
|
let utilities = '\n/* Color Utilities */';
|
|
10
|
+
utilities += '\n@layer components {';
|
|
10
11
|
|
|
11
12
|
// Map of all colors: token name -> utility class base name
|
|
12
13
|
const colorMap = {
|
|
@@ -120,6 +121,8 @@ function generateSemanticColorUtilities(tokens) {
|
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
|
|
124
|
+
utilities += '\n}'; // Close @layer components
|
|
125
|
+
|
|
123
126
|
return utilities;
|
|
124
127
|
}
|
|
125
128
|
|
|
@@ -1091,9 +1094,11 @@ export function generateCSSFromTokens(tokens) {
|
|
|
1091
1094
|
lines.push('}');
|
|
1092
1095
|
|
|
1093
1096
|
// Generate utility classes for text styles
|
|
1097
|
+
// Wrap in @layer components so Tailwind utilities (@layer utilities) can override them
|
|
1094
1098
|
if (tokens.textStyles) {
|
|
1095
1099
|
lines.push('');
|
|
1096
1100
|
lines.push('/* Text Style Utilities */');
|
|
1101
|
+
lines.push('@layer components {');
|
|
1097
1102
|
for (const [styleName, style] of Object.entries(tokens.textStyles)) {
|
|
1098
1103
|
const kebabName = styleName
|
|
1099
1104
|
.replace(/([A-Z])/g, '-$1')
|
|
@@ -1102,35 +1107,36 @@ export function generateCSSFromTokens(tokens) {
|
|
|
1102
1107
|
.replace(/^-/, '');
|
|
1103
1108
|
const className = `text-${kebabName}`;
|
|
1104
1109
|
|
|
1105
|
-
lines.push(
|
|
1110
|
+
lines.push(` .${className} {`);
|
|
1106
1111
|
if (style.fontFamily) {
|
|
1107
1112
|
const fontVar = `--font-${style.fontFamily}`;
|
|
1108
|
-
lines.push(`
|
|
1113
|
+
lines.push(` font-family: var(${fontVar});`);
|
|
1109
1114
|
}
|
|
1110
1115
|
if (style.fontWeight) {
|
|
1111
|
-
lines.push(`
|
|
1116
|
+
lines.push(` font-weight: ${style.fontWeight};`);
|
|
1112
1117
|
}
|
|
1113
1118
|
if (style.fontSize) {
|
|
1114
1119
|
const fontSize = typeof style.fontSize === 'object' ? style.fontSize.base : style.fontSize;
|
|
1115
|
-
lines.push(`
|
|
1120
|
+
lines.push(` font-size: ${fontSize};`);
|
|
1116
1121
|
}
|
|
1117
1122
|
if (style.lineHeight) {
|
|
1118
1123
|
const lineHeight = typeof style.lineHeight === 'object' ? style.lineHeight.base : style.lineHeight;
|
|
1119
|
-
lines.push(`
|
|
1124
|
+
lines.push(` line-height: ${lineHeight};`);
|
|
1120
1125
|
}
|
|
1121
1126
|
if (style.letterSpacing) {
|
|
1122
1127
|
const letterSpacing = typeof style.letterSpacing === 'object' ? style.letterSpacing.base : style.letterSpacing;
|
|
1123
|
-
lines.push(`
|
|
1128
|
+
lines.push(` letter-spacing: ${letterSpacing};`);
|
|
1124
1129
|
}
|
|
1125
1130
|
if (style.textTransform) {
|
|
1126
|
-
lines.push(`
|
|
1131
|
+
lines.push(` text-transform: ${style.textTransform};`);
|
|
1127
1132
|
}
|
|
1128
1133
|
if (style.textColor) {
|
|
1129
1134
|
const colorVar = `--color-${style.textColor.replace(/([A-Z])/g, '-$1').toLowerCase()}`;
|
|
1130
|
-
lines.push(`
|
|
1135
|
+
lines.push(` color: var(${colorVar});`);
|
|
1131
1136
|
}
|
|
1132
|
-
lines.push(
|
|
1137
|
+
lines.push(` }`);
|
|
1133
1138
|
}
|
|
1139
|
+
lines.push('}'); // Close @layer components
|
|
1134
1140
|
|
|
1135
1141
|
// Add responsive media queries for textStyles
|
|
1136
1142
|
const breakpointKeys = ['md', 'lg', 'xl', '2xl'];
|
|
@@ -1158,24 +1164,26 @@ export function generateCSSFromTokens(tokens) {
|
|
|
1158
1164
|
);
|
|
1159
1165
|
|
|
1160
1166
|
if (hasResponsive) {
|
|
1161
|
-
mediaQueryLines.push(`
|
|
1167
|
+
mediaQueryLines.push(` .${className} {`);
|
|
1162
1168
|
if (style.fontSize && typeof style.fontSize === 'object' && style.fontSize[bp]) {
|
|
1163
|
-
mediaQueryLines.push(`
|
|
1169
|
+
mediaQueryLines.push(` font-size: ${style.fontSize[bp]};`);
|
|
1164
1170
|
}
|
|
1165
1171
|
if (style.lineHeight && typeof style.lineHeight === 'object' && style.lineHeight[bp]) {
|
|
1166
|
-
mediaQueryLines.push(`
|
|
1172
|
+
mediaQueryLines.push(` line-height: ${style.lineHeight[bp]};`);
|
|
1167
1173
|
}
|
|
1168
1174
|
if (style.letterSpacing && typeof style.letterSpacing === 'object' && style.letterSpacing[bp]) {
|
|
1169
|
-
mediaQueryLines.push(`
|
|
1175
|
+
mediaQueryLines.push(` letter-spacing: ${style.letterSpacing[bp]};`);
|
|
1170
1176
|
}
|
|
1171
|
-
mediaQueryLines.push(`
|
|
1177
|
+
mediaQueryLines.push(` }`);
|
|
1172
1178
|
}
|
|
1173
1179
|
}
|
|
1174
1180
|
|
|
1175
1181
|
if (mediaQueryLines.length > 0) {
|
|
1176
1182
|
lines.push('');
|
|
1177
|
-
lines.push(`@
|
|
1183
|
+
lines.push(`@layer components {`);
|
|
1184
|
+
lines.push(` @media (min-width: ${breakpointValues[bp]}) {`);
|
|
1178
1185
|
lines.push(...mediaQueryLines);
|
|
1186
|
+
lines.push(` }`);
|
|
1179
1187
|
lines.push('}');
|
|
1180
1188
|
}
|
|
1181
1189
|
}
|