Skip to content

Commit

Permalink
dominant logic
Browse files Browse the repository at this point in the history
  • Loading branch information
loivsen authored and iOvergaard committed Jul 18, 2024
1 parent 5df0102 commit 2abd5e7
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/packages/core/components/icon/icon.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class UmbIconElement extends UmbLitElement {
@property({ type: String })
public set color(value: string) {
if (value) {
this.#setColorStyle(value);
this.#setColorStyle(value, true);
} else {
this._color = undefined;
}
Expand All @@ -35,20 +35,15 @@ export class UmbIconElement extends UmbLitElement {
return this._color ?? '';
}

#setColorStyle(value: string) {
#setColorStyle(value: string, dominant = false) {
const alias = value.replace('color-', '');
const variable = extractUmbColorVariable(alias);
this._color = alias ? (variable ? `--uui-icon-color: var(${variable})` : `--uui-icon-color: ${alias}`) : undefined;
}

#setFallbackColorStyle(value: string) {
const alias = value.replace('color-', '');
const variable = extractUmbColorVariable(alias);
this._fallbackColor = alias
? variable
? `--uui-icon-color: var(${variable})`
: `--uui-icon-color: ${alias}`
: undefined;
const color = alias ? (variable ? `--uui-icon-color: var(${variable})` : `--uui-icon-color: ${alias}`) : undefined;
if (dominant) {
this._color = color;
} else {
this._fallbackColor = color;
}
}

/**
Expand All @@ -60,7 +55,7 @@ export class UmbIconElement extends UmbLitElement {
const [icon, color] = value ? value.split(' ') : [];

if (color) {
this.#setFallbackColorStyle(color);
this.#setColorStyle(color);
} else {
this._fallbackColor = undefined;
}
Expand Down

0 comments on commit 2abd5e7

Please sign in to comment.