fix: Rationalize custom icons to avoid duplication (#1639)

This commit is contained in:
Dermot Duffy
2024-10-13 16:24:51 -07:00
committed by GitHub
parent 0ec9afbad2
commit 7895de96d2
29 changed files with 573 additions and 272 deletions
+4 -3
View File
@@ -8,6 +8,7 @@ import { MenuController } from '../components-lib/menu-controller.js';
import type { MenuConfig, MenuItem } from '../config/types.js';
import menuStyle from '../scss/menu.scss';
import { frigateCardHasAction } from '../utils/action.js';
import { getCustomIconURL } from '../utils/custom-icons.js';
import { EntityRegistryManager } from '../utils/ha/registry/entity/index.js';
import './submenu.js';
@@ -72,7 +73,7 @@ export class FrigateCardMenu extends LitElement {
// (`data-state`). This looks up a CSS style in `menu.scss`.
const buttonState = this._controller.getFreshButtonState(this.hass, button);
const svgPath = this._controller.getSVGPath(button);
const customImageURL = getCustomIconURL(buttonState.icon);
return html` <ha-icon-button
data-domain=${ifDefined(buttonState.data_domain)}
@@ -86,8 +87,8 @@ export class FrigateCardMenu extends LitElement {
.label=${buttonState.title || ''}
@action=${(ev) => this._controller.actionHandler(ev, button)}
>
${svgPath
? html`<ha-svg-icon .path="${svgPath}"></ha-svg-icon>`
${customImageURL
? html`<img src="${customImageURL}" />`
: html`<ha-icon
icon="${buttonState.icon || 'mdi:gesture-tap-button'}"
></ha-icon>`}