Skip to content

Commit

Permalink
New card configuration option: show_line
Browse files Browse the repository at this point in the history
  • Loading branch information
bessarabov committed Apr 26, 2020
1 parent aeff374 commit 7b14362
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ but you can use it to customize the card.
| --- | --- | --- |
| **left_icon** | `mdi:electron-framework` | Left icon in the card |
| **right_icon** | `mdi:ceiling-light` | Right icon in the card |
| **show_line** | `false` | Showing a line between icons |
11 changes: 11 additions & 0 deletions animated-consumption-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ class AnimatedConsumptionCard extends HTMLElement {
this.rightIcon = config.right_icon;
}

this.showLine = false;
if (config.show_line) {
this.showLine = true;
}

this.contentIsCreated = false;

this.speed = 0;
Expand All @@ -64,6 +69,11 @@ class AnimatedConsumptionCard extends HTMLElement {
card.appendChild(content);
this.appendChild(card);

var maybeALine = '';
if (this.showLine) {
maybeALine = `<line x1="0" y1="20" x2="500" y2="20" style="stroke:var(--primary-text-color);" />`;
}

content.innerHTML = `
<style>
Expand Down Expand Up @@ -109,6 +119,7 @@ class AnimatedConsumptionCard extends HTMLElement {
viewBox="0 0 500 40"
preserveAspectRatio="xMinYMax slice"
>
${maybeALine}
</svg>
</td>
Expand Down
1 change: 1 addition & 0 deletions development/ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ views:
entity: input_number.input_number_1
left_icon: mdi:flash
right_icon: mdi:ceiling-light
show_line: true

- type: entities
entities:
Expand Down

0 comments on commit 7b14362

Please sign in to comment.