@rogieking/figui3 8.7.0 → 8.8.0
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/README.md +2 -2
- package/dist/fig.js +1 -1
- package/fig.js +32 -2
- package/package.json +1 -1
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
|
|
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,7 +16610,7 @@ class FigIcon extends HTMLElement {
|
|
|
16580
16610
|
this.style.removeProperty("--size");
|
|
16581
16611
|
}
|
|
16582
16612
|
|
|
16583
|
-
const color = this.getAttribute("color");
|
|
16613
|
+
const color = figIconColorValue(this.getAttribute("color"));
|
|
16584
16614
|
if (color) this.style.backgroundColor = color;
|
|
16585
16615
|
else this.style.removeProperty("background-color");
|
|
16586
16616
|
|
package/package.json
CHANGED