mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Add keyboard support to onboarding links (#17816)
This commit is contained in:
parent
5d5894cae6
commit
5e1583f925
@ -17,6 +17,8 @@ class OnboardingWelcomeLink extends LitElement {
|
|||||||
|
|
||||||
@property() public iconPath!: string;
|
@property() public iconPath!: string;
|
||||||
|
|
||||||
|
@property({ attribute: true, type: Boolean }) public noninteractive?: boolean;
|
||||||
|
|
||||||
@queryAsync("mwc-ripple") private _ripple!: Promise<Ripple | null>;
|
@queryAsync("mwc-ripple") private _ripple!: Promise<Ripple | null>;
|
||||||
|
|
||||||
@state() private _shouldRenderRipple = false;
|
@state() private _shouldRenderRipple = false;
|
||||||
@ -24,6 +26,7 @@ class OnboardingWelcomeLink extends LitElement {
|
|||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<ha-card
|
<ha-card
|
||||||
|
.tabIndex=${this.noninteractive ? "-1" : "0"}
|
||||||
@focus=${this.handleRippleFocus}
|
@focus=${this.handleRippleFocus}
|
||||||
@blur=${this.handleRippleBlur}
|
@blur=${this.handleRippleBlur}
|
||||||
@mousedown=${this.handleRippleActivate}
|
@mousedown=${this.handleRippleActivate}
|
||||||
@ -33,6 +36,7 @@ class OnboardingWelcomeLink extends LitElement {
|
|||||||
@touchstart=${this.handleRippleActivate}
|
@touchstart=${this.handleRippleActivate}
|
||||||
@touchend=${this.handleRippleDeactivate}
|
@touchend=${this.handleRippleDeactivate}
|
||||||
@touchcancel=${this.handleRippleDeactivate}
|
@touchcancel=${this.handleRippleDeactivate}
|
||||||
|
@keydown=${this._handleKeyDown}
|
||||||
>
|
>
|
||||||
<ha-svg-icon .path=${this.iconPath}></ha-svg-icon>
|
<ha-svg-icon .path=${this.iconPath}></ha-svg-icon>
|
||||||
${this.label}
|
${this.label}
|
||||||
@ -41,6 +45,12 @@ class OnboardingWelcomeLink extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _handleKeyDown(ev: KeyboardEvent): void {
|
||||||
|
if (ev.key === "Enter" || ev.key === " ") {
|
||||||
|
(ev.target as HTMLElement).click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _rippleHandlers: RippleHandlers = new RippleHandlers(() => {
|
private _rippleHandlers: RippleHandlers = new RippleHandlers(() => {
|
||||||
this._shouldRenderRipple = true;
|
this._shouldRenderRipple = true;
|
||||||
return this._ripple;
|
return this._ripple;
|
||||||
|
@ -21,6 +21,7 @@ class OnboardingWelcomeLinks extends LitElement {
|
|||||||
href="https://www.home-assistant.io/blog/2016/01/19/perfect-home-automation/"
|
href="https://www.home-assistant.io/blog/2016/01/19/perfect-home-automation/"
|
||||||
>
|
>
|
||||||
<onboarding-welcome-link
|
<onboarding-welcome-link
|
||||||
|
noninteractive
|
||||||
.iconPath=${mdiFileDocument}
|
.iconPath=${mdiFileDocument}
|
||||||
.label=${this.localize("ui.panel.page-onboarding.welcome.vision")}
|
.label=${this.localize("ui.panel.page-onboarding.welcome.vision")}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user