@rogieking/figui3 8.7.0 → 8.8.1

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.
package/fig.js CHANGED
@@ -16548,11 +16548,41 @@ function figIconCssVar(name, size = "medium") {
16548
16548
  return tokenName ? `var(${tokenName})` : "";
16549
16549
  }
16550
16550
 
16551
+ const FIG_ICON_COLOR_TOKENS = {
16552
+ primary: "--figma-color-icon",
16553
+ secondary: "--figma-color-icon-secondary",
16554
+ tertiary: "--figma-color-icon-tertiary",
16555
+ disabled: "--figma-color-icon-disabled",
16556
+ brand: "--figma-color-icon-brand",
16557
+ component: "--figma-color-icon-component",
16558
+ danger: "--figma-color-icon-danger",
16559
+ success: "--figma-color-icon-success",
16560
+ warning: "--figma-color-icon-warning",
16561
+ selected: "--figma-color-icon-selected",
16562
+ hover: "--figma-color-icon-hover",
16563
+ pressed: "--figma-color-icon-pressed",
16564
+ onbrand: "--figma-color-icon-onbrand",
16565
+ oncomponent: "--figma-color-icon-oncomponent",
16566
+ ondanger: "--figma-color-icon-ondanger",
16567
+ ondisabled: "--figma-color-icon-ondisabled",
16568
+ oninverse: "--figma-color-icon-oninverse",
16569
+ onselected: "--figma-color-icon-onselected",
16570
+ onsuccess: "--figma-color-icon-onsuccess",
16571
+ onwarning: "--figma-color-icon-onwarning",
16572
+ };
16573
+
16574
+ function figIconColorValue(color) {
16575
+ if (!color) return "";
16576
+ if (color.startsWith("var(")) return color;
16577
+ const token = FIG_ICON_COLOR_TOKENS[color.toLowerCase()];
16578
+ return token ? `var(${token})` : color;
16579
+ }
16580
+
16551
16581
  /**
16552
16582
  * Masked icon using design-token SVGs from :root.
16553
16583
  * @attr {string} name - Icon name (chevron, add, close, …)
16554
16584
  * @attr {'small'|'medium'} size - Display size; medium (default) uses --spacer-4, small uses --spacer-3
16555
- * @attr {string} color - Icon fill color (applied as background-color for the mask)
16585
+ * @attr {string} color - Icon color alias (primary, secondary, tertiary, disabled, brand, component, danger, success, warning, selected, hover, pressed, onbrand, …), CSS variable, or CSS color.
16556
16586
  */
16557
16587
  class FigIcon extends HTMLElement {
16558
16588
  static get observedAttributes() {
@@ -16580,9 +16610,14 @@ class FigIcon extends HTMLElement {
16580
16610
  this.style.removeProperty("--size");
16581
16611
  }
16582
16612
 
16583
- const color = this.getAttribute("color");
16584
- if (color) this.style.backgroundColor = color;
16585
- else this.style.removeProperty("background-color");
16613
+ const color = figIconColorValue(this.getAttribute("color"));
16614
+ if (color) {
16615
+ this.style.backgroundColor = color;
16616
+ this.style.setProperty("--icon-color", color);
16617
+ } else {
16618
+ this.style.removeProperty("background-color");
16619
+ this.style.removeProperty("--icon-color");
16620
+ }
16586
16621
 
16587
16622
  if (!this.hasAttribute("aria-hidden")) {
16588
16623
  this.setAttribute("aria-hidden", "true");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "8.7.0",
3
+ "version": "8.8.1",
4
4
  "description": "A lightweight web components library for building Figma plugin and widget UIs with native look and feel",
5
5
  "author": "Rogie King",
6
6
  "license": "MIT",