Add animation for locking and unlocking state (#17053)

This commit is contained in:
Paul Bottein 2023-06-27 17:23:46 +02:00 committed by GitHub
parent 381c9f97d6
commit 48b6c2a925
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ import {
TemplateResult, TemplateResult,
} from "lit"; } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { styleMap } from "lit/directives/style-map"; import { styleMap } from "lit/directives/style-map";
import { domainIcon } from "../../../../common/entity/domain_icon"; import { domainIcon } from "../../../../common/entity/domain_icon";
import { stateColorCss } from "../../../../common/entity/state_color"; import { stateColorCss } from "../../../../common/entity/state_color";
@ -136,8 +137,6 @@ export class HaMoreInfoLockToggle extends LitElement {
return html` return html`
<ha-control-switch <ha-control-switch
.pathOn=${onIcon}
.pathOff=${offIcon}
vertical vertical
reversed reversed
.checked=${this._isOn} .checked=${this._isOn}
@ -149,12 +148,33 @@ export class HaMoreInfoLockToggle extends LitElement {
})} })}
.disabled=${this.stateObj.state === UNAVAILABLE} .disabled=${this.stateObj.state === UNAVAILABLE}
> >
<ha-svg-icon
slot="icon-on"
.path=${onIcon}
class=${classMap({ pulse: locking })}
></ha-svg-icon>
<ha-svg-icon
slot="icon-off"
.path=${offIcon}
class=${classMap({ pulse: unlocking })}
></ha-svg-icon>
</ha-control-switch> </ha-control-switch>
`; `;
} }
static get styles(): CSSResultGroup { static get styles(): CSSResultGroup {
return css` return css`
@keyframes pulse {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
ha-control-switch { ha-control-switch {
height: 45vh; height: 45vh;
max-height: 320px; max-height: 320px;
@ -164,6 +184,9 @@ export class HaMoreInfoLockToggle extends LitElement {
--control-switch-padding: 6px; --control-switch-padding: 6px;
--mdc-icon-size: 24px; --mdc-icon-size: 24px;
} }
.pulse {
animation: pulse 1s infinite;
}
.buttons { .buttons {
display: flex; display: flex;
flex-direction: column; flex-direction: column;