diff --git a/src/components/ha-settings-row.ts b/src/components/ha-settings-row.ts index 0d53c58d29..4fdae88f3e 100644 --- a/src/components/ha-settings-row.ts +++ b/src/components/ha-settings-row.ts @@ -1,3 +1,4 @@ +import "@polymer/paper-item/paper-item-body"; import { css, CSSResult, @@ -7,7 +8,6 @@ import { property, SVGTemplateResult, } from "lit-element"; -import "@polymer/paper-item/paper-item-body"; @customElement("ha-settings-row") export class HaSettingsRow extends LitElement { @@ -49,6 +49,9 @@ export class HaSettingsRow extends LitElement { border-top: 1px solid var(--divider-color); padding-bottom: 8px; } + ::slotted(ha-switch) { + padding: 16px 0; + } `; } } diff --git a/src/components/ha-sidebar.ts b/src/components/ha-sidebar.ts index 73e121c4f9..49daf43104 100644 --- a/src/components/ha-sidebar.ts +++ b/src/components/ha-sidebar.ts @@ -165,7 +165,7 @@ let sortStyles: CSSResult; class HaSidebar extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; - @property() public narrow!: boolean; + @property({ type: Boolean, reflect: true }) public narrow!: boolean; @property({ type: Boolean }) public alwaysExpand = false; @@ -259,7 +259,7 @@ class HaSidebar extends LitElement {
${this._editMode ? html` - DONE + ${hass.localize("ui.sidebar.done")} ` : "Home Assistant"}
@@ -447,6 +447,9 @@ class HaSidebar extends LitElement { subscribeNotifications(this.hass.connection, (notifications) => { this._notifications = notifications; }); + window.addEventListener("hass-edit-sidebar", () => + this._activateEditMode() + ); } protected updated(changedProps) { @@ -479,11 +482,15 @@ class HaSidebar extends LitElement { return this.shadowRoot!.querySelector(".tooltip")! as HTMLDivElement; } - private async _handleAction(ev: CustomEvent) { + private _handleAction(ev: CustomEvent) { if (ev.detail.action !== "hold") { return; } + this._activateEditMode(); + } + + private async _activateEditMode() { if (!Sortable) { const [sortableImport, sortStylesImport] = await Promise.all([ import("sortablejs/modular/sortable.core.esm"), @@ -498,9 +505,7 @@ class HaSidebar extends LitElement { } this._editMode = true; - if (!this.expanded) { - fireEvent(this, "hass-toggle-menu"); - } + fireEvent(this, "hass-open-menu"); await this.updateComplete; @@ -761,6 +766,9 @@ class HaSidebar extends LitElement { width: 100%; display: none; } + :host([narrow]) .title { + padding: 0 16px; + } :host([expanded]) .title { display: initial; } diff --git a/src/layouts/home-assistant-main.ts b/src/layouts/home-assistant-main.ts index 31609dbdc5..998fb04a3d 100644 --- a/src/layouts/home-assistant-main.ts +++ b/src/layouts/home-assistant-main.ts @@ -24,6 +24,7 @@ const NON_SWIPABLE_PANELS = ["map"]; declare global { // for fire event interface HASSDomEvents { + "hass-open-menu": undefined; "hass-toggle-menu": undefined; "hass-show-notifications": undefined; } @@ -92,6 +93,17 @@ class HomeAssistantMain extends LitElement { protected firstUpdated() { import(/* webpackChunkName: "ha-sidebar" */ "../components/ha-sidebar"); + this.addEventListener("hass-open-menu", () => { + if (this._sidebarNarrow) { + this.drawer.open(); + } else { + fireEvent(this, "hass-dock-sidebar", { + dock: "docked", + }); + setTimeout(() => this.appLayout.resetLayout()); + } + }); + this.addEventListener("hass-toggle-menu", () => { if (this._sidebarNarrow) { if (this.drawer.opened) { diff --git a/src/panels/profile/ha-panel-profile.ts b/src/panels/profile/ha-panel-profile.ts index b4aa386092..458148335c 100644 --- a/src/panels/profile/ha-panel-profile.ts +++ b/src/panels/profile/ha-panel-profile.ts @@ -107,6 +107,23 @@ class HaPanelProfile extends LitElement { .narrow=${this.narrow} .hass=${this.hass} > + + + ${this.hass.localize( + "ui.panel.profile.customize_sidebar.header" + )} + + + ${this.hass.localize( + "ui.panel.profile.customize_sidebar.description" + )} + + + ${this.hass.localize( + "ui.panel.profile.customize_sidebar.button" + )} + + ${this.hass.dockedSidebar !== "auto" || !this.narrow ? html` ; - } - interface HTMLElementEventMap { "hass-default-panel": HASSDomEvent; + "hass-edit-sidebar": undefined; } } diff --git a/src/translations/en.json b/src/translations/en.json index 02cd088e92..e7d2ea366e 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -585,7 +585,8 @@ }, "sidebar": { "external_app_configuration": "App Configuration", - "sidebar_toggle": "Sidebar Toggle" + "sidebar_toggle": "Sidebar Toggle", + "done": "Done" }, "panel": { "calendar": { @@ -2431,6 +2432,11 @@ "header": "Always hide the sidebar", "description": "This will hide the sidebar by default, similar to the mobile experience." }, + "customize_sidebar": { + "header": "Change the order and hide items from the sidebar", + "description": "You can also press and hold the header of the sidebar to activate edit mode.", + "button": "Edit" + }, "vibrate": { "header": "Vibrate", "description": "Enable or disable vibration on this device when controlling devices."