@webmate-studio/builder 0.2.102 → 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 +100 -40
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webmate-studio/builder",
3
- "version": "0.2.102",
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);`;
954
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);`;
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
  }
@@ -1261,6 +1288,7 @@ export function generateCSSFromTokens(tokens) {
1261
1288
  }
1262
1289
  }
1263
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"
1264
1292
  const breakpointKeys = ['sm', 'md', 'lg', 'xl', '2xl'];
1265
1293
  const breakpointValues = {
1266
1294
  sm: '640px',
@@ -1278,28 +1306,60 @@ export function generateCSSFromTokens(tokens) {
1278
1306
  .toLowerCase()
1279
1307
  .replace(/^-/, '');
1280
1308
  const className = `text-${kebabName}`;
1281
- const hasResponsive = (
1282
- (style.fontSize && typeof style.fontSize === 'object' && style.fontSize[bp]) ||
1283
- (style.lineHeight && typeof style.lineHeight === 'object' && style.lineHeight[bp]) ||
1284
- (style.letterSpacing && typeof style.letterSpacing === 'object' && style.letterSpacing[bp])
1285
- );
1286
1309
 
1287
- if (hasResponsive) {
1288
- // Generate Tailwind-compatible breakpoint class: md:text-body
1289
- lines.push(` .${bp}\\:${className} {`);
1290
- lines.push(` @media (min-width: ${breakpointValues[bp]}) {`);
1291
- if (style.fontSize && typeof style.fontSize === 'object' && style.fontSize[bp]) {
1292
- lines.push(` font-size: ${style.fontSize[bp]};`);
1293
- }
1294
- if (style.lineHeight && typeof style.lineHeight === 'object' && style.lineHeight[bp]) {
1295
- lines.push(` line-height: ${style.lineHeight[bp]};`);
1296
- }
1297
- if (style.letterSpacing && typeof style.letterSpacing === 'object' && style.letterSpacing[bp]) {
1298
- lines.push(` letter-spacing: ${style.letterSpacing[bp]};`);
1299
- }
1300
- lines.push(` }`);
1301
- 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};`);
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};`);
1302
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(` }`);
1303
1363
  }
1304
1364
  }
1305
1365