First attempt

This commit is contained in:
2026-03-30 00:20:44 -04:00
parent 25fe4bef13
commit 90979972a6
3 changed files with 29 additions and 15 deletions

View File

@@ -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';
}

View File

@@ -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

View File

@@ -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