@vettvangur/design-system 2.0.58 → 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 +30 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2417,6 +2417,33 @@ const extractVariantColors = variantNode => {
2417
2417
  }
2418
2418
  };
2419
2419
  }
2420
+ const hasVisibleFill = node => {
2421
+ const paints = Array.isArray(node?.fills) ? node.fills : null;
2422
+ if (!paints || paints.length === 0) {
2423
+ return false;
2424
+ }
2425
+ for (const paint of paints) {
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;
2443
+ }
2444
+ }
2445
+ return false;
2446
+ };
2420
2447
  const getFillToken = node => {
2421
2448
  const fillAlias = Array.isArray(node?.boundVariables?.fills) ? node.boundVariables.fills[0] : null;
2422
2449
  const fillVar = fillAlias?.variable;
@@ -2446,7 +2473,7 @@ const extractVariantColors = variantNode => {
2446
2473
 
2447
2474
  // Prefer explicit bindings on the component root.
2448
2475
  if (variantNode?.type !== 'TEXT') {
2449
- root.bg = getFillToken(variantNode);
2476
+ root.bg = hasVisibleFill(variantNode) ? getFillToken(variantNode) : null;
2450
2477
  root.border = getStrokeToken(variantNode);
2451
2478
  }
2452
2479
  let fallbackRootBg = null;
@@ -2470,7 +2497,7 @@ const extractVariantColors = variantNode => {
2470
2497
 
2471
2498
  // Icon background (used for icon-only background buttons).
2472
2499
  if (!icon.bg && isIconNode(node)) {
2473
- const t = getFillToken(node);
2500
+ const t = hasVisibleFill(node) ? getFillToken(node) : null;
2474
2501
  if (t) {
2475
2502
  icon.bg = t;
2476
2503
  }
@@ -2479,7 +2506,7 @@ const extractVariantColors = variantNode => {
2479
2506
 
2480
2507
  // Root background/stroke candidates (exclude icon wrappers).
2481
2508
  if (!root.bg) {
2482
- const t = getFillToken(node);
2509
+ const t = hasVisibleFill(node) ? getFillToken(node) : null;
2483
2510
  if (t) {
2484
2511
  fallbackRootBg ??= t;
2485
2512
  if (!namedRootBg && isRootBgNode(node)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vettvangur/design-system",
3
- "version": "2.0.58",
3
+ "version": "2.0.59",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "type": "module",