feat(option): override icon with an image URL (#789)

* Override icon with an image URL

added image attribute to override icon with a URL.

(cherry picked from commit dc8aa9225c04c458ea50c8f8c1154535055dcf40)

* Correct icon image height

Kept parent div class the same.

(cherry picked from commit 61fa0d3488212ab77c8d821344f581a9ac101ea2)

* fix lint errors

* Add as next version

Co-authored-by: Jamie Pezone <jampez77@gmail.com>
This commit is contained in:
Karl Kihlström
2022-05-13 22:25:08 +02:00
committed by GitHub
parent 63248b248f
commit 2860a094e7
2 changed files with 9 additions and 0 deletions

View File

@@ -79,6 +79,7 @@ We recommend looking at the [Example usage section](#example-usage) to understan
| type ***(required)*** | string | | v0.0.1 | `custom:mini-graph-card`.
| entities ***(required)*** | list | | v0.2.0 | One or more sensor entities in a list, see [entities object](#entities-object) for additional entity options.
| icon | string | | v0.0.1 | Set a custom icon from any of the available mdi icons.
| icon_image | string | | NEXT_VERSION | Override icon with an image url
| name | string | | v0.0.1 | Set a custom name which is displayed beside the icon.
| unit | string | | v0.0.1 | Set a custom unit of measurement.
| tap_action | [action object](#action-object-options) | | v0.7.0 | Action on click/tap.

View File

@@ -227,6 +227,14 @@ class MiniGraphCard extends LitElement {
}
renderIcon() {
if (this.config.icon_image !== 'undefined') {
return html`
<div class="icon">
<img src="${this.config.icon_image}" height="25"/>
</div>
`;
}
const { icon, icon_adaptive_color } = this.config.show;
return icon ? html`
<div class="icon" loc=${this.config.align_icon}