Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ha-clickable-list-item with native material 3 components #20920

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions src/components/ha-clickable-list-item.ts

This file was deleted.

25 changes: 11 additions & 14 deletions src/panels/config/hardware/ha-config-hardware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import "@material/mwc-list/mwc-list";
import "@material/mwc-list/mwc-list-item";
import { mdiPower } from "@mdi/js";
import type { ChartOptions } from "chart.js";
import { UnsubscribeFunc } from "home-assistant-js-websocket";
Expand All @@ -13,10 +11,11 @@ import "../../../components/buttons/ha-progress-button";
import "../../../components/chart/ha-chart-base";
import "../../../components/ha-alert";
import "../../../components/ha-card";
import "../../../components/ha-clickable-list-item";
import "../../../components/ha-icon-button";
import "../../../components/ha-icon-next";
import "../../../components/ha-settings-row";
import "../../../components/ha-list-new";
import "../../../components/ha-list-item-new";
import {
ConfigEntry,
subscribeConfigEntries,
Expand Down Expand Up @@ -304,26 +303,24 @@ class HaConfigHardware extends SubscribeMixin(LitElement) {
</div>
${documentationURL
? html`
<mwc-list>
<ha-clickable-list-item
.href=${documentationURL}
openNewTab
twoline
hasMeta
<ha-list-new>
<ha-list-item-new
href=${documentationURL}
target="_blank"
>
<span
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.hardware.documentation"
)}</span
>
<span slot="secondary"
<span slot="supporting-text"
>${this.hass.localize(
"ui.panel.config.hardware.documentation_description"
)}</span
>
<ha-icon-next slot="meta"></ha-icon-next>
</ha-clickable-list-item>
</mwc-list>
<ha-icon-next slot="end"></ha-icon-next>
</ha-list-item-new>
</ha-list-new>
`
: ""}
${boardConfigEntries.length ||
Expand Down
26 changes: 8 additions & 18 deletions src/panels/config/info/ha-config-info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "@material/mwc-list/mwc-list";
import {
mdiBug,
mdiFileDocument,
Expand All @@ -18,7 +17,8 @@ import {
import { customElement, property, state } from "lit/decorators";
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import "../../../components/ha-card";
import "../../../components/ha-clickable-list-item";
import "../../../components/ha-list-new";
import "../../../components/ha-list-item-new";
import "../../../components/ha-logo-svg";
import {
HassioHassOSInfo,
Expand Down Expand Up @@ -163,16 +163,15 @@ class HaConfigInfo extends LitElement {
</ul>
</ha-card>
<ha-card outlined class="pages">
<mwc-list>
<ha-list-new>
${PAGES.map(
(page) => html`
<ha-clickable-list-item
graphic="avatar"
openNewTab
<ha-list-item-new
href=${documentationUrl(this.hass, page.path)}
target="_blank"
>
<div
slot="graphic"
slot="start"
class="icon-background"
.style="background-color: ${page.iconColor}"
>
Expand All @@ -183,10 +182,10 @@ class HaConfigInfo extends LitElement {
`ui.panel.config.info.items.${page.name}`
)}
</span>
</ha-clickable-list-item>
</ha-list-item-new>
`
)}
</mwc-list>
</ha-list-new>
${customUiList.length
? html`
<div class="custom-ui">
Expand Down Expand Up @@ -310,15 +309,6 @@ class HaConfigInfo extends LitElement {
padding: 4px 0;
}

mwc-list {
--mdc-list-side-padding: 16px;
--mdc-list-vertical-padding: 0;
}

ha-clickable-list-item {
height: 64px;
}

ha-svg-icon {
height: 24px;
width: 24px;
Expand Down
12 changes: 6 additions & 6 deletions src/panels/config/integrations/ha-integration-overflow-menu.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { mdiDotsVertical } from "@mdi/js";
import { html, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../components/ha-button-menu";
import "../../../components/ha-clickable-list-item";
import "../../../components/ha-button-menu-new";
import "../../../components/ha-menu-item";
import "../../../components/ha-icon-button";
import type { HomeAssistant } from "../../../types";

Expand All @@ -12,18 +12,18 @@ export class HaIntegrationOverflowMenu extends LitElement {

protected render() {
return html`
<ha-button-menu activatable>
<ha-button-menu-new>
<ha-icon-button
slot="trigger"
.label=${this.hass.localize("ui.common.menu")}
.path=${mdiDotsVertical}
></ha-icon-button>
<ha-clickable-list-item href="/config/application_credentials">
<ha-menu-item href="/config/application_credentials">
${this.hass.localize(
"ui.panel.config.application_credentials.caption"
)}
</ha-clickable-list-item>
</ha-button-menu>
</ha-menu-item>
</ha-button-menu-new>
`;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
RowClickedEvent,
SortingChangedEvent,
} from "../../../../components/data-table/ha-data-table";
import "../../../../components/ha-clickable-list-item";
import "../../../../components/ha-button-menu-new";
import "../../../../components/ha-menu-item";
import "../../../../components/ha-fab";
import "../../../../components/ha-icon";
import "../../../../components/ha-icon-button";
Expand Down Expand Up @@ -311,18 +312,18 @@ export class HaConfigLovelaceDashboards extends LitElement {
>
${this.hass.userData?.showAdvanced
? html`
<ha-button-menu slot="toolbar-icon" activatable>
<ha-button-menu-new slot="toolbar-icon">
<ha-icon-button
slot="trigger"
.label=${this.hass.localize("ui.common.menu")}
.path=${mdiDotsVertical}
></ha-icon-button>
<ha-clickable-list-item href="/config/lovelace/resources">
<ha-menu-item href="/config/lovelace/resources">
${this.hass.localize(
"ui.panel.config.lovelace.resources.caption"
)}
</ha-clickable-list-item>
</ha-button-menu>
</ha-menu-item>
</ha-button-menu-new>
`
: ""}
<ha-fab
Expand Down
35 changes: 10 additions & 25 deletions src/panels/config/repairs/integrations-startup-time.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "@material/mwc-list/mwc-list";
import {
css,
CSSResultGroup,
Expand All @@ -9,7 +8,6 @@ import {
} from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../components/ha-card";
import "../../../components/ha-clickable-list-item";
import {
domainToName,
fetchIntegrationManifests,
Expand All @@ -20,6 +18,8 @@ import {
import type { HomeAssistant } from "../../../types";
import { brandsUrl } from "../../../util/brands-url";
import { documentationUrl } from "../../../util/documentation-url";
import "../../../components/ha-list-new";
import "../../../components/ha-list-item-new";

@customElement("integrations-startup-time")
class IntegrationsStartupTime extends LitElement {
Expand All @@ -45,7 +45,7 @@ class IntegrationsStartupTime extends LitElement {
}

return html`
<mwc-list>
<ha-list-new>
${this._setups?.map((setup) => {
const manifest = this._manifests && this._manifests[setup.domain];
const docLink = manifest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using an optional chain for safer access.

- const manifest = this._manifests && this._manifests[setup.domain];
+ const manifest = this._manifests?.[setup.domain];
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
const manifest = this._manifests && this._manifests[setup.domain];
const manifest = this._manifests?.[setup.domain];
Tools
Biome

[error] 50-50: Change to an optional chain.

Expand All @@ -56,13 +56,7 @@ class IntegrationsStartupTime extends LitElement {

const setupSeconds = setup.seconds?.toFixed(2);
return html`
<ha-clickable-list-item
graphic="avatar"
twoline
hasMeta
openNewTab
href=${docLink}
>
<ha-list-item-new href=${docLink} target="_blank">
<img
alt=""
loading="lazy"
Expand All @@ -74,19 +68,19 @@ class IntegrationsStartupTime extends LitElement {
})}
crossorigin="anonymous"
referrerpolicy="no-referrer"
slot="graphic"
slot="start"
/>
<span>
<span slot="headline">
${domainToName(this.hass.localize, setup.domain, manifest)}
</span>
<span slot="secondary">${setup.domain}</span>
<div slot="meta">
<span slot="supporting-text">${setup.domain}</span>
<div slot="end">
${setupSeconds ? html`${setupSeconds} s` : ""}
</div>
</ha-clickable-list-item>
</ha-list-item-new>
`;
})}
</mwc-list>
</ha-list-new>
`;
}

Expand Down Expand Up @@ -116,20 +110,11 @@ class IntegrationsStartupTime extends LitElement {

static get styles(): CSSResultGroup {
return css`
ha-clickable-list-item {
--mdc-list-item-meta-size: 64px;
--mdc-typography-caption-font-size: 12px;
}
img {
display: block;
max-height: 40px;
max-width: 40px;
}
div[slot="meta"] {
display: flex;
justify-content: center;
align-items: center;
}
`;
}
}
Expand Down
Loading