@webmate-studio/builder 0.2.102 → 0.2.104

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 +108 -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.104",
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);`;
973
+ }
974
+
975
+ // Text color
976
+ if (style.textColor) {
977
+ globalStyles += `\n color: var(--text-${kebabName}-color);`;
954
978
  }
979
+
980
+ globalStyles += `\n }`;
981
+ globalStyles += `\n}`;
955
982
  }
956
983
  }
957
984
  }
@@ -1208,6 +1235,9 @@ export function generateCSSFromTokens(tokens) {
1208
1235
  if (style.fontWeight) {
1209
1236
  lines.push(` font-weight: ${style.fontWeight};`);
1210
1237
  }
1238
+ if (style.fontStyle) {
1239
+ lines.push(` font-style: ${style.fontStyle};`);
1240
+ }
1211
1241
  if (style.fontSize) {
1212
1242
  const fontSize = typeof style.fontSize === 'object' ? style.fontSize.base : style.fontSize;
1213
1243
  lines.push(` font-size: ${fontSize};`);
@@ -1261,6 +1291,7 @@ export function generateCSSFromTokens(tokens) {
1261
1291
  }
1262
1292
  }
1263
1293
  // Generate responsive variants (md:, lg:, xl:, 2xl:) for Tailwind compatibility
1294
+ // These allow switching to a different text style at a breakpoint: class="text-body lg:text-lead"
1264
1295
  const breakpointKeys = ['sm', 'md', 'lg', 'xl', '2xl'];
1265
1296
  const breakpointValues = {
1266
1297
  sm: '640px',
@@ -1278,28 +1309,65 @@ export function generateCSSFromTokens(tokens) {
1278
1309
  .toLowerCase()
1279
1310
  .replace(/^-/, '');
1280
1311
  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
1312
 
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(` }`);
1313
+ // Generate Tailwind-compatible breakpoint class: md:text-body
1314
+ // Apply ALL properties of the text style, not just responsive values
1315
+ lines.push(` .${bp}\\:${className} {`);
1316
+ lines.push(` @media (min-width: ${breakpointValues[bp]}) {`);
1317
+
1318
+ // Font family
1319
+ if (style.fontFamily) {
1320
+ const fontVar = `--font-${style.fontFamily}`;
1321
+ lines.push(` font-family: var(${fontVar});`);
1302
1322
  }
1323
+
1324
+ // Font weight
1325
+ if (style.fontWeight) {
1326
+ lines.push(` font-weight: ${style.fontWeight};`);
1327
+ }
1328
+
1329
+ // Font style
1330
+ if (style.fontStyle) {
1331
+ lines.push(` font-style: ${style.fontStyle};`);
1332
+ }
1333
+
1334
+ // Font size (use breakpoint value if available, otherwise base)
1335
+ if (style.fontSize) {
1336
+ const fontSize = typeof style.fontSize === 'object'
1337
+ ? (style.fontSize[bp] || style.fontSize.base)
1338
+ : style.fontSize;
1339
+ lines.push(` font-size: ${fontSize};`);
1340
+ }
1341
+
1342
+ // Line height (use breakpoint value if available, otherwise base)
1343
+ if (style.lineHeight) {
1344
+ const lineHeight = typeof style.lineHeight === 'object'
1345
+ ? (style.lineHeight[bp] || style.lineHeight.base)
1346
+ : style.lineHeight;
1347
+ lines.push(` line-height: ${lineHeight};`);
1348
+ }
1349
+
1350
+ // Letter spacing (use breakpoint value if available, otherwise base)
1351
+ if (style.letterSpacing) {
1352
+ const letterSpacing = typeof style.letterSpacing === 'object'
1353
+ ? (style.letterSpacing[bp] || style.letterSpacing.base)
1354
+ : style.letterSpacing;
1355
+ lines.push(` letter-spacing: ${letterSpacing};`);
1356
+ }
1357
+
1358
+ // Text transform
1359
+ if (style.textTransform) {
1360
+ lines.push(` text-transform: ${style.textTransform};`);
1361
+ }
1362
+
1363
+ // Text color
1364
+ if (style.textColor) {
1365
+ const colorVar = `--color-${style.textColor.replace(/([A-Z])/g, '-$1').toLowerCase()}`;
1366
+ lines.push(` color: var(${colorVar});`);
1367
+ }
1368
+
1369
+ lines.push(` }`);
1370
+ lines.push(` }`);
1303
1371
  }
1304
1372
  }
1305
1373