Add beautiful transitions!
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
"home-assistant-js-websocket": "^5.11.1",
|
"home-assistant-js-websocket": "^5.11.1",
|
||||||
"lit-element": "^2.5.1",
|
"lit-element": "^2.5.1",
|
||||||
"lit-html": "^1.4.1",
|
"lit-html": "^1.4.1",
|
||||||
|
"lit-transition": "^1.3.2",
|
||||||
"zod": "^3.7.1"
|
"zod": "^3.7.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
+18
-19
@@ -18,7 +18,9 @@ import {
|
|||||||
unsafeCSS,
|
unsafeCSS,
|
||||||
} from 'lit-element';
|
} from 'lit-element';
|
||||||
|
|
||||||
|
import { NodePart } from "lit-html";
|
||||||
import { until } from 'lit-html/directives/until.js';
|
import { until } from 'lit-html/directives/until.js';
|
||||||
|
import { transition } from 'lit-transition';
|
||||||
import {
|
import {
|
||||||
HomeAssistant,
|
HomeAssistant,
|
||||||
fireEvent,
|
fireEvent,
|
||||||
@@ -71,25 +73,17 @@ type FrigateCardMenuCallback = (name: string) => any;
|
|||||||
// A menu for the Frigate card.
|
// A menu for the Frigate card.
|
||||||
@customElement('frigate-card-menu')
|
@customElement('frigate-card-menu')
|
||||||
export class FrigateCardMenu extends LitElement {
|
export class FrigateCardMenu extends LitElement {
|
||||||
constructor() {
|
@property({ attribute: false })
|
||||||
super();
|
protected expand = false;
|
||||||
this.expand = false;
|
|
||||||
this.motionEntity = null;
|
|
||||||
this.hass = null;
|
|
||||||
this.actionCallback = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
protected expand: boolean;
|
protected motionEntity: string | null = null;
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
protected motionEntity: string | null;
|
protected hass: HomeAssistant | null = null;
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
protected hass: HomeAssistant | null;
|
protected actionCallback: FrigateCardMenuCallback | null = null;
|
||||||
|
|
||||||
@property({ attribute: false })
|
|
||||||
protected actionCallback: FrigateCardMenuCallback | null;
|
|
||||||
|
|
||||||
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
@@ -128,12 +122,13 @@ export class FrigateCardMenu extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render the menu.
|
// Render the menu.
|
||||||
protected render(): TemplateResult | void {
|
protected render(): TemplateResult | void | ((part: NodePart) => Promise<void>) {
|
||||||
if (!this.expand) {
|
if (!this.expand) {
|
||||||
return html`
|
return transition(
|
||||||
|
html`
|
||||||
<div class="frigate-card-menu">
|
<div class="frigate-card-menu">
|
||||||
${this._renderFrigateButton()}
|
${this._renderFrigateButton()}
|
||||||
</div>`;
|
</div>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let motionIcon: string | null = null;
|
let motionIcon: string | null = null;
|
||||||
@@ -141,8 +136,11 @@ export class FrigateCardMenu extends LitElement {
|
|||||||
motionIcon = this.hass.states[this.motionEntity]?.state == "on" ? "mdi:motion-sensor" : "mdi:walk";
|
motionIcon = this.hass.states[this.motionEntity]?.state == "on" ? "mdi:motion-sensor" : "mdi:walk";
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return transition(
|
||||||
<div class="frigate-card-menu-expanded">
|
html`
|
||||||
|
<div
|
||||||
|
class="frigate-card-menu-expanded"
|
||||||
|
>
|
||||||
${this._renderFrigateButton()}
|
${this._renderFrigateButton()}
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
class="button"
|
class="button"
|
||||||
@@ -192,7 +190,8 @@ export class FrigateCardMenu extends LitElement {
|
|||||||
></ha-icon-button>`
|
></ha-icon-button>`
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return compiled CSS styles (thus safe to use with unsafeCSS).
|
// Return compiled CSS styles (thus safe to use with unsafeCSS).
|
||||||
|
|||||||
Reference in New Issue
Block a user