Skip to content

Commit

Permalink
Enable contain-toggled for stack (#25)
Browse files Browse the repository at this point in the history
* Fix contain-toggled for stacks

* Fixed missing token

* Fix inArray

* Fix travesing cards

* Fix conditions

* Fixed typo
  • Loading branch information
holantomas authored Nov 6, 2022
1 parent 8ad3fb7 commit d5e5fa2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions collapsable-cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,17 @@ class VerticalStackInCard extends HTMLElement {
styleTag.innerHTML = this.getStyles()
card.appendChild(styleTag);

if (
config.defaultOpen === 'contain-toggled' &&
config.cards.filter((c) => this._hass.states[c.entity]?.state !== "off")
.length > 0
) {
if (config.defaultOpen === 'contain-toggled' && config.cards.filter((c) => this.checkActiveCard(c)).length > 0) {
toggleButton.click();
}
}

checkActiveCard(card) {
const containers = ["grid", "vertical-stack", "horizontal-stack"];
return containers.includes(card.type)
? card.cards.filter((c) => this.checkActiveCard(c)).length > 0
: this._hass.states[card.entity]?.state !== "off"
}

createToggleButton() {
const toggleButton = document.createElement('button');
Expand Down

0 comments on commit d5e5fa2

Please sign in to comment.