@webmate-studio/builder 0.2.101 → 0.2.103

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/design-tokens.js +131 -40
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webmate-studio/builder",
3
- "version": "0.2.101",
3
+ "version": "0.2.103",
4
4
  "type": "module",
5
5
  "description": "Webmate Studio Component Builder",
6
6
  "keywords": [
@@ -913,6 +913,7 @@ body {
913
913
  }
914
914
 
915
915
  // Generate responsive variants (sm:, md:, lg:, xl:, 2xl:) for Tailwind compatibility
916
+ // These allow switching to a different text style at a breakpoint: class="text-body lg:text-lead"
916
917
  const breakpointKeys = ['sm', 'md', 'lg', 'xl', '2xl'];
917
918
  const breakpointValues = {
918
919
  sm: '640px',
@@ -930,28 +931,54 @@ body {
930
931
  .toLowerCase()
931
932
  .replace(/^-/, '');
932
933
  const className = `text-${kebabName}`;
933
- const hasResponsive = (
934
- (style.fontSize && typeof style.fontSize === 'object' && style.fontSize[bp]) ||
935
- (style.lineHeight && typeof style.lineHeight === 'object' && style.lineHeight[bp]) ||
936
- (style.letterSpacing && typeof style.letterSpacing === 'object' && style.letterSpacing[bp])
937
- );
938
934
 
939
- if (hasResponsive) {
940
- // Generate Tailwind-compatible breakpoint class: md:text-body
941
- globalStyles += `\n@media (min-width: ${breakpointValues[bp]}) {`;
942
- globalStyles += `\n .${bp}\\:${className} {`;
943
- if (style.fontSize && typeof style.fontSize === 'object' && style.fontSize[bp]) {
944
- globalStyles += `\n font-size: ${style.fontSize[bp]};`;
945
- }
946
- if (style.lineHeight && typeof style.lineHeight === 'object' && style.lineHeight[bp]) {
947
- globalStyles += `\n line-height: ${style.lineHeight[bp]};`;
948
- }
949
- if (style.letterSpacing && typeof style.letterSpacing === 'object' && style.letterSpacing[bp]) {
950
- globalStyles += `\n letter-spacing: ${style.letterSpacing[bp]};`;
951
- }
952
- globalStyles += `\n }`;
953
- globalStyles += `\n}`;
935
+ // Generate Tailwind-compatible breakpoint class: md:text-body
936
+ // Apply ALL properties of the text style, not just responsive values
937
+ globalStyles += `\n@media (min-width: ${breakpointValues[bp]}) {`;
938
+ globalStyles += `\n .${bp}\\:${className} {`;
939
+
940
+ // Font family
941
+ if (style.fontFamily) {
942
+ globalStyles += `\n font-family: var(--text-${kebabName}-font-family);`;
943
+ }
944
+
945
+ // Font weight
946
+ if (style.fontWeight) {
947
+ globalStyles += `\n font-weight: var(--text-${kebabName}-font-weight);`;
948
+ }
949
+
950
+ // Font style
951
+ if (style.fontStyle) {
952
+ globalStyles += `\n font-style: var(--text-${kebabName}-font-style);`;
953
+ }
954
+
955
+ // Font size (use CSS variable which is responsive)
956
+ if (style.fontSize) {
957
+ globalStyles += `\n font-size: var(--text-${kebabName}-font-size);`;
958
+ }
959
+
960
+ // Line height (use CSS variable which is responsive)
961
+ if (style.lineHeight) {
962
+ globalStyles += `\n line-height: var(--text-${kebabName}-line-height);`;
963
+ }
964
+
965
+ // Letter spacing (use CSS variable which is responsive)
966
+ if (style.letterSpacing) {
967
+ globalStyles += `\n letter-spacing: var(--text-${kebabName}-letter-spacing);`;
968
+ }
969
+
970
+ // Text transform
971
+ if (style.textTransform) {
972
+ globalStyles += `\n text-transform: var(--text-${kebabName}-text-transform);`;
954
973
  }
974
+
975
+ // Text color
976
+ if (style.textColor) {
977
+ globalStyles += `\n color: var(--text-${kebabName}-color);`;
978
+ }
979
+
980
+ globalStyles += `\n }`;
981
+ globalStyles += `\n}`;
955
982
  }
956
983
  }
957
984
  }
@@ -1228,8 +1255,40 @@ export function generateCSSFromTokens(tokens) {
1228
1255
  lines.push(` color: var(${colorVar});`);
1229
1256
  }
1230
1257
  lines.push(` }`);
1258
+
1259
+ // Add intrinsic responsive values (if the style itself has responsive values)
1260
+ const intrinsicBreakpoints = ['sm', 'md', 'lg', 'xl', '2xl'];
1261
+ for (const bp of intrinsicBreakpoints) {
1262
+ const hasIntrinsicResponsive = (
1263
+ (style.fontSize && typeof style.fontSize === 'object' && style.fontSize[bp]) ||
1264
+ (style.lineHeight && typeof style.lineHeight === 'object' && style.lineHeight[bp]) ||
1265
+ (style.letterSpacing && typeof style.letterSpacing === 'object' && style.letterSpacing[bp])
1266
+ );
1267
+
1268
+ if (hasIntrinsicResponsive) {
1269
+ const bpValue = intrinsicBreakpoints.indexOf(bp) === 0 ? '640px' :
1270
+ intrinsicBreakpoints.indexOf(bp) === 1 ? '768px' :
1271
+ intrinsicBreakpoints.indexOf(bp) === 2 ? '1024px' :
1272
+ intrinsicBreakpoints.indexOf(bp) === 3 ? '1280px' : '1536px';
1273
+
1274
+ lines.push(` @media (min-width: ${bpValue}) {`);
1275
+ lines.push(` .${className} {`);
1276
+ if (style.fontSize && typeof style.fontSize === 'object' && style.fontSize[bp]) {
1277
+ lines.push(` font-size: ${style.fontSize[bp]};`);
1278
+ }
1279
+ if (style.lineHeight && typeof style.lineHeight === 'object' && style.lineHeight[bp]) {
1280
+ lines.push(` line-height: ${style.lineHeight[bp]};`);
1281
+ }
1282
+ if (style.letterSpacing && typeof style.letterSpacing === 'object' && style.letterSpacing[bp]) {
1283
+ lines.push(` letter-spacing: ${style.letterSpacing[bp]};`);
1284
+ }
1285
+ lines.push(` }`);
1286
+ lines.push(` }`);
1287
+ }
1288
+ }
1231
1289
  }
1232
1290
  // Generate responsive variants (md:, lg:, xl:, 2xl:) for Tailwind compatibility
1291
+ // These allow switching to a different text style at a breakpoint: class="text-body lg:text-lead"
1233
1292
  const breakpointKeys = ['sm', 'md', 'lg', 'xl', '2xl'];
1234
1293
  const breakpointValues = {
1235
1294
  sm: '640px',
@@ -1247,28 +1306,60 @@ export function generateCSSFromTokens(tokens) {
1247
1306
  .toLowerCase()
1248
1307
  .replace(/^-/, '');
1249
1308
  const className = `text-${kebabName}`;
1250
- const hasResponsive = (
1251
- (style.fontSize && typeof style.fontSize === 'object' && style.fontSize[bp]) ||
1252
- (style.lineHeight && typeof style.lineHeight === 'object' && style.lineHeight[bp]) ||
1253
- (style.letterSpacing && typeof style.letterSpacing === 'object' && style.letterSpacing[bp])
1254
- );
1255
1309
 
1256
- if (hasResponsive) {
1257
- // Generate Tailwind-compatible breakpoint class: md:text-body
1258
- lines.push(` .${bp}\\:${className} {`);
1259
- lines.push(` @media (min-width: ${breakpointValues[bp]}) {`);
1260
- if (style.fontSize && typeof style.fontSize === 'object' && style.fontSize[bp]) {
1261
- lines.push(` font-size: ${style.fontSize[bp]};`);
1262
- }
1263
- if (style.lineHeight && typeof style.lineHeight === 'object' && style.lineHeight[bp]) {
1264
- lines.push(` line-height: ${style.lineHeight[bp]};`);
1265
- }
1266
- if (style.letterSpacing && typeof style.letterSpacing === 'object' && style.letterSpacing[bp]) {
1267
- lines.push(` letter-spacing: ${style.letterSpacing[bp]};`);
1268
- }
1269
- lines.push(` }`);
1270
- lines.push(` }`);
1310
+ // Generate Tailwind-compatible breakpoint class: md:text-body
1311
+ // Apply ALL properties of the text style, not just responsive values
1312
+ lines.push(` .${bp}\\:${className} {`);
1313
+ lines.push(` @media (min-width: ${breakpointValues[bp]}) {`);
1314
+
1315
+ // Font family
1316
+ if (style.fontFamily) {
1317
+ const fontVar = `--font-${style.fontFamily}`;
1318
+ lines.push(` font-family: var(${fontVar});`);
1319
+ }
1320
+
1321
+ // Font weight
1322
+ if (style.fontWeight) {
1323
+ lines.push(` font-weight: ${style.fontWeight};`);
1324
+ }
1325
+
1326
+ // Font size (use breakpoint value if available, otherwise base)
1327
+ if (style.fontSize) {
1328
+ const fontSize = typeof style.fontSize === 'object'
1329
+ ? (style.fontSize[bp] || style.fontSize.base)
1330
+ : style.fontSize;
1331
+ lines.push(` font-size: ${fontSize};`);
1271
1332
  }
1333
+
1334
+ // Line height (use breakpoint value if available, otherwise base)
1335
+ if (style.lineHeight) {
1336
+ const lineHeight = typeof style.lineHeight === 'object'
1337
+ ? (style.lineHeight[bp] || style.lineHeight.base)
1338
+ : style.lineHeight;
1339
+ lines.push(` line-height: ${lineHeight};`);
1340
+ }
1341
+
1342
+ // Letter spacing (use breakpoint value if available, otherwise base)
1343
+ if (style.letterSpacing) {
1344
+ const letterSpacing = typeof style.letterSpacing === 'object'
1345
+ ? (style.letterSpacing[bp] || style.letterSpacing.base)
1346
+ : style.letterSpacing;
1347
+ lines.push(` letter-spacing: ${letterSpacing};`);
1348
+ }
1349
+
1350
+ // Text transform
1351
+ if (style.textTransform) {
1352
+ lines.push(` text-transform: ${style.textTransform};`);
1353
+ }
1354
+
1355
+ // Text color
1356
+ if (style.textColor) {
1357
+ const colorVar = `--color-${style.textColor.replace(/([A-Z])/g, '-$1').toLowerCase()}`;
1358
+ lines.push(` color: var(${colorVar});`);
1359
+ }
1360
+
1361
+ lines.push(` }`);
1362
+ lines.push(` }`);
1272
1363
  }
1273
1364
  }
1274
1365