Skip to content

Commit

Permalink
Merge pull request #28 from custom-cards/dev
Browse files Browse the repository at this point in the history
Version 0.0.7
  • Loading branch information
ofekashery authored Oct 17, 2018
2 parents 95dfbd3 + 7c88a11 commit c547223
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mv vertical-stack-in-card.js /config/www/

```yaml
resources:
- url: /local/vertical-stack-in-card.js?v=0.0.2
- url: /local/vertical-stack-in-card.js?v=0.0.7
type: js
```
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.6
0.0.7
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.0.7
- Fixes [#26](https://github.com/custom-cards/vertical-stack-in-card/issues/26)

## 0.0.6
- Closing issue [#16](https://github.com/custom-cards/vertical-stack-in-card/issues/16)

Expand Down
35 changes: 23 additions & 12 deletions vertical-stack-in-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class VerticalStackInCard extends HTMLElement {
// Make use of shadowRoot to avoid conflicts when reusing
this.attachShadow({ mode: 'open' });
}

setConfig(config) {
if (!config || !config.cards || !Array.isArray(config.cards)) {
throw new Error('Card config incorrect');
Expand All @@ -26,6 +27,7 @@ class VerticalStackInCard extends HTMLElement {
title.innerHTML = '<div class="name">' + config.title + '</div>';
root.appendChild(title);
}

let element;
config.cards.forEach(item => {
if (item.type.startsWith("custom:")){
Expand All @@ -49,20 +51,29 @@ class VerticalStackInCard extends HTMLElement {

connectedCallback() {
this._refCards.forEach((element) => {
if (element.shadowRoot) {
if (!element.shadowRoot.querySelector('ha-card')) {
let searchEles = element.shadowRoot.getElementById("root");
if (!searchEles) {
searchEles = element.shadowRoot.getElementById("card");
}
searchEles = searchEles.childNodes;
for(let i = 0; i < searchEles.length; i++) {
searchEles[i].style.margin = "0px";
searchEles[i].shadowRoot.querySelector('ha-card').style.boxShadow = 'none';
let fn = () => {
if (element.shadowRoot) {
if (!element.shadowRoot.querySelector('ha-card')) {
let searchEles = element.shadowRoot.getElementById("root");
if (!searchEles) {
searchEles = element.shadowRoot.getElementById("card");
}
if(!searchEles) return;
searchEles = searchEles.childNodes;
for(let i = 0; i < searchEles.length; i++) {
searchEles[i].style.margin = "0px";
searchEles[i].shadowRoot.querySelector('ha-card').style.boxShadow = 'none';
}
} else {
element.shadowRoot.querySelector('ha-card').style.boxShadow = 'none';
}
} else {
element.shadowRoot.querySelector('ha-card').style.boxShadow = 'none';
}
};

if(element.updateComplete) {
element.updateComplete.then(fn);
} else {
fn();
}
});
}
Expand Down

0 comments on commit c547223

Please sign in to comment.