Skip to content

Commit

Permalink
Update to LitElement
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider committed Mar 19, 2020
1 parent d1ad677 commit 8f8863d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
9 changes: 9 additions & 0 deletions hooks/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -euo pipefail

VERSION=$(jq -r .version package.json)

cat <<EOF >src/version-const.ts
export const CARD_VERSION = '${VERSION}';
EOF
2 changes: 2 additions & 0 deletions hooks/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ set -euo pipefail
echo "Pre-Commit hooks running..."

npm run build
npm run update-version
git add src/version-const.ts
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"rollup": "rollup -c",
"babel": "babel dist/decluttering-card.js --out-file dist/decluttering-card.js",
"lint": "eslint src/decluttering-card.ts",
"watch": "rollup -c rollup.debug.config.js --watch"
"watch": "rollup -c rollup.debug.config.js --watch",
"update-version": "./hooks/bump-version.sh"
},
"repository": {
"type": "git",
Expand Down
16 changes: 11 additions & 5 deletions src/decluttering-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ import {
import { DeclutteringCardConfig, TemplateConfig } from './types';
import deepReplace from './deep-replace';
import getLovelaceCast from './getLovelaceCast';
import { CARD_VERSION } from './version-const';

const HELPERS = (window as any).loadCardHelpers ? (window as any).loadCardHelpers() : undefined;

console.info(
`%c DECLUTTERING-CARD \n%c Version ${CARD_VERSION} `,
'color: orange; font-weight: bold; background: black',
'color: white; font-weight: bold; background: dimgray',
);

@customElement('decluttering-card')
class DeclutteringCard extends LitElement {
@property() private _card?: any;
@property() protected _card?: any;

@property() private _hass?: HomeAssistant;

Expand Down Expand Up @@ -47,6 +54,7 @@ class DeclutteringCard extends LitElement {
this._config = deepReplace(config.variables, templateConfig);
this._createCard(this._config).then((card) => {
this._card = card;
return this._card;
});
}

Expand Down Expand Up @@ -74,9 +82,7 @@ class DeclutteringCard extends LitElement {
ev.stopPropagation();
this._rebuildCard(element, config);
},
{
once: true,
},
{ once: true },
);
return element;
}
Expand All @@ -87,7 +93,7 @@ class DeclutteringCard extends LitElement {
}

public getCardSize(): number {
return typeof this._card.getCardSize === 'function'
return this._card && typeof this._card.getCardSize === 'function'
? this._card.getCardSize() : 1;
}
}
1 change: 1 addition & 0 deletions src/version-const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const CARD_VERSION = '0.4.0';

0 comments on commit 8f8863d

Please sign in to comment.