Skip to content

Commit 58171b4

Browse files
authored
Fix some lint warnings and possible upper/lowercase issues
Also, add the show option show.horseshoe (default true) to optionally disable rendering the horseshoe. This does not mean that the requirements for the horseshoe are disabled also: so you still have to provide the scale, colorstops, etc.
1 parent 7d97395 commit 58171b4

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

Diff for: flex-horseshoe-card.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Card : flex-horseshoe-card.js
3+
* Card : flex-horseshoe-card.js
44
* Project : Home Assistant
55
* Repository: https://github.com/AmoebeLabs/
66
*
@@ -34,6 +34,7 @@ const TICKMARKS_RADIUS_SIZE = 0.43 * SVG_VIEW_BOX;
3434
const HORSESHOE_PATH_LENGTH = 2 * 260/360 * Math.PI * HORSESHOE_RADIUS_SIZE;
3535

3636
const DEFAULT_SHOW = {
37+
horseshoe: true,
3738
scale_tickmarks: false,
3839
horseshoe_style: 'fixed',
3940
}
@@ -629,7 +630,7 @@ class FlexHorseshoeCard extends LitElement {
629630
.card--filter-none {
630631
}
631632
632-
#horseshoe__svg__group {
633+
.horseshoe__svg__group {
633634
transform: translateY(15%);
634635
}
635636
@@ -762,7 +763,6 @@ class FlexHorseshoeCard extends LitElement {
762763
this.color0 = stroke;
763764
this.color1 = stroke;
764765
this.color1_offset = '0%';
765-
766766
}
767767
else if (strokeStyle == 'lineargradient') {
768768
// This has taken a lot of time to get a satisfying result, and it appeared much simpler than anticipated.
@@ -787,9 +787,8 @@ class FlexHorseshoeCard extends LitElement {
787787
if (this.config.animations) Object.keys(this.config.animations).map(animation => {
788788
const entityIndex = animation.substr(Number(animation.indexOf('.') + 1));
789789
this.config.animations[animation].map(item => {
790-
791790
// if animation state not equals sensor state, return... Nothing to animate for this state...
792-
if (!(this.entities[entityIndex].state === item.state)) return;
791+
if (this.entities[entityIndex].state.toLowerCase() != item.state.toLowerCase()) return;
793792

794793
if (item.vlines) {
795794
item.vlines.map(item2 => {
@@ -1087,8 +1086,10 @@ class FlexHorseshoeCard extends LitElement {
10871086

10881087
_renderHorseShoe() {
10891088

1089+
if (!this.config.show.horseshoe) return;
1090+
10901091
return svg`
1091-
<g id="horseshoe__svg__group">
1092+
<g id="horseshoe__svg__group" class="horseshoe__svg__group">
10921093
<circle id="horseshoe__scale" class="horseshoe__scale" cx="50%" cy="50%" r="45%"
10931094
fill="${this.config.fill || 'rgba(0, 0, 0, 0)'}"
10941095
stroke="${this.config.horseshoe_scale.color || '#000000'}"
@@ -1287,7 +1288,7 @@ class FlexHorseshoeCard extends LitElement {
12871288

12881289
let uomStyle = {...configStyle, ...UOM_STYLES, ...fsuomStr};
12891290
const uomStyleStr = JSON.stringify(uomStyle).slice(1, -1).replace(/"/g,"").replace(/,/g,"");
1290-
1291+
12911292
const uom = this._buildUom(this.entities[item.entity_index], this.config.entities[item.entity_index]);
12921293

12931294
const state = (this.config.entities[item.entity_index].attribute &&
@@ -1652,7 +1653,6 @@ class FlexHorseshoeCard extends LitElement {
16521653

16531654
handlePopup(e, entity) {
16541655
e.stopPropagation();
1655-
// console.log('handlePopup', e, entity);
16561656

16571657
this._handleClick(this, this._hass, this.config,
16581658
this.config.entities[this.config.entities.findIndex(
@@ -1731,7 +1731,6 @@ class FlexHorseshoeCard extends LitElement {
17311731
*/
17321732

17331733
_buildState(inState, entityConfig) {
1734-
// console.log('buildstate', inState, entityConfig);
17351734
if (isNaN(inState))
17361735
return inState;
17371736

@@ -1935,4 +1934,4 @@ class FlexHorseshoeCard extends LitElement {
19351934
}
19361935
}
19371936

1938-
customElements.define('flex-horseshoe-card', FlexHorseshoeCard);
1937+
customElements.define('flex-horseshoe-card', FlexHorseshoeCard);

0 commit comments

Comments
 (0)