Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8f8863d

Browse files
committedMar 19, 2020
Update to LitElement
1 parent d1ad677 commit 8f8863d

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed
 

‎hooks/bump-version.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
VERSION=$(jq -r .version package.json)
6+
7+
cat <<EOF >src/version-const.ts
8+
export const CARD_VERSION = '${VERSION}';
9+
EOF

‎hooks/pre-commit.sh

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ set -euo pipefail
55
echo "Pre-Commit hooks running..."
66

77
npm run build
8+
npm run update-version
9+
git add src/version-const.ts

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"rollup": "rollup -c",
1313
"babel": "babel dist/decluttering-card.js --out-file dist/decluttering-card.js",
1414
"lint": "eslint src/decluttering-card.ts",
15-
"watch": "rollup -c rollup.debug.config.js --watch"
15+
"watch": "rollup -c rollup.debug.config.js --watch",
16+
"update-version": "./hooks/bump-version.sh"
1617
},
1718
"repository": {
1819
"type": "git",

‎src/decluttering-card.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ import {
1414
import { DeclutteringCardConfig, TemplateConfig } from './types';
1515
import deepReplace from './deep-replace';
1616
import getLovelaceCast from './getLovelaceCast';
17+
import { CARD_VERSION } from './version-const';
1718

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

21+
console.info(
22+
`%c DECLUTTERING-CARD \n%c Version ${CARD_VERSION} `,
23+
'color: orange; font-weight: bold; background: black',
24+
'color: white; font-weight: bold; background: dimgray',
25+
);
26+
2027
@customElement('decluttering-card')
2128
class DeclutteringCard extends LitElement {
22-
@property() private _card?: any;
29+
@property() protected _card?: any;
2330

2431
@property() private _hass?: HomeAssistant;
2532

@@ -47,6 +54,7 @@ class DeclutteringCard extends LitElement {
4754
this._config = deepReplace(config.variables, templateConfig);
4855
this._createCard(this._config).then((card) => {
4956
this._card = card;
57+
return this._card;
5058
});
5159
}
5260

@@ -74,9 +82,7 @@ class DeclutteringCard extends LitElement {
7482
ev.stopPropagation();
7583
this._rebuildCard(element, config);
7684
},
77-
{
78-
once: true,
79-
},
85+
{ once: true },
8086
);
8187
return element;
8288
}
@@ -87,7 +93,7 @@ class DeclutteringCard extends LitElement {
8793
}
8894

8995
public getCardSize(): number {
90-
return typeof this._card.getCardSize === 'function'
96+
return this._card && typeof this._card.getCardSize === 'function'
9197
? this._card.getCardSize() : 1;
9298
}
9399
}

‎src/version-const.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const CARD_VERSION = '0.4.0';

0 commit comments

Comments
 (0)
Please sign in to comment.