@yahoo/uds-mobile 2.4.1 → 2.4.3

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.
@@ -123,25 +123,12 @@ function generateElevationBorderColors(config, colorMode) {
123
123
  */
124
124
  function generateElevationBackgroundColors(config, colorMode) {
125
125
  const result = {};
126
- const palette = config.colorMode[colorMode].palette;
127
- const spectrum = config.colorMode[colorMode].spectrum;
128
126
  for (const level of Object.keys(config.elevation)) {
129
- const backgroundFill = config.elevation[level][colorMode].backgroundFill;
127
+ const fbv = config.elevation[level][colorMode].finalBackgroundValue;
130
128
  let color = "transparent";
131
- if (backgroundFill.type === "background") {
132
- const colorDef = palette.background?.[backgroundFill.value];
133
- if (colorDef) {
134
- const rgbValue = spectrum[colorDef.hue]?.[colorDef.step];
135
- if (rgbValue) {
136
- const parts = extractRgb(rgbValue).trim().split(/\s+/);
137
- color = colorDef.opacity !== void 0 ? `rgba(${parts.join(", ")}, ${parseInt(colorDef.opacity, 10) / 100})` : `rgb(${parts.join(", ")})`;
138
- }
139
- }
140
- } else if (backgroundFill.type === "always") color = newAlwaysPalette[backgroundFill.value] ?? "transparent";
141
- else if (backgroundFill.type === "spectrum") {
142
- const spectrumValue = backgroundFill.value;
143
- const rgbValue = spectrum[spectrumValue.hue]?.[spectrumValue.step];
144
- if (rgbValue) color = `rgb(${extractRgb(rgbValue).trim().split(/\s+/).join(", ")})`;
129
+ if (fbv) {
130
+ const alpha = parseInt(String(fbv.a), 10) / 100;
131
+ color = alpha < 1 ? `rgba(${fbv.r}, ${fbv.g}, ${fbv.b}, ${alpha})` : `rgb(${fbv.r}, ${fbv.g}, ${fbv.b})`;
145
132
  }
146
133
  result[`elevation-${level}`] = color;
147
134
  }
@@ -277,7 +264,7 @@ function isElevationCustomShadows(value) {
277
264
  function generateBoxShadows(config, colorMode) {
278
265
  const colorsConfig = config.colorMode[colorMode];
279
266
  const spectrum = colorsConfig.spectrum;
280
- const palette = colorsConfig.palette.foreground;
267
+ const palette = colorsConfig.palette.shadow;
281
268
  const drop = {};
282
269
  const inset = {};
283
270
  for (const [variant, presets] of Object.entries(config.shadow.drop)) {
@@ -388,7 +375,7 @@ function resolveValue(variable, config, colorMode, propName) {
388
375
  const shadowVariant = value;
389
376
  if (shadowVariant === "none") return [];
390
377
  const shadowPresets = config.shadow.drop[shadowVariant];
391
- if (shadowPresets && shadowPresets.length > 0) return convertShadowToBoxShadow(shadowPresets, spectrum, palette.foreground);
378
+ if (shadowPresets && shadowPresets.length > 0) return convertShadowToBoxShadow(shadowPresets, spectrum, palette.shadow);
392
379
  return [];
393
380
  }
394
381
  if (type === "shadowVariantsWithInvert") {
@@ -396,9 +383,9 @@ function resolveValue(variable, config, colorMode, propName) {
396
383
  if (shadowVariant === "none") return [];
397
384
  const baseVariant = shadowVariant.endsWith("-invert") ? shadowVariant.replace("-invert", "") : shadowVariant;
398
385
  const shadowPresets = config.shadow.inset[shadowVariant];
399
- if (shadowPresets && shadowPresets.length > 0) return convertShadowToBoxShadow(shadowPresets, spectrum, palette.foreground, true);
386
+ if (shadowPresets && shadowPresets.length > 0) return convertShadowToBoxShadow(shadowPresets, spectrum, palette.shadow, true);
400
387
  const dropPresets = config.shadow.drop[baseVariant];
401
- if (dropPresets && dropPresets.length > 0) return convertShadowToBoxShadow(dropPresets, spectrum, palette.foreground, true);
388
+ if (dropPresets && dropPresets.length > 0) return convertShadowToBoxShadow(dropPresets, spectrum, palette.shadow, true);
402
389
  return [];
403
390
  }
404
391
  if (type === "elevationAliases") {
@@ -407,22 +394,10 @@ function resolveValue(variable, config, colorMode, propName) {
407
394
  if (!elevationPreset) return;
408
395
  const preset = elevationPreset[colorMode];
409
396
  if (propName === "backgroundColor") {
410
- const backgroundFill = preset.backgroundFill;
411
- if (backgroundFill.type === "background") {
412
- const colorDef = palette.background?.[backgroundFill.value];
413
- if (colorDef) {
414
- const rgbValue = spectrum[colorDef.hue]?.[colorDef.step];
415
- if (rgbValue) {
416
- const parts = extractRgb(rgbValue).trim().split(/\s+/);
417
- if (colorDef.opacity !== void 0) return `rgba(${parts.join(", ")}, ${parseInt(colorDef.opacity, 10) / 100})`;
418
- return `rgb(${parts.join(", ")})`;
419
- }
420
- }
421
- } else if (backgroundFill.type === "always") return newAlwaysPalette[backgroundFill.value] ?? "transparent";
422
- else if (backgroundFill.type === "spectrum") {
423
- const spectrumValue = backgroundFill.value;
424
- const rgbValue = spectrum[spectrumValue.hue]?.[spectrumValue.step];
425
- if (rgbValue) return `rgb(${extractRgb(rgbValue).trim().split(/\s+/).join(", ")})`;
397
+ const fbv = preset.finalBackgroundValue;
398
+ if (fbv) {
399
+ const alpha = parseInt(String(fbv.a), 10) / 100;
400
+ return alpha < 1 ? `rgba(${fbv.r}, ${fbv.g}, ${fbv.b}, ${alpha})` : `rgb(${fbv.r}, ${fbv.g}, ${fbv.b})`;
426
401
  }
427
402
  return "transparent";
428
403
  }
@@ -457,10 +432,10 @@ function resolveValue(variable, config, colorMode, propName) {
457
432
  if (!preset.dropShadow || preset.dropShadow === "none") return [];
458
433
  if (isElevationCustomShadows(preset.dropShadow)) {
459
434
  const allPresets = [...preset.dropShadow];
460
- return allPresets.length > 0 ? convertShadowToBoxShadow(allPresets, spectrum, palette.foreground) : [];
435
+ return allPresets.length > 0 ? convertShadowToBoxShadow(allPresets, spectrum, palette.shadow) : [];
461
436
  }
462
437
  const refPresets = config.shadow.drop[preset.dropShadow];
463
- return refPresets && refPresets.length > 0 ? convertShadowToBoxShadow(refPresets, spectrum, palette.foreground) : [];
438
+ return refPresets && refPresets.length > 0 ? convertShadowToBoxShadow(refPresets, spectrum, palette.shadow) : [];
464
439
  }
465
440
  return;
466
441
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yahoo/uds-mobile",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "uds-mobile": "./cli/uds-mobile.js"