Skip to content

Commit 2f86904

Browse files
authored
Update binary-control-button-row.js
1 parent 9a6c2a7 commit 2f86904

1 file changed

Lines changed: 92 additions & 93 deletions

File tree

dist/binary-control-button-row.js

Lines changed: 92 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,23 @@ class CustomBinaryRow extends Polymer.Element {
5252
},
5353
_config: Object,
5454
_stateObj: Object,
55-
_onColor: String,
56-
_offColor: String,
57-
_onText: String,
58-
_offText: String,
59-
_onName: String,
60-
_offName: String,
61-
_isOffState: Boolean,
62-
_isOnState: Boolean,
63-
64-
_leftColor: String,
65-
_leftText: String,
66-
_leftName: String,
67-
_leftState: Boolean,
68-
69-
_rightColor: String,
70-
_rightText: String,
71-
_rightName: String,
72-
_rightState: Boolean,
55+
//_onColor: String,
56+
//_offColor: String,
57+
//_onText: String,
58+
//_offText: String,
59+
//_onName: String,
60+
//_offName: String,
61+
//_isOffState: Boolean,
62+
//_isOnState: Boolean,
63+
64+
_leftColor: String,
65+
_leftText: String,
66+
_leftName: String,
67+
_leftState: Boolean,
68+
_rightColor: String,
69+
_rightText: String,
70+
_rightName: String,
71+
_rightState: Boolean,
7372

7473
}
7574
}
@@ -80,9 +79,9 @@ class CustomBinaryRow extends Polymer.Element {
8079
this._config = {
8180
customTheme: false,
8281
reverseButtons: false,
83-
IsOnColor: '#43A047',
84-
IsOffColor: '#f44c09',
85-
ButtonInactiveColor: '#759aaa',
82+
isOnColor: '#43A047',
83+
isOffColor: '#f44c09',
84+
buttonInactiveColor: '#759aaa',
8685
customOffText: 'OFF',
8786
customOnText: 'ON',
8887
...config
@@ -93,94 +92,94 @@ class CustomBinaryRow extends Polymer.Element {
9392

9493
const config = this._config;
9594
const stateObj = hass.states[config.entity];
96-
const custTheme = config.customTheme;
97-
const revButtons = config.reverseButtons;
98-
const custOnClr = config.isOnColor;
99-
const custOffClr = config.isOffColor;
100-
const custInactiveClr = config.buttonInactiveColor;
101-
const custOffTxt = config.customOffText;
102-
const custOnTxt = config.customOnText;
103-
95+
const custTheme = config.customTheme;
96+
const revButtons = config.reverseButtons;
97+
const custOnClr = config.isOnColor;
98+
const custOffClr = config.isOffColor;
99+
const custInactiveClr = config.buttonInactiveColor;
100+
const custOffTxt = config.customOffText;
101+
const custOnTxt = config.customOnText;
102+
104103

105104

106105

107-
let state;
108-
if (stateObj) {
109-
state = stateObj.state;
110-
}
106+
let state;
107+
if (stateObj) {
108+
state = stateObj.state;
109+
}
111110

112-
let onstate;
113-
let offstate;
111+
let onstate;
112+
let offstate;
114113

115-
if (stateObj) {
116-
if (stateObj.state == 'on') {
117-
onstate = 'on';
118-
} else {
119-
offstate = 'on';
120-
}
114+
if (stateObj) {
115+
if (stateObj.state == 'on') {
116+
onstate = 'on';
117+
} else {
118+
offstate = 'on';
121119
}
120+
}
122121

123-
let oncolor;
124-
let offcolor;
122+
let oncolor;
123+
let offcolor;
125124

126-
if (custTheme) {
127-
if (onstate == 'on') {
128-
oncolor = 'background-color:' + custOnClr;
129-
} else {
130-
oncolor = 'background-color:' + custInactiveClr;
131-
}
125+
if (custTheme) {
126+
if (onstate == 'on') {
127+
oncolor = 'background-color:' + custOnClr;
128+
} else {
129+
oncolor = 'background-color:' + custInactiveClr;
130+
}
132131

133-
if (offstate == 'on') {
134-
offcolor = 'background-color:' + custOffClr;
135-
} else {
136-
offcolor = 'background-color:' + custInactiveClr;
137-
}
132+
if (offstate == 'on') {
133+
offcolor = 'background-color:' + custOffClr;
134+
} else {
135+
offcolor = 'background-color:' + custInactiveClr;
136+
}
137+
} else {
138+
if (onstate == 'on') {
139+
oncolor = 'background-color: var(--primary-color)';
138140
} else {
139-
if (onstate == 'on') {
140-
oncolor = 'background-color: var(--primary-color)';
141-
} else {
142-
oncolor = 'background-color: var(--disabled-text-color)';
143-
}
141+
oncolor = 'background-color: var(--disabled-text-color)';
142+
}
144143

145-
if (offstate == 'on') {
146-
offcolor = 'background-color: var(--primary-color)';
147-
} else {
148-
offcolor = 'background-color: var(--disabled-text-color)';
149-
}
144+
if (offstate == 'on') {
145+
offcolor = 'background-color: var(--primary-color)';
146+
} else {
147+
offcolor = 'background-color: var(--disabled-text-color)';
150148
}
149+
}
151150

152-
let offtext = custOffTxt;
153-
let ontext = custOnTxt;
151+
let offtext = custOffTxt;
152+
let ontext = custOnTxt;
154153

155-
let offname = 'off';
156-
let onname = 'on';
154+
let offname = 'off';
155+
let onname = 'on';
157156

158-
if (revButtons) {
159-
this.setProperties({
160-
_stateObj: stateObj,
161-
_rightState: stateObj.state === 'on',
162-
_leftState: stateObj.state == 'off',
163-
_rightName: onname,
164-
_leftName: offname,
165-
_rightColor: oncolor,
166-
_leftColor: offcolor,
167-
_rightText: ontext,
168-
_leftText: offtext,
169-
});
170-
} else {
171-
this.setProperties({
172-
_stateObj: stateObj,
173-
_leftState: stateObj.state === 'on',
174-
_rightState: stateObj.state == 'off',
175-
_leftName: onname,
176-
_rightName: offname,
177-
_leftColor: oncolor,
178-
_rightColor: offcolor,
179-
_leftText: ontext,
180-
_rightText: offtext,
181-
});
182-
}
157+
if (revButtons) {
158+
this.setProperties({
159+
_stateObj: stateObj,
160+
_rightState: stateObj.state === 'on',
161+
_leftState: stateObj.state == 'off',
162+
_rightName: onname,
163+
_leftName: offname,
164+
_rightColor: oncolor,
165+
_leftColor: offcolor,
166+
_rightText: ontext,
167+
_leftText: offtext,
168+
});
169+
} else {
170+
this.setProperties({
171+
_stateObj: stateObj,
172+
_leftState: stateObj.state === 'on',
173+
_rightState: stateObj.state == 'off',
174+
_leftName: onname,
175+
_rightName: offname,
176+
_leftColor: oncolor,
177+
_rightColor: offcolor,
178+
_leftText: ontext,
179+
_rightText: offtext,
180+
});
183181
}
182+
}
184183

185184

186185
stopPropagation(e) {

0 commit comments

Comments
 (0)