1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-02-15 07:25:54 +00:00

Remove ha-divider and replace with wa-divider (#29609)

* Replace ha-divider with wa-divider in onboarding and dashboard components

* Refactor styles in onboarding-welcome component for consistency and responsiveness
This commit is contained in:
Wendelin
2026-02-12 19:03:28 +01:00
committed by GitHub
parent 1b3ea3d55d
commit 67fb7f61c2
3 changed files with 42 additions and 70 deletions

View File

@@ -1,50 +0,0 @@
import { css, html, LitElement, nothing } from "lit";
import { ifDefined } from "lit/directives/if-defined";
import { customElement, property } from "lit/decorators";
@customElement("ha-divider")
export class HaMdDivider extends LitElement {
@property() public label?: string;
public render() {
return html`
<div
role=${ifDefined(this.label ? "separator" : undefined)}
aria-label=${ifDefined(this.label)}
>
<span class="line"></span>
${this.label
? html`
<span class="label">${this.label}</span>
<span class="line"></span>
`
: nothing}
</div>
`;
}
static styles = css`
:host {
width: var(--ha-divider-width, 100%);
}
div {
display: flex;
align-items: center;
justify-content: center;
}
.label {
padding: var(--ha-divider-label-padding, 0 16px);
}
.line {
flex: 1;
background-color: var(--divider-color);
height: var(--ha-divider-line-height, 1px);
}
`;
}
declare global {
interface HTMLElementTagNameMap {
"ha-divider": HaMdDivider;
}
}

View File

@@ -1,15 +1,15 @@
import "@home-assistant/webawesome/dist/components/divider/divider";
import type { CSSResultGroup, TemplateResult } from "lit"; import type { CSSResultGroup, TemplateResult } from "lit";
import { LitElement, css, html } from "lit"; import { LitElement, css, html } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";
import type { LocalizeFunc } from "../common/translations/localize";
import type { HomeAssistant } from "../types";
import { onBoardingStyles } from "./styles";
import { fireEvent } from "../common/dom/fire_event"; import { fireEvent } from "../common/dom/fire_event";
import type { LocalizeFunc } from "../common/translations/localize";
import "../components/ha-button"; import "../components/ha-button";
import "../components/ha-divider"; import "../components/ha-icon-button-next";
import "../components/ha-md-list"; import "../components/ha-md-list";
import "../components/ha-md-list-item"; import "../components/ha-md-list-item";
import "../components/ha-icon-button-next"; import type { HomeAssistant } from "../types";
import { onBoardingStyles } from "./styles";
@customElement("onboarding-welcome") @customElement("onboarding-welcome")
class OnboardingWelcome extends LitElement { class OnboardingWelcome extends LitElement {
@@ -26,9 +26,16 @@ class OnboardingWelcome extends LitElement {
${this.localize("ui.panel.page-onboarding.welcome.start")} ${this.localize("ui.panel.page-onboarding.welcome.start")}
</ha-button> </ha-button>
<ha-divider <div class="divider">
.label=${this.localize("ui.panel.page-onboarding.welcome.or_restore")} <wa-divider></wa-divider>
></ha-divider> <div>
<span
>${this.localize(
"ui.panel.page-onboarding.welcome.or_restore"
)}</span
>
</div>
</div>
<ha-md-list> <ha-md-list>
<ha-md-list-item type="button" @click=${this._restoreBackupUpload}> <ha-md-list-item type="button" @click=${this._restoreBackupUpload}>
@@ -83,24 +90,39 @@ class OnboardingWelcome extends LitElement {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: flex-start; align-items: flex-start;
margin-bottom: -16px; margin-bottom: calc(var(--ha-space-4) * -1);
} }
h1 { h1 {
margin-top: 16px; margin-top: var(--ha-space-4);
margin-bottom: 8px; margin-bottom: var(--ha-space-2);
} }
p { p {
margin: 0; margin: 0;
} }
.start { .start {
margin: 32px 0; margin: var(--ha-space-8) 0;
width: 100%; width: 100%;
} }
ha-divider { .divider {
--ha-divider-width: calc(100% + 64px); width: calc(100% + var(--ha-space-16));
margin-left: -32px; position: relative;
margin-right: -32px; margin-left: calc(var(--ha-space-8) * -1);
margin-right: calc(var(--ha-space-8) * -1);
} }
.divider div {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
top: 0;
bottom: 0;
width: 100%;
}
.divider div span {
background-color: var(--card-background-color);
padding: 0 var(--ha-space-4);
}
ha-md-list { ha-md-list {
width: 100%; width: 100%;
padding-bottom: 0; padding-bottom: 0;

View File

@@ -1,12 +1,12 @@
import "@home-assistant/webawesome/dist/components/divider/divider";
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit"; import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit"; import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import "../../components/ha-divider";
import "../../components/ha-dropdown-item"; import "../../components/ha-dropdown-item";
import "../../components/ha-icon"; import "../../components/ha-icon";
import type { HaSelectSelectEvent } from "../../components/ha-select";
import "../../components/ha-select"; import "../../components/ha-select";
import type { HaSelectSelectEvent } from "../../components/ha-select";
import "../../components/ha-settings-row"; import "../../components/ha-settings-row";
import "../../components/ha-spinner"; import "../../components/ha-spinner";
import "../../components/ha-svg-icon"; import "../../components/ha-svg-icon";
@@ -57,7 +57,7 @@ class HaPickDashboardRow extends LitElement {
> >
${this.hass.localize("ui.panel.profile.dashboard.system")} ${this.hass.localize("ui.panel.profile.dashboard.system")}
</ha-dropdown-item> </ha-dropdown-item>
<ha-divider></ha-divider> <wa-divider></wa-divider>
${PANEL_DASHBOARDS.map((panel) => { ${PANEL_DASHBOARDS.map((panel) => {
const panelInfo = this.hass.panels[panel] as const panelInfo = this.hass.panels[panel] as
| PanelInfo | PanelInfo
@@ -80,7 +80,7 @@ class HaPickDashboardRow extends LitElement {
})} })}
${this._dashboards.length ${this._dashboards.length
? html` ? html`
<ha-divider></ha-divider> <wa-divider></wa-divider>
${this._dashboards.map((dashboard) => { ${this._dashboards.map((dashboard) => {
if ( if (
!this.hass.user!.is_admin && !this.hass.user!.is_admin &&