From f0375a850b67cb28e6109bf6d20fd1dd3e9f8e6d Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 27 Dec 2023 13:17:50 +0100 Subject: [PATCH] Fix dialog headers --- src/components/ha-dialog.ts | 40 +++++++++++-------- .../calendar/dialog-calendar-event-detail.ts | 15 ++----- .../calendar/dialog-calendar-event-editor.ts | 27 +++++-------- src/panels/todo/dialog-todo-item-editor.ts | 23 ++++------- 4 files changed, 45 insertions(+), 60 deletions(-) diff --git a/src/components/ha-dialog.ts b/src/components/ha-dialog.ts index feaceec93daf..e853b52514dd 100644 --- a/src/components/ha-dialog.ts +++ b/src/components/ha-dialog.ts @@ -13,13 +13,15 @@ export const createCloseHeading = ( hass: HomeAssistant | undefined, title: string | TemplateResult ) => html` -
${title}
- +
+ ${title} + +
`; @customElement("ha-dialog") @@ -94,15 +96,12 @@ export class HaDialog extends DialogBase { } .mdc-dialog__title { padding: 24px 24px 0 24px; - text-overflow: ellipsis; - overflow: hidden; } .mdc-dialog__actions { padding: 12px 24px 12px 24px; } .mdc-dialog__title::before { - display: block; - height: 0px; + content: unset; } .mdc-dialog .mdc-dialog__content { position: var(--dialog-content-position, relative); @@ -126,19 +125,26 @@ export class HaDialog extends DialogBase { flex-direction: column; } .header_title { - margin-right: 32px; - margin-inline-end: 32px; - margin-inline-start: initial; + position: relative; + padding-right: 32px; + padding-inline-end: 32px; + padding-inline-start: initial; direction: var(--direction); } + .header_title span { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + display: block; + } .header_button { position: absolute; - right: 16px; - top: 14px; + right: -8px; + top: -8px; text-decoration: none; color: inherit; inset-inline-start: initial; - inset-inline-end: 16px; + inset-inline-end: -8px; direction: var(--direction); } .dialog-actions { diff --git a/src/panels/calendar/dialog-calendar-event-detail.ts b/src/panels/calendar/dialog-calendar-event-detail.ts index 6172e79b4ca8..ee091eac1652 100644 --- a/src/panels/calendar/dialog-calendar-event-detail.ts +++ b/src/panels/calendar/dialog-calendar-event-detail.ts @@ -1,8 +1,8 @@ import "@material/mwc-button"; -import { mdiCalendarClock, mdiClose } from "@mdi/js"; +import { mdiCalendarClock } from "@mdi/js"; import { toDate } from "date-fns-tz"; import { addDays, isSameDay } from "date-fns/esm"; -import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; +import { CSSResultGroup, LitElement, css, html, nothing } from "lit"; import { property, state } from "lit/decorators"; import { formatDate } from "../../common/datetime/format_date"; import { formatDateTime } from "../../common/datetime/format_date_time"; @@ -11,6 +11,7 @@ import { fireEvent } from "../../common/dom/fire_event"; import { isDate } from "../../common/string/is_date"; import "../../components/entity/state-info"; import "../../components/ha-date-input"; +import { createCloseHeading } from "../../components/ha-dialog"; import "../../components/ha-time-input"; import { CalendarEventMutableParams, @@ -65,15 +66,7 @@ class DialogCalendarEventDetail extends LitElement { @closed=${this.closeDialog} scrimClickAction escapeKeyAction - .heading=${html` -
${this._data!.summary}
- - `} + .heading=${createCloseHeading(this.hass, this._data!.summary)} >
${this._error diff --git a/src/panels/calendar/dialog-calendar-event-editor.ts b/src/panels/calendar/dialog-calendar-event-editor.ts index 2cd0bb0f5d36..b0bf4f0f6b9d 100644 --- a/src/panels/calendar/dialog-calendar-event-editor.ts +++ b/src/panels/calendar/dialog-calendar-event-editor.ts @@ -1,5 +1,4 @@ import "@material/mwc-button"; -import { mdiClose } from "@mdi/js"; import { formatInTimeZone, toDate } from "date-fns-tz"; import { addDays, @@ -9,7 +8,7 @@ import { startOfHour, } from "date-fns/esm"; import { HassEntity } from "home-assistant-js-websocket"; -import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; +import { CSSResultGroup, LitElement, css, html, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import memoizeOne from "memoize-one"; import { fireEvent } from "../../common/dom/fire_event"; @@ -18,23 +17,24 @@ import { supportsFeature } from "../../common/entity/supports-feature"; import { isDate } from "../../common/string/is_date"; import "../../components/entity/ha-entity-picker"; import "../../components/ha-date-input"; +import { createCloseHeading } from "../../components/ha-dialog"; import "../../components/ha-textarea"; import "../../components/ha-time-input"; import { CalendarEntityFeature, CalendarEventMutableParams, + RecurrenceRange, createCalendarEvent, deleteCalendarEvent, - RecurrenceRange, updateCalendarEvent, } from "../../data/calendar"; +import { TimeZone } from "../../data/translation"; import { haStyleDialog } from "../../resources/styles"; import { HomeAssistant } from "../../types"; import "../lovelace/components/hui-generic-entity-row"; import "./ha-recurrence-rule-editor"; import { showConfirmEventDialog } from "./show-confirm-event-dialog-box"; import { CalendarEventEditDialogParams } from "./show-dialog-calendar-event-editor"; -import { TimeZone } from "../../data/translation"; const CALENDAR_DOMAINS = ["calendar"]; @@ -142,19 +142,12 @@ class DialogCalendarEventEditor extends LitElement { @closed=${this.closeDialog} scrimClickAction escapeKeyAction - .heading=${html` -
- ${isCreate - ? this.hass.localize("ui.components.calendar.event.add") - : this._summary} -
- - `} + .heading=${createCloseHeading( + this.hass, + isCreate + ? this.hass.localize("ui.components.calendar.event.add") + : this._summary + )} >
${this._error diff --git a/src/panels/todo/dialog-todo-item-editor.ts b/src/panels/todo/dialog-todo-item-editor.ts index 3dd4782df605..12df7d1d3fc8 100644 --- a/src/panels/todo/dialog-todo-item-editor.ts +++ b/src/panels/todo/dialog-todo-item-editor.ts @@ -1,11 +1,12 @@ import "@material/mwc-button"; -import { mdiClose } from "@mdi/js"; import { formatInTimeZone, toDate } from "date-fns-tz"; import { CSSResultGroup, LitElement, css, html, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import memoizeOne from "memoize-one"; import { fireEvent } from "../../common/dom/fire_event"; +import { supportsFeature } from "../../common/entity/supports-feature"; import "../../components/ha-date-input"; +import { createCloseHeading } from "../../components/ha-dialog"; import "../../components/ha-textarea"; import "../../components/ha-time-input"; import { @@ -20,7 +21,6 @@ import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box"; import { haStyleDialog } from "../../resources/styles"; import { HomeAssistant } from "../../types"; import { TodoItemEditDialogParams } from "./show-dialog-todo-item-editor"; -import { supportsFeature } from "../../common/entity/supports-feature"; @customElement("dialog-todo-item-editor") class DialogTodoItemEditor extends LitElement { @@ -100,19 +100,12 @@ class DialogTodoItemEditor extends LitElement { @closed=${this.closeDialog} scrimClickAction escapeKeyAction - .heading=${html` -
- ${isCreate - ? this.hass.localize("ui.components.todo.item.add") - : this._summary} -
- - `} + .heading=${createCloseHeading( + this.hass, + isCreate + ? this.hass.localize("ui.components.todo.item.add") + : this._summary + )} >
${this._error