Add support for card-mod styling like any other entities row

This commit is contained in:
2020-01-08 12:24:51 +01:00
parent 3b1eca2c90
commit 8fce47cc02
2 changed files with 20 additions and 2 deletions

View File

@@ -49,16 +49,34 @@ class FoldEntityRow extends LitElement {
this.toggle(ev);
});
this.head.setAttribute('head', 'head');
this.applyStyle(this.head, head);
this.rows = items.map((i) => {
const row = createEntityRow(fix_config(i));
row.hass = hass();
if(this.hasMoreInfo(i))
row.classList.add("state-card-dialog");
this.applyStyle(row, fix_config(i));
return row;
});
}
async applyStyle(root, config) {
if(!config.style) return;
await customElements.whenDefined("card-mod");
if(root.updateComplete)
await root.updateComplete;
const cm = document.createElement("card-mod");
cm.template = {
template: config.style,
variables: {config},
entity_ids: config.entity_ids,
};
root.shadowRoot.appendChild(cm);
}
toggle(ev) {
if(ev)
ev.stopPropagation();