Skip to content

Commit

Permalink
feat(option): override icon with an image URL (kalkih#789)
Browse files Browse the repository at this point in the history
* Override icon with an image URL

added image attribute to override icon with a URL.

(cherry picked from commit dc8aa92)

* Correct icon image height

Kept parent div class the same.

(cherry picked from commit 61fa0d3)

* fix lint errors

* Add as next version

Co-authored-by: Jamie Pezone <[email protected]>
  • Loading branch information
kalkih and jampez77 authored May 13, 2022
1 parent 63248b2 commit 2860a09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 2860a09

Please sign in to comment.