@vettvangur/design-system 2.0.57 → 2.0.59

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 +51 -42
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2417,27 +2417,37 @@ const extractVariantColors = variantNode => {
2417
2417
  }
2418
2418
  };
2419
2419
  }
2420
- const getFillToken = node => {
2421
- // Figma exposes fill variable bindings in two common shapes:
2422
- // - node.boundVariables.fills[0]
2423
- // - node.fills[i].boundVariables.color
2424
- const fillAlias = Array.isArray(node?.boundVariables?.fills) ? node.boundVariables.fills[0] : null;
2425
- const fillVar = fillAlias?.variable;
2426
- if (fillVar?.resolvedType === 'COLOR' && fillVar?.nameKebab) {
2427
- return fillVar.nameKebab;
2428
- }
2420
+ const hasVisibleFill = node => {
2429
2421
  const paints = Array.isArray(node?.fills) ? node.fills : null;
2430
- if (!paints) {
2431
- return null;
2422
+ if (!paints || paints.length === 0) {
2423
+ return false;
2432
2424
  }
2433
2425
  for (const paint of paints) {
2434
- const colorAlias = paint?.boundVariables?.color;
2435
- const colorVar = colorAlias?.variable;
2436
- if (colorVar?.resolvedType === 'COLOR' && colorVar?.nameKebab) {
2437
- return colorVar.nameKebab;
2426
+ if (!paint || typeof paint !== 'object') {
2427
+ continue;
2428
+ }
2429
+ if (paint.visible === false) {
2430
+ continue;
2431
+ }
2432
+ const opacity = typeof paint.opacity === 'number' ? paint.opacity : 1;
2433
+ if (opacity <= 0) {
2434
+ continue;
2435
+ }
2436
+ const alpha = typeof paint?.color?.a === 'number' ? paint.color.a : 1;
2437
+ if (alpha * opacity <= 0) {
2438
+ continue;
2439
+ }
2440
+ const type = typeof paint.type === 'string' ? paint.type : null;
2441
+ if (type && type !== 'NONE') {
2442
+ return true;
2438
2443
  }
2439
2444
  }
2440
- return null;
2445
+ return false;
2446
+ };
2447
+ const getFillToken = node => {
2448
+ const fillAlias = Array.isArray(node?.boundVariables?.fills) ? node.boundVariables.fills[0] : null;
2449
+ const fillVar = fillAlias?.variable;
2450
+ return fillVar?.resolvedType === 'COLOR' && fillVar?.nameKebab ? fillVar.nameKebab : null;
2441
2451
  };
2442
2452
  const getStrokeToken = node => {
2443
2453
  const strokeAlias = Array.isArray(node?.boundVariables?.strokes) ? node.boundVariables.strokes[0] : null;
@@ -2463,7 +2473,7 @@ const extractVariantColors = variantNode => {
2463
2473
 
2464
2474
  // Prefer explicit bindings on the component root.
2465
2475
  if (variantNode?.type !== 'TEXT') {
2466
- root.bg = getFillToken(variantNode);
2476
+ root.bg = hasVisibleFill(variantNode) ? getFillToken(variantNode) : null;
2467
2477
  root.border = getStrokeToken(variantNode);
2468
2478
  }
2469
2479
  let fallbackRootBg = null;
@@ -2479,38 +2489,37 @@ const extractVariantColors = variantNode => {
2479
2489
  if (t) {
2480
2490
  root.text = t;
2481
2491
  }
2492
+ return;
2482
2493
  }
2483
2494
  if (node?.type === 'TEXT') {
2484
2495
  return;
2485
2496
  }
2486
2497
 
2487
- // If the design has a dedicated icon wrapper with a fill token, prefer mapping it
2488
- // to `.button__icon` instead of the button root.
2498
+ // Icon background (used for icon-only background buttons).
2489
2499
  if (!icon.bg && isIconNode(node)) {
2490
- const t = getFillToken(node);
2500
+ const t = hasVisibleFill(node) ? getFillToken(node) : null;
2491
2501
  if (t) {
2492
2502
  icon.bg = t;
2493
2503
  }
2504
+ return;
2494
2505
  }
2495
2506
 
2496
2507
  // Root background/stroke candidates (exclude icon wrappers).
2497
- if (!isIconNode(node)) {
2498
- if (!root.bg) {
2499
- const t = getFillToken(node);
2500
- if (t) {
2501
- fallbackRootBg ??= t;
2502
- if (!namedRootBg && isRootBgNode(node)) {
2503
- namedRootBg = t;
2504
- }
2508
+ if (!root.bg) {
2509
+ const t = hasVisibleFill(node) ? getFillToken(node) : null;
2510
+ if (t) {
2511
+ fallbackRootBg ??= t;
2512
+ if (!namedRootBg && isRootBgNode(node)) {
2513
+ namedRootBg = t;
2505
2514
  }
2506
2515
  }
2507
- if (!root.border) {
2508
- const t = getStrokeToken(node);
2509
- if (t) {
2510
- fallbackRootBorder ??= t;
2511
- if (!namedRootBorder && isRootBgNode(node)) {
2512
- namedRootBorder = t;
2513
- }
2516
+ }
2517
+ if (!root.border) {
2518
+ const t = getStrokeToken(node);
2519
+ if (t) {
2520
+ fallbackRootBorder ??= t;
2521
+ if (!namedRootBorder && isRootBgNode(node)) {
2522
+ namedRootBorder = t;
2514
2523
  }
2515
2524
  }
2516
2525
  }
@@ -2531,13 +2540,6 @@ const renderApplyLine = (prefix, token, indent = ' ') => {
2531
2540
  }
2532
2541
  return `${indent}@apply ${prefix}-${token};\n`;
2533
2542
  };
2534
- function renderIconBgBlock(indent, bgToken) {
2535
- if (!bgToken) {
2536
- return '';
2537
- }
2538
- const innerIndent = `${indent} `;
2539
- return `${indent}.button__icon {\n${renderApplyLine('bg', bgToken, innerIndent)}${indent}}\n`;
2540
- }
2541
2543
  function renderUtility(name, base, hover) {
2542
2544
  const baseRoot = base?.root ?? {
2543
2545
  bg: null,
@@ -2550,6 +2552,13 @@ function renderUtility(name, base, hover) {
2550
2552
  const hoverRoot = hover?.root ?? null;
2551
2553
  const hoverIcon = hover?.icon ?? null;
2552
2554
  const baseLines = renderApplyLine('bg', baseRoot?.bg, ' ') + renderApplyLine('border', baseRoot?.border, ' ') + renderApplyLine('text', baseRoot?.text, ' ');
2555
+ const renderIconBgBlock = (indent, bgToken) => {
2556
+ if (!bgToken) {
2557
+ return '';
2558
+ }
2559
+ const innerIndent = `${indent} `;
2560
+ return `${indent}.button__icon {\n${renderApplyLine('bg', bgToken, innerIndent)}${indent}}\n`;
2561
+ };
2553
2562
 
2554
2563
  // Only emit icon background styles when the button root itself has no background.
2555
2564
  const iconBaseBlock = !baseRoot?.bg ? renderIconBgBlock(' ', baseIcon?.bg) : '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vettvangur/design-system",
3
- "version": "2.0.57",
3
+ "version": "2.0.59",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "type": "module",