diff --git a/src/components/ha-icon.ts b/src/components/ha-icon.ts index 5d71f214ed..f0ae31d674 100644 --- a/src/components/ha-icon.ts +++ b/src/components/ha-icon.ts @@ -4,6 +4,7 @@ import "@polymer/iron-icon/iron-icon"; // Not duplicate, this is for typing. // tslint:disable-next-line import { IronIconElement } from "@polymer/iron-icon/iron-icon"; +import { html } from "@polymer/polymer/lib/utils/html-tag.js"; const ironIconClass = customElements.get("iron-icon") as Constructor< IronIconElement @@ -26,6 +27,96 @@ export class HaIcon extends ironIconClass { import(/* webpackChunkName: "mdi-icons" */ "../resources/mdi-icons"); } } + + _iconChanged(icon) { + const parts = (icon || "").split(":"); + if (parts.length === 3) { + this._iconEffect = parts.pop(); + } + this._iconName = parts.pop(); + this._iconsetName = parts.pop() || this._DEFAULT_ICONSET; + this.setAttribute("effect", this._iconEffect); + this._updateIcon(); + } + + _template = html` + ${super._template} + + `; } declare global {