Version 2.0!

This commit is contained in:
2019-11-05 00:28:13 +01:00
parent bff8a650bc
commit fd2e449001
21 changed files with 4875 additions and 619 deletions

63
src/card-maker.js Normal file
View File

@@ -0,0 +1,63 @@
import { LitElement, html } from "./lit-element.js";
import { createCard, createEntityRow, createElement } from "./lovelace-element.js";
import { provideHass } from "./hass.js";
class ThingMaker extends LitElement {
static get properties() {
return {
'hass': {},
'config': {},
'noHass': {type: Boolean },
};
}
setConfig(config) {
this._config = config;
if(!this.el)
this.el = this.create(config);
else
this.el.setConfig(config);
if(this._hass) this.el.hass = this._hass;
if(this.noHass) provideHass(this);
}
set config(config) {
this.setConfig(config);
}
set hass(hass) {
this._hass = hass;
if(this.el) this.el.hass = hass;
}
createRenderRoot() {
return this;
}
render() {
return html`${this.el}`;
}
}
if(!customElements.get("card-maker")) {
class CardMaker extends ThingMaker {
create(config) {
return createCard(config);
}
}
customElements.define("card-maker", CardMaker);
}
if(!customElements.get("element-maker")) {
class ElementMaker extends ThingMaker {
create(config) {
return createElement(config);
}
}
customElements.define("element-maker", ElementMaker);
}
if(!customElements.get("entity-row-maker")) {
class EntityRowMaker extends ThingMaker {
create(config) {
return createEntityRow(config);
}
}
customElements.define("entity-row-maker", EntityRowMaker);
}