add some comments/links about Lit

This commit is contained in:
Ian Richardson
2020-11-16 20:40:25 -06:00
parent a102dd0d4f
commit ed1b89f2d3
3 changed files with 10 additions and 5 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "boilerplate-card", "name": "boilerplate-card",
"version": "1.3.1", "version": "1.3.2",
"description": "Lovelace boilerplate-card", "description": "Lovelace boilerplate-card",
"keywords": [ "keywords": [
"home-assistant", "home-assistant",
+8 -3
View File
@@ -18,14 +18,13 @@ import {
handleAction, handleAction,
LovelaceCardEditor, LovelaceCardEditor,
getLovelace, getLovelace,
} from 'custom-card-helpers'; } from 'custom-card-helpers'; // This is a community maintained npm module with common helper functions/types
import './editor'; import './editor';
import { BoilerplateCardConfig } from './types'; import type { BoilerplateCardConfig } from './types';
import { actionHandler } from './action-handler-directive'; import { actionHandler } from './action-handler-directive';
import { CARD_VERSION } from './const'; import { CARD_VERSION } from './const';
import { localize } from './localize/localize'; import { localize } from './localize/localize';
/* eslint no-console: 0 */ /* eslint no-console: 0 */
@@ -35,6 +34,7 @@ console.info(
'color: white; font-weight: bold; background: dimgray', 'color: white; font-weight: bold; background: dimgray',
); );
// This puts your card into the UI card picker dialog
(window as any).customCards = (window as any).customCards || []; (window as any).customCards = (window as any).customCards || [];
(window as any).customCards.push({ (window as any).customCards.push({
type: 'boilerplate-card', type: 'boilerplate-card',
@@ -54,9 +54,11 @@ export class BoilerplateCard extends LitElement {
} }
// TODO Add any properities that should cause your element to re-render here // TODO Add any properities that should cause your element to re-render here
// https://lit-element.polymer-project.org/guide/properties
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@internalProperty() private config!: BoilerplateCardConfig; @internalProperty() private config!: BoilerplateCardConfig;
// https://lit-element.polymer-project.org/guide/properties#accessors-custom
public setConfig(config: BoilerplateCardConfig): void { public setConfig(config: BoilerplateCardConfig): void {
// TODO Check for required fields and that they are of the proper format // TODO Check for required fields and that they are of the proper format
if (!config) { if (!config) {
@@ -73,6 +75,7 @@ export class BoilerplateCard extends LitElement {
}; };
} }
// https://lit-element.polymer-project.org/guide/lifecycle#shouldupdate
protected shouldUpdate(changedProps: PropertyValues): boolean { protected shouldUpdate(changedProps: PropertyValues): boolean {
if (!this.config) { if (!this.config) {
return false; return false;
@@ -81,6 +84,7 @@ export class BoilerplateCard extends LitElement {
return hasConfigOrEntityChanged(this, changedProps, false); return hasConfigOrEntityChanged(this, changedProps, false);
} }
// https://lit-element.polymer-project.org/guide/templates
protected render(): TemplateResult | void { protected render(): TemplateResult | void {
// TODO Check for stateObj or other necessary things and render a warning if missing // TODO Check for stateObj or other necessary things and render a warning if missing
if (this.config.show_warning) { if (this.config.show_warning) {
@@ -130,6 +134,7 @@ export class BoilerplateCard extends LitElement {
`; `;
} }
// https://lit-element.polymer-project.org/guide/styles
static get styles(): CSSResult { static get styles(): CSSResult {
return css``; return css``;
} }
+1 -1
View File
@@ -1 +1 @@
export const CARD_VERSION = '1.3.1'; export const CARD_VERSION = '1.3.2';