Add card_options. Make compatible with legacy card-modder

This commit is contained in:
2019-11-11 21:03:02 +01:00
parent 8eeea0e700
commit 49e70438ff
3 changed files with 18 additions and 7 deletions

View File

@@ -61,7 +61,7 @@ class LayoutCard extends LitElement {
if(c === "break")
return null;
const el = document.createElement("card-maker");
el.config = c;
el.config = {...c, ...this._config.card_options};
el.hass = hass();
// Cards are initially placed in the staging area
// That places them in the DOM and lets us read their getCardSize() function
@@ -132,7 +132,8 @@ class LayoutCard extends LitElement {
return Math.max.apply(Math, this.columns.map((c) => c.length));
}
isPanel() {
_isPanel() {
if(this.isPanel) return true;
let el = this.parentElement;
let steps = 10;
while(steps--) {
@@ -148,7 +149,7 @@ class LayoutCard extends LitElement {
<div id="columns"
class="
${this._config.rtl ? "rtl": " "}
${this.isPanel() ? "panel": " "}
${this._isPanel() ? "panel": " "}
"
style="
${this._config.justify_content ? `justify-content: ${this._config.justify_content};` : ''}
@@ -206,6 +207,11 @@ class LayoutCard extends LitElement {
`;
}
// Compatibility with legacy card-modder
get _cardModder() {
return {target: this};
}
}
customElements.define("layout-card", LayoutCard);