Skip to content

Commit

Permalink
Merge pull request #33 from wassy92x/30-deprecation-lit-element
Browse files Browse the repository at this point in the history
Updated lit-element to lit. Fixes issue #30
  • Loading branch information
wassy92x authored Apr 27, 2023
2 parents 829c094 + 12bc542 commit 2a0f966
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lovelace-digital-clock",
"version": "1.2.3",
"version": "1.2.4",
"description": "Home Assistant Digital Clock",
"keywords": [
"home-assistant",
Expand All @@ -16,7 +16,7 @@
"license": "MIT",
"dependencies": {
"custom-card-helpers": "^1.9.0",
"lit-element": "^3.3.1",
"lit": "^2.7.3",
"luxon": "^3.3.0"
},
"devDependencies": {
Expand Down
24 changes: 8 additions & 16 deletions src/DigitalClock.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import {
LitElement,
html,
customElement,
CSSResult,
TemplateResult,
css,
PropertyValues,
state, property,
} from 'lit-element';
import {css, CSSResult, html, LitElement, PropertyValues, TemplateResult} from 'lit';
import {customElement, property, state} from 'lit/decorators';
import {DateTime} from 'luxon';
import {HomeAssistant} from 'custom-card-helpers';

Expand Down Expand Up @@ -40,7 +32,7 @@ export class DigitalClock extends LitElement {
private _intervalId?: number;

public setConfig(config: IDigitalClockConfig): void {
this._config = { ...config };
this._config = {...config};
if (this._config.timeFormat)
this._config.firstLineFormat = this._config.timeFormat;
if (this._config.dateFormat)
Expand Down Expand Up @@ -114,12 +106,12 @@ export class DigitalClock extends LitElement {
if (typeof this._config?.firstLineFormat === 'string')
firstLine = dateTime.toFormat(this._config.firstLineFormat);
else
firstLine = dateTime.toLocaleString(this._config?.firstLineFormat ?? { hour: '2-digit', minute: '2-digit' });
firstLine = dateTime.toLocaleString(this._config?.firstLineFormat ?? {hour: '2-digit', minute: '2-digit'});

if (typeof this._config?.secondLineFormat === 'string')
secondLine = dateTime.toFormat(this._config.secondLineFormat);
else
secondLine = dateTime.toLocaleString(this._config?.secondLineFormat ?? { weekday: 'short', day: '2-digit', month: 'short' });
secondLine = dateTime.toLocaleString(this._config?.secondLineFormat ?? {weekday: 'short', day: '2-digit', month: 'short'});

if (firstLine !== this._firstLine)
this._firstLine = firstLine;
Expand Down Expand Up @@ -148,16 +140,16 @@ export class DigitalClock extends LitElement {
font-weight: bold;
padding: 8px 0;
}
ha-card > span {
display: block;
}
.first-line {
font-size: 2.8em;
line-height: 1em;
}
.second-line {
font-size: 1.6em;
line-height: 1em;
Expand Down
11 changes: 10 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ levn@^0.3.0, levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"

lit-element@^3.3.0, lit-element@^3.3.1:
lit-element@^3.3.0:
version "3.3.1"
resolved "https://registry.yarnpkg.com/lit-element/-/lit-element-3.3.1.tgz#9dcb950b1fadf156dacf3ded8d7d51a8cf16a966"
integrity sha512-Gl+2409uXWbf7n6cCl7Kzasm7zjT9xmdwi2BhLNi70sRKAgRkqueDu5mSIH3hPYMM0/vqBCdPXod3NbGkRA2ww==
Expand All @@ -1613,6 +1613,15 @@ lit@^2.1.1:
lit-element "^3.3.0"
lit-html "^2.7.0"

lit@^2.7.3:
version "2.7.3"
resolved "https://registry.yarnpkg.com/lit/-/lit-2.7.3.tgz#7f7920dbaba12828d359ca3439cd6f73619061da"
integrity sha512-0a+u+vVbmgSfPu+fyvqjMPBX0Kwbyj9QOv9MbQFZhWGlV2cyk3lEwgfUQgYN+i/lx++1Z3wZknSIp3QCKxHLyg==
dependencies:
"@lit/reactive-element" "^1.6.0"
lit-element "^3.3.0"
lit-html "^2.7.0"

locate-path@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e"
Expand Down

0 comments on commit 2a0f966

Please sign in to comment.