@vettvangur/design-system 2.0.35 → 2.0.37

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/dist/index.js +85 -51
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3523,61 +3523,95 @@ async function generateShadows(variableSet, config) {
3523
3523
  message(`finished generating shadows (${lines.length})`);
3524
3524
  }
3525
3525
 
3526
- /**
3527
- * design-system :: src/generators/tailwind/screens.mjs.
3528
- *
3529
- * Design token tooling: pulls from Figma and generates platform outputs (Razor/Astro/Tailwind).
3530
- *
3531
- * These docs are generated from inline JSDoc in the repo and are intended for contributors.
3532
- *
3533
- * @generated
3534
- * @module design-system
3535
- */
3536
- const
3537
- /**
3538
- * BREAKPOINTS CSS.
3539
- *
3540
- * @generated
3541
- * @example
3542
- * console.log(BREAKPOINTS_CSS)
3543
- */
3544
- BREAKPOINTS_CSS = `/* AUTO-GENERATED - DO NOT EDIT BY HAND */
3545
-
3546
- @theme {
3547
- --breakpoint-phone-xs: ${rem(0)};
3548
- --breakpoint-phone-s: ${rem(321)};
3549
- --breakpoint-phone-m: ${rem(426)};
3550
- --breakpoint-tablet: ${rem(576)};
3551
- --breakpoint-desktop-xs: ${rem(775)};
3552
- --breakpoint-desktop-s: ${rem(992)};
3553
- --breakpoint-desktop-m: ${rem(1200)};
3554
- --breakpoint-desktop-l: ${rem(1280)};
3555
- --breakpoint-desktop-xl: ${rem(1367)};
3556
- --breakpoint-desktop-xxl: ${rem(1740)};
3557
- --breakpoint-ultrawide: ${rem(2000)};
3526
+ /**
3527
+ * design-system :: src/generators/tailwind/screens.mjs.
3528
+ *
3529
+ * Design token tooling: pulls from Figma and generates platform outputs (Razor/Astro/Tailwind).
3530
+ *
3531
+ * These docs are generated from inline JSDoc in the repo and are intended for contributors.
3532
+ *
3533
+ * @generated
3534
+ * @module design-system
3535
+ */
3536
+ const BASE_SCREENS = {
3537
+ 'phone-xs': 0,
3538
+ 'phone-s': 321,
3539
+ 'phone-m': 426,
3540
+ tablet: 576,
3541
+ 'desktop-xs': 775,
3542
+ 'desktop-s': 992,
3543
+ 'desktop-m': 1200,
3544
+ 'desktop-l': 1280,
3545
+ 'desktop-xl': 1367,
3546
+ 'desktop-xxl': 1740,
3547
+ ultrawide: 2000
3548
+ };
3549
+ function pickFirstNumber(values) {
3550
+ if (!values || typeof values !== 'object') {
3551
+ return null;
3552
+ }
3553
+ for (const v of Object.values(values)) {
3554
+ if (typeof v === 'number' && Number.isFinite(v)) {
3555
+ return v;
3556
+ }
3557
+ }
3558
+ return null;
3558
3559
  }
3559
- `;
3560
-
3561
- /**
3562
- * Generate screens.
3563
- *
3564
- * @param config - Configuration object.
3565
- * @returns Nothing.
3566
- *
3567
- * @example
3568
- * // design-system (src/tools/javascript/design-system/src/generators/tailwind/screens.mjs)
3569
- * // import { generateScreens } from '@vettvangur/design-system'
3570
- *
3571
- * await generateScreens({})
3572
- */
3573
- async function generateScreens(config) {
3560
+ function buildScreensCss(extra = {}) {
3561
+ const merged = {
3562
+ ...BASE_SCREENS,
3563
+ ...extra
3564
+ };
3565
+ const keys = Object.keys(merged).sort((a, b) => a.localeCompare(b, 'en'));
3566
+ const lines = ['/* AUTO-GENERATED - DO NOT EDIT BY HAND */', '', '@theme {'];
3567
+ for (const key of keys) {
3568
+ lines.push(` --breakpoint-${key}: ${merged[key]};`);
3569
+ }
3570
+ lines.push('}', '');
3571
+ return `${lines.join('\n')}\n`;
3572
+ }
3573
+
3574
+ /**
3575
+ * Generate screens.
3576
+ *
3577
+ * Writes `screens.css` containing the built-in breakpoints plus any additional
3578
+ * breakpoint values found in the Figma variable collection named `Screens`.
3579
+ *
3580
+ * The Figma variable collection is expected to be present under
3581
+ * `figmaVariables.screens.tokens` (collection keys are kebab-cased).
3582
+ *
3583
+ * Existing built-in breakpoints are never removed. If Figma provides a token
3584
+ * with the same key as a built-in breakpoint, the built-in value wins.
3585
+ *
3586
+ * @param figmaVariables - Raw Figma variables map (from `src/figma/index.mjs`).
3587
+ * @param config - Configuration object.
3588
+ * @returns Nothing.
3589
+ *
3590
+ * @example
3591
+ * // design-system (src/tools/javascript/design-system/src/generators/tailwind/screens.mjs)
3592
+ * // import { generateScreens } from '@vettvangur/design-system'
3593
+ *
3594
+ * await generateScreens({ screens: { tokens: { kiosk: { values: { Default: 1920 } } } } }, { paths: { styles: './src/styles' } })
3595
+ */
3596
+ async function generateScreens(figmaVariables, config) {
3574
3597
  message('generating breakpoints...');
3598
+ const screensCollection = figmaVariables?.screens;
3599
+ const extras = {};
3600
+ for (const [key, tok] of Object.entries(screensCollection?.tokens || {})) {
3601
+ if (Object.hasOwn(BASE_SCREENS, key)) {
3602
+ continue;
3603
+ }
3604
+ const n = pickFirstNumber(tok?.values);
3605
+ if (n != null) {
3606
+ extras[key] = n;
3607
+ }
3608
+ }
3575
3609
  const outDir = path.join(config.paths.styles, 'config');
3576
3610
  await fs$1.mkdir(outDir, {
3577
3611
  recursive: true
3578
3612
  });
3579
3613
  const outPath = path.join(outDir, 'screens.css');
3580
- await fs$1.writeFile(outPath, BREAKPOINTS_CSS, 'utf8');
3614
+ await fs$1.writeFile(outPath, buildScreensCss(extras), 'utf8');
3581
3615
  message('finished generating breakpoints');
3582
3616
  }
3583
3617
 
@@ -3709,7 +3743,7 @@ async function fileExists(p) {
3709
3743
  *
3710
3744
  * await generateTailwind({}, projectType, typography, buttons, colors, scales, effects)
3711
3745
  */
3712
- async function generateTailwind(config, projectType, typography, buttons, colors, scales, effects) {
3746
+ async function generateTailwind(config, projectType, typography, buttons, colors, scales, effects, figmaVariables) {
3713
3747
  message(pc.yellow('-=[ tailwind ]=-'));
3714
3748
  await generateFontFamily(typography.families, config);
3715
3749
  await generateFontWeight(typography.weights, config);
@@ -3727,7 +3761,7 @@ async function generateTailwind(config, projectType, typography, buttons, colors
3727
3761
  await generateColors$1(colors, config);
3728
3762
  await generateScales(scales, config);
3729
3763
  await generateShadows(effects, config);
3730
- await generateScreens(config);
3764
+ await generateScreens(figmaVariables, config);
3731
3765
  await generateSources(config, projectType);
3732
3766
  }
3733
3767
 
@@ -5311,7 +5345,7 @@ async function pullAndBuild({
5311
5345
 
5312
5346
  // console.log(colors)
5313
5347
 
5314
- await generateTailwind(config, 'razor', typography, buttons, colors, scales, raw.effects);
5348
+ await generateTailwind(config, 'razor', typography, buttons, colors, scales, raw.effects, raw.variables);
5315
5349
  if (target === 'razor') {
5316
5350
  // console.dir(typography, { depth: null, maxArrayLength: null })
5317
5351
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vettvangur/design-system",
3
- "version": "2.0.35",
3
+ "version": "2.0.37",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "type": "module",