mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-09 10:26:35 +00:00
Fix accessibility of settings and system navigation (#12845)
This commit is contained in:
parent
be169f9c83
commit
a1bc748bc1
@ -1,11 +1,12 @@
|
|||||||
import "@material/mwc-list/mwc-list";
|
import { ActionDetail } from "@material/mwc-list/mwc-list";
|
||||||
import "@material/mwc-list/mwc-list-item";
|
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
|
import { navigate } from "../common/navigate";
|
||||||
import type { PageNavigation } from "../layouts/hass-tabs-subpage";
|
import type { PageNavigation } from "../layouts/hass-tabs-subpage";
|
||||||
import type { HomeAssistant } from "../types";
|
import type { HomeAssistant } from "../types";
|
||||||
import "./ha-clickable-list-item";
|
|
||||||
import "./ha-icon-next";
|
import "./ha-icon-next";
|
||||||
|
import "./ha-list-item";
|
||||||
import "./ha-svg-icon";
|
import "./ha-svg-icon";
|
||||||
|
|
||||||
@customElement("ha-navigation-list")
|
@customElement("ha-navigation-list")
|
||||||
@ -18,17 +19,22 @@ class HaNavigationList extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public hasSecondary = false;
|
@property({ type: Boolean }) public hasSecondary = false;
|
||||||
|
|
||||||
|
@property() public label?: string;
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<mwc-list>
|
<mwc-list
|
||||||
|
innerRole="menu"
|
||||||
|
itemRoles="menuitem"
|
||||||
|
innerAriaLabel=${ifDefined(this.label)}
|
||||||
|
@action=${this._handleListAction}
|
||||||
|
>
|
||||||
${this.pages.map(
|
${this.pages.map(
|
||||||
(page) => html`
|
(page) => html`
|
||||||
<ha-clickable-list-item
|
<ha-list-item
|
||||||
graphic="avatar"
|
graphic="avatar"
|
||||||
.twoline=${this.hasSecondary}
|
.twoline=${this.hasSecondary}
|
||||||
.hasMeta=${!this.narrow}
|
.hasMeta=${!this.narrow}
|
||||||
@click=${this._entryClicked}
|
|
||||||
href=${page.path}
|
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
slot="graphic"
|
slot="graphic"
|
||||||
@ -44,15 +50,20 @@ class HaNavigationList extends LitElement {
|
|||||||
${!this.narrow
|
${!this.narrow
|
||||||
? html`<ha-icon-next slot="meta"></ha-icon-next>`
|
? html`<ha-icon-next slot="meta"></ha-icon-next>`
|
||||||
: ""}
|
: ""}
|
||||||
</ha-clickable-list-item>
|
</ha-list-item>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
</mwc-list>
|
</mwc-list>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _entryClicked(ev) {
|
private _handleListAction(ev: CustomEvent<ActionDetail>) {
|
||||||
ev.currentTarget.blur();
|
const path = this.pages[ev.detail.index].path;
|
||||||
|
if (path.endsWith("#external-app-configuration")) {
|
||||||
|
this.hass.auth.external!.fireMessage({ type: "config_screen/show" });
|
||||||
|
} else {
|
||||||
|
navigate(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles: CSSResultGroup = css`
|
static styles: CSSResultGroup = css`
|
||||||
@ -75,7 +86,7 @@ class HaNavigationList extends LitElement {
|
|||||||
.icon-background ha-svg-icon {
|
.icon-background ha-svg-icon {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
ha-clickable-list-item {
|
ha-list-item {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: var(--navigation-list-item-title-font-size);
|
font-size: var(--navigation-list-item-title-font-size);
|
||||||
padding: var(--navigation-list-item-padding) 0;
|
padding: var(--navigation-list-item-padding) 0;
|
||||||
|
@ -137,6 +137,9 @@ class HaConfigSystemNavigation extends LitElement {
|
|||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
.pages=${pages}
|
.pages=${pages}
|
||||||
hasSecondary
|
hasSecondary
|
||||||
|
.label=${this.hass.localize(
|
||||||
|
"ui.panel.config.dashboard.system.main"
|
||||||
|
)}
|
||||||
></ha-navigation-list>
|
></ha-navigation-list>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
</ha-config-section>
|
</ha-config-section>
|
||||||
|
@ -60,26 +60,11 @@ class HaConfigNavigation extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
.pages=${pages}
|
.pages=${pages}
|
||||||
@click=${this._entryClicked}
|
.label=${this.hass.localize("panel.config")}
|
||||||
></ha-navigation-list>
|
></ha-navigation-list>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _entryClicked(ev) {
|
|
||||||
const anchor = ev
|
|
||||||
.composedPath()
|
|
||||||
.find((n) => (n as HTMLElement).tagName === "A") as
|
|
||||||
| HTMLAnchorElement
|
|
||||||
| undefined;
|
|
||||||
|
|
||||||
if (anchor?.href?.endsWith("#external-app-configuration")) {
|
|
||||||
ev.preventDefault();
|
|
||||||
this.hass.auth.external!.fireMessage({
|
|
||||||
type: "config_screen/show",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static styles: CSSResultGroup = css`
|
static styles: CSSResultGroup = css`
|
||||||
ha-navigation-list {
|
ha-navigation-list {
|
||||||
--navigation-list-item-title-font-size: 16px;
|
--navigation-list-item-title-font-size: 16px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user