mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26: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({ attribute: true, type: Boolean }) public noninteractive?: boolean;
|
||||
|
||||
@queryAsync("mwc-ripple") private _ripple!: Promise<Ripple | null>;
|
||||
|
||||
@state() private _shouldRenderRipple = false;
|
||||
@ -24,6 +26,7 @@ class OnboardingWelcomeLink extends LitElement {
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<ha-card
|
||||
.tabIndex=${this.noninteractive ? "-1" : "0"}
|
||||
@focus=${this.handleRippleFocus}
|
||||
@blur=${this.handleRippleBlur}
|
||||
@mousedown=${this.handleRippleActivate}
|
||||
@ -33,6 +36,7 @@ class OnboardingWelcomeLink extends LitElement {
|
||||
@touchstart=${this.handleRippleActivate}
|
||||
@touchend=${this.handleRippleDeactivate}
|
||||
@touchcancel=${this.handleRippleDeactivate}
|
||||
@keydown=${this._handleKeyDown}
|
||||
>
|
||||
<ha-svg-icon .path=${this.iconPath}></ha-svg-icon>
|
||||
${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(() => {
|
||||
this._shouldRenderRipple = true;
|
||||
return this._ripple;
|
||||
|
@ -21,6 +21,7 @@ class OnboardingWelcomeLinks extends LitElement {
|
||||
href="https://www.home-assistant.io/blog/2016/01/19/perfect-home-automation/"
|
||||
>
|
||||
<onboarding-welcome-link
|
||||
noninteractive
|
||||
.iconPath=${mdiFileDocument}
|
||||
.label=${this.localize("ui.panel.page-onboarding.welcome.vision")}
|
||||
>
|
||||
|
Loading…
x
Reference in New Issue
Block a user