Use card-tools. Should fix the problems that sometimes nesting with card-modder doesn't work.

This commit is contained in:
Thomas Lovén 2018-12-12 12:34:06 +01:00
parent 7db164aac9
commit bd7e5a91c1
2 changed files with 6 additions and 12 deletions

View File

@ -16,6 +16,8 @@ Get more control over the placement of cards
## Instructions
This card requires [card-tools](https://github.com/thomasloven/lovelace-card-tools) to be installed.
This card takes other cards and place them in different layouts.
The card works best if used in a view with `panel: true`.

View File

@ -26,18 +26,10 @@ class LayoutCard extends Polymer.Element {
`;
}
makeCard(config) {
let tag = config.type;
if(tag.startsWith("custom:"))
tag = tag.substr(7);
else
tag = `hui-${tag}-card`;
let card = document.createElement(tag);
card.setConfig(config);
return card;
}
setConfig(config) {
if(!window.cardTools) throw new Error(`Can't find card-tools. See https://github.com/thomasloven/lovelace-card-tools`);
window.cardTools.checkVersion(0.1);
this.config = config;
this.colnum = 0;
@ -83,7 +75,7 @@ class LayoutCard extends Polymer.Element {
this._cards = this.config.cards.map((c) => {
if (typeof c === 'string') return c;
let el = this.makeCard(c);
let el = cardTools.createCard(c);
if (this._hass) el.hass = this._hass;
return el;
});