Skip to content

Commit

Permalink
add some comments/links about Lit
Browse files Browse the repository at this point in the history
  • Loading branch information
iantrich committed Nov 17, 2020
1 parent a102dd0 commit ed1b89f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "boilerplate-card",
"version": "1.3.1",
"version": "1.3.2",
"description": "Lovelace boilerplate-card",
"keywords": [
"home-assistant",
Expand Down
11 changes: 8 additions & 3 deletions src/boilerplate-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ import {
handleAction,
LovelaceCardEditor,
getLovelace,
} from 'custom-card-helpers';
} from 'custom-card-helpers'; // This is a community maintained npm module with common helper functions/types

import './editor';

import { BoilerplateCardConfig } from './types';
import type { BoilerplateCardConfig } from './types';
import { actionHandler } from './action-handler-directive';
import { CARD_VERSION } from './const';

import { localize } from './localize/localize';

/* eslint no-console: 0 */
Expand All @@ -35,6 +34,7 @@ console.info(
'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.push({
type: 'boilerplate-card',
Expand All @@ -54,9 +54,11 @@ export class BoilerplateCard extends LitElement {
}

// 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;
@internalProperty() private config!: BoilerplateCardConfig;

// https://lit-element.polymer-project.org/guide/properties#accessors-custom
public setConfig(config: BoilerplateCardConfig): void {
// TODO Check for required fields and that they are of the proper format
if (!config) {
Expand All @@ -73,6 +75,7 @@ export class BoilerplateCard extends LitElement {
};
}

// https://lit-element.polymer-project.org/guide/lifecycle#shouldupdate
protected shouldUpdate(changedProps: PropertyValues): boolean {
if (!this.config) {
return false;
Expand All @@ -81,6 +84,7 @@ export class BoilerplateCard extends LitElement {
return hasConfigOrEntityChanged(this, changedProps, false);
}

// https://lit-element.polymer-project.org/guide/templates
protected render(): TemplateResult | void {
// TODO Check for stateObj or other necessary things and render a warning if missing
if (this.config.show_warning) {
Expand Down Expand Up @@ -130,6 +134,7 @@ export class BoilerplateCard extends LitElement {
`;
}

// https://lit-element.polymer-project.org/guide/styles
static get styles(): CSSResult {
return css``;
}
Expand Down
2 changes: 1 addition & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const CARD_VERSION = '1.3.1';
export const CARD_VERSION = '1.3.2';

0 comments on commit ed1b89f

Please sign in to comment.