Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { extractUmbColorVariable } from '../../resources/extractUmbColorVariable.function.js';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import { html, customElement, property, state, ifDefined, css, styleMap } from '@umbraco-cms/backoffice/external/lit';
import type { StyleInfo } from '@umbraco-cms/backoffice/external/lit';
import { html, customElement, property, state, ifDefined, css } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';

/**
Expand All @@ -17,9 +16,6 @@ export class UmbIconElement extends UmbLitElement {
@state()
private _icon?: string;

@state()
private _style: StyleInfo = {};

/**
* Color alias or a color code directly.
* If a color has been set via the name property, this property will override it.
Expand Down Expand Up @@ -53,19 +49,19 @@ export class UmbIconElement extends UmbLitElement {
const value = this.#color || this.#fallbackColor;

if (!value) {
this._style = { '--uui-icon-color': 'inherit' };
this.style.removeProperty('--uui-icon-color');
Comment thread
engijlr marked this conversation as resolved.
Comment thread
engijlr marked this conversation as resolved.
return;
}

const color = value.replace('color-', '');
const variable = extractUmbColorVariable(color);
const styling = variable ? `var(${variable})` : color;

this._style = { '--uui-icon-color': styling };
this.style.setProperty('--uui-icon-color', styling);
Comment thread
engijlr marked this conversation as resolved.
}

override render() {
return html`<uui-icon name=${ifDefined(this._icon)} style=${styleMap(this._style)}></uui-icon>`;
return html`<uui-icon name=${ifDefined(this._icon)}></uui-icon>`;
}

static override styles = [
Expand Down
Loading