Compare commits
1 Commits
7a490f2b4d
...
state_colo
| Author | SHA1 | Date | |
|---|---|---|---|
|
772860344c
|
@@ -6,18 +6,20 @@
|
||||
state = hass?.states[this.config?.entity]?.state || '';
|
||||
}
|
||||
|
||||
let bg_color = 'var(--bubble-main-background-color)';
|
||||
let off_color = this.config?.state_color_button?.off_color
|
||||
? `var(--${this.config.state_color_button.off_color})`
|
||||
: 'var(--bubble-main-background-color)';
|
||||
|
||||
// Use the configured color or default to accent color
|
||||
let on_color = this.config?.state_color_button?.color
|
||||
? `var(--${this.config.state_color_button.color})`
|
||||
let on_color = this.config?.state_color_button?.on_color
|
||||
? `var(--${this.config.state_color_button.on_color})`
|
||||
: 'var(--bubble-accent-color)';
|
||||
|
||||
// Main button background
|
||||
const mainButton = card?.querySelector('.bubble-button-background');
|
||||
if (mainButton) {
|
||||
mainButton.style.opacity = '1';
|
||||
mainButton.style.backgroundColor = state === 'on' ? on_color : bg_color;
|
||||
mainButton.style.backgroundColor = state === 'on' ? on_color : off_color;
|
||||
mainButton.style.transition = 'background-color 1s';
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
- name: color
|
||||
label: Color (CSS Variable)
|
||||
- name: on_color
|
||||
label: On Color (CSS Variable)
|
||||
selector:
|
||||
text: {}
|
||||
required: false
|
||||
- name: off_color
|
||||
label: Off Color (CSS Variable)
|
||||
selector:
|
||||
text: {}
|
||||
required: false
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
state_color_button:
|
||||
name: State Color Button
|
||||
version: 1.2.0
|
||||
version: 2.0.0
|
||||
creator: Tony Stork
|
||||
supported:
|
||||
- button
|
||||
@@ -14,7 +14,7 @@ state_color_button:
|
||||
alt_entity: sensor.your_face
|
||||
</pre></code-block>
|
||||
code: |-
|
||||
${(() => {
|
||||
`${(() => {
|
||||
let state;
|
||||
if (this.config?.state_color_button?.alt_entity) {
|
||||
state = hass?.states[this.config?.state_color_button?.alt_entity]?.state || '';
|
||||
@@ -22,18 +22,20 @@ state_color_button:
|
||||
state = hass?.states[this.config?.entity]?.state || '';
|
||||
}
|
||||
|
||||
let bg_color = 'var(--bubble-main-background-color)';
|
||||
let off_color = this.config?.state_color_button?.off_color
|
||||
? `var(--${this.config.state_color_button.off_color})`
|
||||
: 'var(--bubble-main-background-color)';
|
||||
|
||||
// Use the configured color or default to accent color
|
||||
let on_color = this.config?.state_color_button?.color
|
||||
? `var(--${this.config.state_color_button.color})`
|
||||
let on_color = this.config?.state_color_button?.on_color
|
||||
? `var(--${this.config.state_color_button.on_color})`
|
||||
: 'var(--bubble-accent-color)';
|
||||
|
||||
// Main button background
|
||||
const mainButton = card?.querySelector('.bubble-button-background');
|
||||
if (mainButton) {
|
||||
mainButton.style.opacity = '1';
|
||||
mainButton.style.backgroundColor = state === 'on' ? on_color : bg_color;
|
||||
mainButton.style.backgroundColor = state === 'on' ? on_color : off_color;
|
||||
mainButton.style.transition = 'background-color 1s';
|
||||
}
|
||||
|
||||
@@ -54,10 +56,15 @@ state_color_button:
|
||||
|
||||
// No CSS string needed
|
||||
return '';
|
||||
})()}
|
||||
})()}`
|
||||
editor:
|
||||
- name: color
|
||||
label: Color (CSS Variable)
|
||||
- name: on_color
|
||||
label: On Color (CSS Variable)
|
||||
selector:
|
||||
text: {}
|
||||
required: false
|
||||
- name: off_color
|
||||
label: Off Color (CSS Variable)
|
||||
selector:
|
||||
text: {}
|
||||
required: false
|
||||
|
||||
Reference in New Issue
Block a user