From d3b92408499ceb4e2dd049792b1f9b8becf94886 Mon Sep 17 00:00:00 2001 From: Alexandre Garcia Date: Sun, 20 Jan 2019 21:32:06 -0500 Subject: [PATCH] Remove need for external dependency --- button-card.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/button-card.js b/button-card.js index 94a341b..7ed3185 100644 --- a/button-card.js +++ b/button-card.js @@ -1,6 +1,5 @@ -import { - LitElement, html, -} from 'https://unpkg-gcp.firebaseapp.com/@polymer/lit-element@0.5.2/lit-element.js?module'; +var LitElement = LitElement || Object.getPrototypeOf(customElements.get("hui-error-entity-row")); +var html = LitElement.prototype.html; class ButtonCard extends LitElement { static get properties() { @@ -10,18 +9,18 @@ class ButtonCard extends LitElement { }; } - _render({ hass, config }) { - const state = hass.states[config.entity]; - switch (config.color_type) { + render() { + const state = this.__hass.states[this.config.entity]; + switch (this.config.color_type) { case 'blank-card': - return this.blankCardColoredHtml(state, config); + return this.blankCardColoredHtml(state, this.config); case 'label-card': - return this.labelCardColoredHtml(state, config); + return this.labelCardColoredHtml(state, this.config); case 'card': - return this.cardColoredHtml(state, config); + return this.cardColoredHtml(state, this.config); case 'icon': default: - return this.iconColoredHtml(state, config); + return this.iconColoredHtml(state, this.config); } } @@ -102,7 +101,7 @@ class ButtonCard extends LitElement { const fontColor = this.getFontColorBasedOnBackgroundColor(color); return html` - +
${config.icon ? html`` : ''} @@ -165,7 +164,7 @@ class ButtonCard extends LitElement { text-align: center; } - +
${config.icon ? html`` : ''} @@ -181,8 +180,9 @@ class ButtonCard extends LitElement { // if (!config.entity) { // throw new Error('You need to define entity'); // } - this.config = {...config}; + this.config = config; this.config.color = config.color ? config.color : 'var(--primary-text-color)'; + this.config.state = config.state; this.config.size = config.size ? config.size : '40%'; let cardStyle = ''; if (config.style) {