diff --git a/src/common/util/compute_rtl.ts b/src/common/util/compute_rtl.ts index 0c53e374e9..b0b8b20cf5 100644 --- a/src/common/util/compute_rtl.ts +++ b/src/common/util/compute_rtl.ts @@ -38,4 +38,8 @@ export function setDirectionStyles(direction: string, element: LitElement) { "--margin-title", direction === "ltr" ? "var(--margin-title-ltr)" : "var(--margin-title-rtl)" ); + element.style.setProperty( + "--scale-direction", + direction === "ltr" ? "1" : "-1" + ); } diff --git a/src/components/chart/ha-chart-base.ts b/src/components/chart/ha-chart-base.ts index 36ddc2915c..ea720e16bc 100644 --- a/src/components/chart/ha-chart-base.ts +++ b/src/components/chart/ha-chart-base.ts @@ -10,7 +10,6 @@ import { customElement, property, state } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; import { styleMap } from "lit/directives/style-map"; import { clamp } from "../../common/number/clamp"; -import { computeRTL } from "../../common/util/compute_rtl"; import { HomeAssistant } from "../../types"; import { debounce } from "../../common/util/debounce"; @@ -212,12 +211,10 @@ export class HaChartBase extends LitElement { height: `${ this.height ?? this._chartHeight ?? this.clientWidth / 2 }px`, - "padding-left": `${ - computeRTL(this.hass) ? 0 : this._paddingYAxisInternal - }px`, - "padding-right": `${ - computeRTL(this.hass) ? this._paddingYAxisInternal : 0 - }px`, + "padding-left": `${this._paddingYAxisInternal}`, + "padding-right": 0, + "padding-inline-start": `${this._paddingYAxisInternal}`, + "padding-inline-end": 0, })} > @@ -433,14 +430,6 @@ export class HaChartBase extends LitElement { .chartTooltip .bullet { align-self: baseline; } - :host([rtl]) .chartLegend .bullet, - :host([rtl]) .chartTooltip .bullet { - margin-right: inherit; - margin-left: 6px; - margin-inline-end: inherit; - margin-inline-start: 6px; - direction: var(--direction); - } .chartTooltip { padding: 8px; font-size: 90%; @@ -452,9 +441,7 @@ export class HaChartBase extends LitElement { z-index: 1000; width: 200px; box-sizing: border-box; - } - :host([rtl]) .chartTooltip { - direction: rtl; + direction: var(--direction); } .chartLegend ul, .chartTooltip ul { diff --git a/src/components/data-table/ha-data-table.ts b/src/components/data-table/ha-data-table.ts index 7f3d2f61b8..411829f43b 100644 --- a/src/components/data-table/ha-data-table.ts +++ b/src/components/data-table/ha-data-table.ts @@ -688,15 +688,12 @@ export class HaDataTable extends LitElement { padding-left: 16px; /* @noflip */ padding-right: 0; + /* @noflip */ + padding-inline-start: 16px; + /* @noflip */ + padding-inline-end: initial; width: 60px; } - :host([dir="rtl"]) .mdc-data-table__header-cell--checkbox, - :host([dir="rtl"]) .mdc-data-table__cell--checkbox { - /* @noflip */ - padding-left: 0; - /* @noflip */ - padding-right: 16px; - } .mdc-data-table__table { height: 100%; @@ -723,11 +720,7 @@ export class HaDataTable extends LitElement { } .mdc-data-table__cell--numeric { - text-align: right; - } - :host([dir="rtl"]) .mdc-data-table__cell--numeric { - /* @noflip */ - text-align: left; + text-align: var(--float-end); } .mdc-data-table__cell--icon { @@ -753,15 +746,7 @@ export class HaDataTable extends LitElement { .mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:not( .not-sorted ) { - text-align: left; - } - :host([dir="rtl"]) - .mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:hover, - :host([dir="rtl"]) - .mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:not( - .not-sorted - ) { - text-align: right; + text-align: var(--float-start); } .mdc-data-table__cell--icon:first-child img, @@ -771,27 +756,14 @@ export class HaDataTable extends LitElement { .mdc-data-table__cell--icon:first-child ha-domain-icon, .mdc-data-table__cell--icon:first-child ha-service-icon { margin-left: 8px; - } - :host([dir="rtl"]) .mdc-data-table__cell--icon:first-child ha-icon, - :host([dir="rtl"]) - .mdc-data-table__cell--icon:first-child - ha-state-icon, - :host([dir="rtl"]) - .mdc-data-table__cell--icon:first-child - ha-svg-icon - :host([dir="rtl"]) - .mdc-data-table__cell--icon:first-child - img { - margin-left: auto; - margin-right: 8px; + margin-inline-start: 8px; + margin-inline-end: initial; } .mdc-data-table__cell--icon:first-child state-badge { margin-right: -8px; - } - :host([dir="rtl"]) .mdc-data-table__cell--icon:first-child state-badge { - margin-right: auto; - margin-left: -8px; + margin-inline-end: -8px; + margin-inline-start: initial; } .mdc-data-table__cell--overflow-menu, @@ -824,15 +796,8 @@ export class HaDataTable extends LitElement { .mdc-data-table__header-cell--icon-button:first-child, .mdc-data-table__cell--icon-button:first-child { padding-left: 16px; - } - :host([dir="rtl"]) - .mdc-data-table__header-cell--overflow-menu:first-child, - :host([dir="rtl"]) .mdc-data-table__cell--overflow-menu:first-child, - :host([dir="rtl"]) - .mdc-data-table__header-cell--overflow-menu:first-child, - :host([dir="rtl"]) .mdc-data-table__cell--overflow-menu:first-child { - padding-left: 8px; - padding-right: 16px; + padding-inline-start: 16px; + padding-inline-end: initial; // 8px? } .mdc-data-table__cell--overflow-menu:last-child, @@ -840,14 +805,8 @@ export class HaDataTable extends LitElement { .mdc-data-table__header-cell--icon-button:last-child, .mdc-data-table__cell--icon-button:last-child { padding-right: 16px; - } - :host([dir="rtl"]) - .mdc-data-table__header-cell--overflow-menu:last-child, - :host([dir="rtl"]) .mdc-data-table__cell--overflow-menu:last-child, - :host([dir="rtl"]) .mdc-data-table__header-cell--icon-button:last-child, - :host([dir="rtl"]) .mdc-data-table__cell--icon-button:last-child { - padding-right: 8px; - padding-left: 16px; + padding-inline-end: 16px; + padding-inline-start: initial; // 8px? } .mdc-data-table__cell--overflow-menu, .mdc-data-table__header-cell--overflow-menu { @@ -867,28 +826,15 @@ export class HaDataTable extends LitElement { letter-spacing: 0.0071428571em; text-decoration: inherit; text-transform: inherit; - text-align: left; - } - :host([dir="rtl"]) .mdc-data-table__header-cell { - /* @noflip */ - text-align: right; + text-align: var(--float-start); } .mdc-data-table__header-cell--numeric { - text-align: right; + text-align: var(--float-end); } .mdc-data-table__header-cell--numeric.sortable:hover, .mdc-data-table__header-cell--numeric.sortable:not(.not-sorted) { - text-align: left; - } - :host([dir="rtl"]) .mdc-data-table__header-cell--numeric { - /* @noflip */ - text-align: left; - } - :host([dir="rtl"]) .mdc-data-table__header-cell--numeric.sortable:hover, - :host([dir="rtl"]) - .mdc-data-table__header-cell--numeric.sortable:not(.not-sorted) { - text-align: right; + text-align: var(--float-start); } /* custom from here */ @@ -909,20 +855,15 @@ export class HaDataTable extends LitElement { .mdc-data-table__header-cell span { position: relative; left: 0px; - } - :host([dir="rtl"]) .mdc-data-table__header-cell span { - left: auto; - right: 0px; + inset-inline-start: 0px; + inset-inline-end: initial; } .mdc-data-table__header-cell.sortable { cursor: pointer; } .mdc-data-table__header-cell > * { - transition: left 0.2s ease; - } - :host([dir="rtl"]) .mdc-data-table__header-cell > * { - transition: right 0.2s ease; + transition: var(--float-start) 0.2s ease; } .mdc-data-table__header-cell ha-svg-icon { top: -3px; @@ -930,35 +871,20 @@ export class HaDataTable extends LitElement { } .mdc-data-table__header-cell.not-sorted ha-svg-icon { left: -20px; - } - :host([dir="rtl"]) .mdc-data-table__header-cell.not-sorted ha-svg-icon { - right: -20px; + inset-inline-start: -20px; + inset-inline-end: initial; } .mdc-data-table__header-cell.sortable:not(.not-sorted) span, .mdc-data-table__header-cell.sortable.not-sorted:hover span { left: 24px; - } - :host([dir="rtl"]) - .mdc-data-table__header-cell.sortable:not(.not-sorted) - span, - :host([dir="rtl"]) - .mdc-data-table__header-cell.sortable.not-sorted:hover - span { - left: auto; - right: 24px; + inset-inline-start: 24px; + inset-inline-end: initial; } .mdc-data-table__header-cell.sortable:not(.not-sorted) ha-svg-icon, .mdc-data-table__header-cell.sortable:hover.not-sorted ha-svg-icon { left: 12px; - } - :host([dir="rtl"]) - .mdc-data-table__header-cell.sortable:not(.not-sorted) - ha-svg-icon, - :host([dir="rtl"]) - .mdc-data-table__header-cell.sortable:hover.not-sorted - ha-svg-icon { - left: auto; - right: 12px; + inset-inline-start: 12px; + inset-inline-end: initial; } .table-header { border-bottom: 1px solid var(--divider-color); diff --git a/src/components/date-range-picker.ts b/src/components/date-range-picker.ts index 237576a89c..5ebb0c2a97 100644 --- a/src/components/date-range-picker.ts +++ b/src/components/date-range-picker.ts @@ -9,6 +9,7 @@ import { localizeWeekdays, localizeMonths, } from "../common/datetime/localize_date"; +import { mainWindow } from "../common/dom/get_main_window"; // Set the current date to the left picker instead of the right picker because the right is hidden const CustomDateRangePicker = Vue.extend({ @@ -157,7 +158,7 @@ class DateRangePickerElement extends WrappedElement { min-width: initial !important; max-height: var(--date-range-picker-max-height); overflow-y: auto; - } + } .daterangepicker:before { display: none; } @@ -267,15 +268,37 @@ class DateRangePickerElement extends WrappedElement { .calendar-table { padding: 0 !important; } - .daterangepicker.ltr { + .calendar-time { direction: ltr; - text-align: left; + } + .daterangepicker.ltr { + direction: var(--direction); + text-align: var(--float-start); } .vue-daterange-picker{ min-width: unset !important; display: block !important; } `; + if (mainWindow.document.dir === "rtl") { + style.innerHTML += ` + .daterangepicker .calendar-table .next span { + transform: rotate(135deg); + -webkit-transform: rotate(135deg); + } + .daterangepicker .calendar-table .prev span { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); + } + .daterangepicker td.start-date { + border-radius: 0 50% 50% 0; + } + .daterangepicker td.end-date { + border-radius: 50% 0 0 50%; + } + `; + } + const shadowRoot = this.shadowRoot!; shadowRoot.appendChild(style); // Stop click events from reaching the document, otherwise it will close the picker immediately. diff --git a/src/components/entity/state-info.ts b/src/components/entity/state-info.ts index db631e4496..18bc50068c 100644 --- a/src/components/entity/state-info.ts +++ b/src/components/entity/state-info.ts @@ -3,7 +3,6 @@ import type { HassEntity } from "home-assistant-js-websocket"; import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; import { customElement, property } from "lit/decorators"; import { computeStateName } from "../../common/entity/compute_state_name"; -import { computeRTL } from "../../common/util/compute_rtl"; import type { HomeAssistant } from "../../types"; import "../ha-relative-time"; import "./state-badge"; @@ -16,9 +15,6 @@ class StateInfo extends LitElement { @property({ type: Boolean }) public inDialog = false; - // property used only in CSS - @property({ type: Boolean, reflect: true }) public rtl = false; - @property() public color?: string; protected render() { @@ -79,18 +75,6 @@ class StateInfo extends LitElement { `; } - protected updated(changedProps) { - super.updated(changedProps); - if (!changedProps.has("hass")) { - return; - } - - const oldHass = changedProps.get("hass") as HomeAssistant | undefined; - if (!oldHass || oldHass.locale !== this.hass.locale) { - this.rtl = computeRTL(this.hass); - } - } - static get styles(): CSSResultGroup { return css` :host { @@ -106,17 +90,14 @@ class StateInfo extends LitElement { .info { margin-left: 8px; + margin-inline-start: 8px; + margin-inline-end: initial; display: flex; flex-direction: column; justify-content: center; height: 100%; min-width: 0; - } - - :host([rtl]) .info { - margin-right: 8px; - margin-left: 0; - text-align: right; + text-align: var(--float-start); } .name { diff --git a/src/components/ha-button-toggle-group.ts b/src/components/ha-button-toggle-group.ts index e4dd2e9524..9fc426a991 100644 --- a/src/components/ha-button-toggle-group.ts +++ b/src/components/ha-button-toggle-group.ts @@ -69,6 +69,7 @@ export class HaButtonToggleGroup extends LitElement { display: flex; --mdc-icon-button-size: var(--button-toggle-size, 36px); --mdc-icon-size: var(--button-toggle-icon-size, 20px); + direction: ltr; } mwc-button { --mdc-shape-small: 0; @@ -119,19 +120,6 @@ export class HaButtonToggleGroup extends LitElement { --mdc-shape-small: 4px; border-right-width: 1px; } - - :host([dir="rtl"]) ha-icon-button:first-child, - :host([dir="rtl"]) mwc-button:first-child { - border-radius: 0 4px 4px 0; - border-right-width: 1px; - --mdc-shape-small: 0 4px 4px 0; - --mdc-button-outline-width: 1px; - } - :host([dir="rtl"]) ha-icon-button:last-child, - :host([dir="rtl"]) mwc-button:last-child { - --mdc-shape-small: 4px 0 0 4px; - border-radius: 4px 0 0 4px; - } `; } } diff --git a/src/components/ha-date-range-picker.ts b/src/components/ha-date-range-picker.ts index 6984dc13fc..1bb96721fc 100644 --- a/src/components/ha-date-range-picker.ts +++ b/src/components/ha-date-range-picker.ts @@ -32,7 +32,6 @@ import { firstWeekdayIndex } from "../common/datetime/first_weekday"; import { formatDate } from "../common/datetime/format_date"; import { formatDateTime } from "../common/datetime/format_date_time"; import { useAmPm } from "../common/datetime/use_am_pm"; -import { computeRTLDirection } from "../common/util/compute_rtl"; import { HomeAssistant } from "../types"; import "./date-range-picker"; import "./ha-icon-button"; @@ -65,8 +64,6 @@ export class HaDateRangePicker extends LitElement { @state() private _hour24format = false; - @state() private _rtlDirection = "ltr"; - @property({ type: Boolean }) public extendedPresets = false; @property() public openingDirection?: "right" | "left" | "center" | "inline"; @@ -236,7 +233,6 @@ export class HaDateRangePicker extends LitElement { const oldHass = changedProps.get("hass") as HomeAssistant | undefined; if (!oldHass || oldHass.locale !== this.hass.locale) { this._hour24format = !useAmPm(this.hass.locale); - this._rtlDirection = computeRTLDirection(this.hass); } } } @@ -306,11 +302,7 @@ export class HaDateRangePicker extends LitElement { >`} ${this.ranges !== false && (this.ranges || this._ranges) - ? html`
+ ? html`
${Object.keys(this.ranges || this._ranges!).map( (name) => html`${name}` diff --git a/src/components/ha-drawer.ts b/src/components/ha-drawer.ts index 37461fb1df..45a54623d5 100644 --- a/src/components/ha-drawer.ts +++ b/src/components/ha-drawer.ts @@ -3,6 +3,7 @@ import { styles } from "@material/mwc-drawer/mwc-drawer.css"; import { css, PropertyValues } from "lit"; import { customElement, property } from "lit/decorators"; import { fireEvent } from "../common/dom/fire_event"; +import { mainWindow } from "../common/dom/get_main_window"; const blockingElements = (document as any).$blockingElements; @@ -12,6 +13,8 @@ export class HaDrawer extends DrawerBase { private _mc?: HammerManager; + private _rtlStyle?: HTMLElement; + protected createAdapter() { return { ...super.createAdapter(), @@ -31,8 +34,26 @@ export class HaDrawer extends DrawerBase { protected updated(changedProps: PropertyValues) { super.updated(changedProps); if (changedProps.has("direction")) { - this.mdcRoot.dir = this.direction; + if (mainWindow.document.dir === "rtl") { + this._rtlStyle = document.createElement("style"); + this._rtlStyle.innerHTML = ` + .mdc-drawer--animate { + transform: translateX(100%); + } + .mdc-drawer--opening { + transform: translateX(0); + } + .mdc-drawer--closing { + transform: translateX(100%); + } + `; + + this.shadowRoot!.appendChild(this._rtlStyle); + } else if (this._rtlStyle) { + this.shadowRoot!.removeChild(this._rtlStyle); + } } + if (changedProps.has("open") && this.open && this.type === "modal") { this._setupSwipe(); } else if (this._mc) { @@ -66,6 +87,8 @@ export class HaDrawer extends DrawerBase { position: fixed; top: 0; border-color: var(--divider-color, rgba(0, 0, 0, 0.12)); + inset-inline-start: 0 !important; + inset-inline-end: initial !important; } .mdc-drawer.mdc-drawer--modal.mdc-drawer--open { z-index: 200; diff --git a/src/components/ha-sidebar.ts b/src/components/ha-sidebar.ts index ba19958170..d36a6a646d 100644 --- a/src/components/ha-sidebar.ts +++ b/src/components/ha-sidebar.ts @@ -38,7 +38,6 @@ import { storage } from "../common/decorators/storage"; import { fireEvent } from "../common/dom/fire_event"; import { toggleAttribute } from "../common/dom/toggle_attribute"; import { stringCompare } from "../common/string/compare"; -import { computeRTL } from "../common/util/compute_rtl"; import { throttle } from "../common/util/throttle"; import { ActionHandlerDetail } from "../data/lovelace/action_handler"; import { @@ -307,16 +306,12 @@ class HaSidebar extends SubscribeMixin(LitElement) { return; } - const oldHass = changedProps.get("hass") as HomeAssistant | undefined; - if (!oldHass || oldHass.locale !== this.hass.locale) { - toggleAttribute(this, "rtl", computeRTL(this.hass)); - } - this._calculateCounts(); if (!SUPPORT_SCROLL_IF_NEEDED) { return; } + const oldHass = changedProps.get("hass") as HomeAssistant | undefined; if (!oldHass || oldHass.panelUrl !== this.hass.panelUrl) { const selectedEl = this.shadowRoot!.querySelector(".iron-selected"); if (selectedEl) { @@ -851,29 +846,22 @@ class HaSidebar extends SubscribeMixin(LitElement) { font-size: 20px; align-items: center; padding-left: calc(4px + env(safe-area-inset-left)); - } - :host([rtl]) .menu { - padding-left: 4px; - padding-right: calc(4px + env(safe-area-inset-right)); + padding-inline-start: calc(4px + env(safe-area-inset-left)); + padding-inline-end: initial; } :host([expanded]) .menu { width: calc(256px + env(safe-area-inset-left)); } - :host([rtl][expanded]) .menu { - width: calc(256px + env(safe-area-inset-right)); - } .menu ha-icon-button { color: var(--sidebar-icon-color); } .title { margin-left: 19px; + margin-inline-start: 19px; + margin-inline-end: initial; width: 100%; display: none; } - :host([rtl]) .title { - margin-left: 0; - margin-right: 19px; - } :host([narrow]) .title { margin: 0; padding: 0 16px; @@ -904,11 +892,8 @@ class HaSidebar extends SubscribeMixin(LitElement) { overflow-x: hidden; background: none; margin-left: env(safe-area-inset-left); - } - - :host([rtl]) paper-listbox { - margin-left: initial; - margin-right: env(safe-area-inset-right); + margin-inline-start: env(safe-area-inset-left); + margin-inline-end: initial; } a { @@ -925,6 +910,8 @@ class HaSidebar extends SubscribeMixin(LitElement) { box-sizing: border-box; margin: 4px; padding-left: 12px; + padding-inline-start: 12px; + padding-inline-end: initial; border-radius: 4px; --paper-item-min-height: 40px; width: 48px; @@ -932,10 +919,6 @@ class HaSidebar extends SubscribeMixin(LitElement) { :host([expanded]) paper-icon-item { width: 248px; } - :host([rtl]) paper-icon-item { - padding-left: auto; - padding-right: 12px; - } ha-icon[slot="item-icon"], ha-svg-icon[slot="item-icon"] { @@ -1010,11 +993,8 @@ class HaSidebar extends SubscribeMixin(LitElement) { .configuration-container { display: flex; margin-left: env(safe-area-inset-left); - } - :host([rtl]) .notifications-container, - :host([rtl]) .configuration-container { - margin-left: initial; - margin-right: env(safe-area-inset-right); + margin-inline-start: env(safe-area-inset-left); + margin-inline-end: initial; } .notifications { cursor: pointer; @@ -1025,23 +1005,18 @@ class HaSidebar extends SubscribeMixin(LitElement) { } .profile { margin-left: env(safe-area-inset-left); - } - :host([rtl]) .profile { - margin-left: initial; - margin-right: env(safe-area-inset-right); + margin-inline-start: env(safe-area-inset-left); + margin-inline-end: initial; } .profile paper-icon-item { padding-left: 4px; - } - :host([rtl]) .profile paper-icon-item { - padding-left: auto; - padding-right: 4px; + margin-inline-start: 4px; + margin-inline-end: auto; } .profile .item-text { margin-left: 8px; - } - :host([rtl]) .profile .item-text { - margin-right: 8px; + margin-inline-start: 8px; + margin-inline-end: initial; } .notification-badge, @@ -1106,9 +1081,9 @@ class HaSidebar extends SubscribeMixin(LitElement) { font-weight: 500; } - :host([rtl]) .menu ha-icon-button { - -webkit-transform: scaleX(-1); - transform: scaleX(-1); + .menu ha-icon-button { + -webkit-transform: scaleX(var(--scale-direction)); + transform: scaleX(var(--scale-direction)); } `, ]; diff --git a/src/components/ha-slider.ts b/src/components/ha-slider.ts index 5ea8d50b33..31607a62f5 100644 --- a/src/components/ha-slider.ts +++ b/src/components/ha-slider.ts @@ -2,9 +2,15 @@ import { customElement } from "lit/decorators"; import "element-internals-polyfill"; import { MdSlider } from "@material/web/slider/slider"; import { CSSResult, css } from "lit"; +import { mainWindow } from "../common/dom/get_main_window"; @customElement("ha-slider") export class HaSlider extends MdSlider { + public connectedCallback() { + super.connectedCallback(); + this.dir = mainWindow.document.dir; + } + static override styles: CSSResult[] = [ ...MdSlider.styles, css` diff --git a/src/components/ha-textarea.ts b/src/components/ha-textarea.ts index 7cf773b903..0fef6fe5a0 100644 --- a/src/components/ha-textarea.ts +++ b/src/components/ha-textarea.ts @@ -3,18 +3,11 @@ import { styles as textfieldStyles } from "@material/mwc-textfield/mwc-textfield import { styles as textareaStyles } from "@material/mwc-textarea/mwc-textarea.css"; import { css, PropertyValues } from "lit"; import { customElement, property } from "lit/decorators"; -import { mainWindow } from "../common/dom/get_main_window"; @customElement("ha-textarea") export class HaTextArea extends TextAreaBase { @property({ type: Boolean, reflect: true }) autogrow = false; - firstUpdated() { - super.firstUpdated(); - - this.setAttribute("dir", mainWindow.document.dir); - } - updated(changedProperties: PropertyValues) { super.updated(changedProperties); if (this.autogrow && changedProperties.has("value")) { @@ -54,9 +47,10 @@ export class HaTextArea extends TextAreaBase { margin-top: 16px; margin-bottom: 16px; } - :host([dir="rtl"]) .mdc-floating-label { - right: 16px; - left: initial; + .mdc-floating-label { + inset-inline-start: 16px !important; + inset-inline-end: initial !important; + transform-origin: var(--float-start) top; } `, ]; diff --git a/src/components/media-player/ha-media-player-browse.ts b/src/components/media-player/ha-media-player-browse.ts index 6737ea613b..e46c9e908c 100644 --- a/src/components/media-player/ha-media-player-browse.ts +++ b/src/components/media-player/ha-media-player-browse.ts @@ -25,7 +25,6 @@ import { classMap } from "lit/directives/class-map"; import { styleMap } from "lit/directives/style-map"; import { until } from "lit/directives/until"; import { fireEvent } from "../../common/dom/fire_event"; -import { computeRTLDirection } from "../../common/util/compute_rtl"; import { debounce } from "../../common/util/debounce"; import { isUnavailableState } from "../../data/entity"; import type { MediaPlayerItem } from "../../data/media-player"; @@ -539,7 +538,6 @@ export class HaMediaPlayerBrowse extends LitElement { .graphic=${mediaClass.show_list_images ? "medium" : "avatar"} - dir=${computeRTLDirection(this.hass)} > ${this.hass.localize( @@ -637,7 +635,6 @@ export class HaMediaPlayerBrowse extends LitElement { @click=${this._childClicked} .item=${child} .graphic=${mediaClass.show_list_images ? "medium" : "avatar"} - dir=${computeRTLDirection(this.hass)} > ${backgroundImage === "none" && !child.can_play ? html``} - .dir=${computeRTLDirection(this.hass)} > `} - .dir=${computeRTLDirection(this.hass)} > diff --git a/src/layouts/hass-subpage.ts b/src/layouts/hass-subpage.ts index 3a1ed24385..f297a77b18 100644 --- a/src/layouts/hass-subpage.ts +++ b/src/layouts/hass-subpage.ts @@ -1,15 +1,6 @@ -import { - css, - CSSResultGroup, - html, - LitElement, - PropertyValues, - TemplateResult, -} from "lit"; +import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, eventOptions, property } from "lit/decorators"; import { restoreScroll } from "../common/decorators/restore-scroll"; -import { toggleAttribute } from "../common/dom/toggle_attribute"; -import { computeRTL } from "../common/util/compute_rtl"; import "../components/ha-icon-button-arrow-prev"; import "../components/ha-menu-button"; import { HomeAssistant } from "../types"; @@ -34,17 +25,6 @@ class HassSubpage extends LitElement { // @ts-ignore @restoreScroll(".content") private _savedScrollPos?: number; - protected willUpdate(changedProps: PropertyValues): void { - super.willUpdate(changedProps); - if (!changedProps.has("hass")) { - return; - } - const oldHass = changedProps.get("hass") as HomeAssistant | undefined; - if (!oldHass || oldHass.locale !== this.hass.locale) { - toggleAttribute(this, "rtl", computeRTL(this.hass)); - } - } - protected render(): TemplateResult { return html`
@@ -160,6 +140,9 @@ class HassSubpage extends LitElement { #fab { position: absolute; right: calc(16px + env(safe-area-inset-right)); + inset-inline-end: calc(16px + env(safe-area-inset-right)); + inset-inline-start: initial; + bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 1; } @@ -169,15 +152,8 @@ class HassSubpage extends LitElement { #fab[is-wide] { bottom: 24px; right: 24px; - } - :host([rtl]) #fab { - right: auto; - left: calc(16px + env(safe-area-inset-left)); - } - :host([rtl][is-wide]) #fab { - bottom: 24px; - left: 24px; - right: auto; + inset-inline-end: 24px; + inset-inline-start: initial; } `, ]; diff --git a/src/layouts/hass-tabs-subpage-data-table.ts b/src/layouts/hass-tabs-subpage-data-table.ts index 275cfe82f1..7af35ded29 100644 --- a/src/layouts/hass-tabs-subpage-data-table.ts +++ b/src/layouts/hass-tabs-subpage-data-table.ts @@ -4,7 +4,6 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property, query } from "lit/decorators"; import { fireEvent } from "../common/dom/fire_event"; import { LocalizeFunc } from "../common/translations/localize"; -import { computeRTLDirection } from "../common/util/compute_rtl"; import "../components/data-table/ha-data-table"; import type { DataTableColumnContainer, @@ -244,7 +243,6 @@ export class HaTabsSubpageDataTable extends LitElement { .selectable=${this.selectable} .hasFab=${this.hasFab} .id=${this.id} - .dir=${computeRTLDirection(this.hass)} .clickable=${this.clickable} .appendRow=${this.appendRow} > diff --git a/src/layouts/hass-tabs-subpage.ts b/src/layouts/hass-tabs-subpage.ts index 15d8b26629..9de45b8a4a 100644 --- a/src/layouts/hass-tabs-subpage.ts +++ b/src/layouts/hass-tabs-subpage.ts @@ -13,7 +13,6 @@ import memoizeOne from "memoize-one"; import { isComponentLoaded } from "../common/config/is_component_loaded"; import { restoreScroll } from "../common/decorators/restore-scroll"; import { LocalizeFunc } from "../common/translations/localize"; -import { computeRTL } from "../common/util/compute_rtl"; import "../components/ha-icon-button-arrow-prev"; import "../components/ha-menu-button"; import "../components/ha-svg-icon"; @@ -58,8 +57,6 @@ class HassTabsSubpage extends LitElement { @property({ type: Boolean, reflect: true, attribute: "is-wide" }) public isWide = false; - @property({ type: Boolean, reflect: true }) public rtl = false; - @state() private _activeTab?: PageNavigation; // @ts-ignore @@ -123,14 +120,6 @@ class HassTabsSubpage extends LitElement { `${this.route.prefix}${this.route.path}`.includes(tab.path) ); } - if (changedProperties.has("hass")) { - const oldHass = changedProperties.get("hass") as - | HomeAssistant - | undefined; - if (!oldHass || oldHass.language !== this.hass.language) { - this.rtl = computeRTL(this.hass); - } - } super.willUpdate(changedProperties); } @@ -334,6 +323,8 @@ class HassTabsSubpage extends LitElement { #fab { position: fixed; right: calc(16px + env(safe-area-inset-right)); + inset-inline-end: calc(16px + env(safe-area-inset-right)); + inset-inline-start: initial; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 1; } @@ -343,15 +334,8 @@ class HassTabsSubpage extends LitElement { #fab[is-wide] { bottom: 24px; right: 24px; - } - :host([rtl]) #fab { - right: auto; - left: calc(16px + env(safe-area-inset-left)); - } - :host([rtl][is-wide]) #fab { - bottom: 24px; - left: 24px; - right: auto; + inset-inline-end: 24px; + inset-inline-start: initial; } `, ]; diff --git a/src/layouts/home-assistant-main.ts b/src/layouts/home-assistant-main.ts index d6e7b3c826..29963ac45d 100644 --- a/src/layouts/home-assistant-main.ts +++ b/src/layouts/home-assistant-main.ts @@ -11,7 +11,6 @@ import { customElement, property, state } from "lit/decorators"; import { fireEvent, HASSDomEvent } from "../common/dom/fire_event"; import { listenMediaQuery } from "../common/dom/media_query"; import { toggleAttribute } from "../common/dom/toggle_attribute"; -import { computeRTLDirection } from "../common/util/compute_rtl"; import "../components/ha-drawer"; import { showNotificationDrawer } from "../dialogs/notifications/show-notification-drawer"; import type { HomeAssistant, Route } from "../types"; @@ -62,7 +61,6 @@ export class HomeAssistantMain extends LitElement { ` : html` @@ -203,7 +201,6 @@ export class HAFullCalendar extends LitElement { .buttons=${viewToggleButtons} .active=${this._activeView} @value-changed=${this._handleView} - .dir=${computeRTLDirection(this.hass)} >
`} @@ -503,6 +500,8 @@ export class HAFullCalendar extends LitElement { position: absolute; bottom: 32px; right: 32px; + inset-inline-end: 32px; + inset-inline-start: initial; z-index: 1; } diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index ed180172b3..04343c20ec 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -1,5 +1,4 @@ import "@material/mwc-button"; -import "@material/mwc-list/mwc-list-item"; import { mdiCheck, mdiContentDuplicate, @@ -35,6 +34,7 @@ import "../../../components/ha-fab"; import "../../../components/ha-icon-button"; import "../../../components/ha-svg-icon"; import "../../../components/ha-yaml-editor"; +import "../../../components/ha-list-item"; import { AutomationConfig, AutomationEntity, @@ -150,7 +150,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { .path=${mdiDotsVertical} > -
- + - ${this.hass.localize("ui.panel.config.automation.editor.run")} - + ${stateObj && this._config && this.narrow ? html` - + ${this.hass.localize( "ui.panel.config.automation.editor.show_trace" )} @@ -181,22 +181,22 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { slot="graphic" .path=${mdiTransitConnection} > - + ` : ""} - ${this.hass.localize("ui.panel.config.automation.editor.rename")} - + ${this._config && !("use_blueprint" in this._config) ? html` - - + ` : ""} - - +
  • - + ${this.hass.localize("ui.panel.config.automation.editor.edit_ui")} ${this._mode === "gui" ? html`` : ``} - - + + ${this.hass.localize("ui.panel.config.automation.editor.edit_yaml")} ${this._mode === "yaml" ? html`` : ``} - +
  • - - + - - + ${this._config diff --git a/src/panels/config/cloud/account/cloud-account.ts b/src/panels/config/cloud/account/cloud-account.ts index 293576fa8f..8c81013cd2 100644 --- a/src/panels/config/cloud/account/cloud-account.ts +++ b/src/panels/config/cloud/account/cloud-account.ts @@ -1,9 +1,8 @@ import "@material/mwc-button"; -import { css, html, LitElement, PropertyValues } from "lit"; +import { css, html, LitElement } from "lit"; import { customElement, property, state } from "lit/decorators"; import { formatDateTime } from "../../../../common/datetime/format_date_time"; import { fireEvent } from "../../../../common/dom/fire_event"; -import { computeRTLDirection } from "../../../../common/util/compute_rtl"; import { debounce } from "../../../../common/util/debounce"; import "../../../../components/ha-alert"; import "../../../../components/ha-card"; @@ -37,8 +36,6 @@ export class CloudAccount extends SubscribeMixin(LitElement) { @state() private _subscription?: SubscriptionInfo; - @state() private _rtlDirection: "rtl" | "ltr" = "rtl"; - protected render() { return html` @@ -193,7 +188,6 @@ export class CloudAccount extends SubscribeMixin(LitElement) { .hass=${this.hass} .narrow=${this.narrow} .cloudStatus=${this.cloudStatus} - dir=${this._rtlDirection} >
    @@ -205,15 +199,6 @@ export class CloudAccount extends SubscribeMixin(LitElement) { this._fetchSubscriptionInfo(); } - protected updated(changedProps: PropertyValues) { - if (changedProps.has("hass")) { - const oldHass = changedProps.get("hass") as HomeAssistant | undefined; - if (!oldHass || oldHass.locale !== this.hass.locale) { - this._rtlDirection = computeRTLDirection(this.hass); - } - } - } - protected override hassSubscribe() { const googleCheck = debounce( () => { @@ -272,10 +257,6 @@ export class CloudAccount extends SubscribeMixin(LitElement) { fireEvent(this, "ha-refresh-cloud-status"); } - _computeRTLDirection(hass) { - return computeRTLDirection(hass); - } - static get styles() { return [ haStyle, diff --git a/src/panels/config/cloud/account/cloud-remote-pref.ts b/src/panels/config/cloud/account/cloud-remote-pref.ts index e5d0771b39..bcfb4bdde7 100644 --- a/src/panels/config/cloud/account/cloud-remote-pref.ts +++ b/src/panels/config/cloud/account/cloud-remote-pref.ts @@ -179,14 +179,12 @@ export class CloudRemotePref extends LitElement { .header-actions { position: absolute; right: 24px; + inset-inline-end: 24px; + inset-inline-start: initial; top: 24px; display: flex; flex-direction: row; } - :host([dir="rtl"]) .header-actions { - right: auto; - left: 24px; - } .header-actions .icon-link { margin-top: -16px; margin-right: 8px; diff --git a/src/panels/config/cloud/account/cloud-tts-pref.ts b/src/panels/config/cloud/account/cloud-tts-pref.ts index 052fad179b..c1e85fccdc 100644 --- a/src/panels/config/cloud/account/cloud-tts-pref.ts +++ b/src/panels/config/cloud/account/cloud-tts-pref.ts @@ -177,12 +177,10 @@ export class CloudTTSPref extends LitElement { .example { position: absolute; right: 16px; + inset-inline-end: 16px; + inset-inline-start: initial; top: 16px; } - :host([dir="rtl"]) .example { - right: auto; - left: 24px; - } .row { display: flex; } diff --git a/src/panels/config/devices/device-detail/integration-elements/mqtt/dialog-mqtt-device-debug-info.ts b/src/panels/config/devices/device-detail/integration-elements/mqtt/dialog-mqtt-device-debug-info.ts index 2a629114aa..3884f65b5d 100644 --- a/src/panels/config/devices/device-detail/integration-elements/mqtt/dialog-mqtt-device-debug-info.ts +++ b/src/panels/config/devices/device-detail/integration-elements/mqtt/dialog-mqtt-device-debug-info.ts @@ -9,7 +9,6 @@ import { } from "lit"; import { customElement, state } from "lit/decorators"; import { computeStateName } from "../../../../../../common/entity/compute_state_name"; -import { computeRTLDirection } from "../../../../../../common/util/compute_rtl"; import "../../../../../../components/ha-dialog"; import "../../../../../../components/ha-formfield"; import "../../../../../../components/ha-switch"; @@ -51,8 +50,6 @@ class DialogMQTTDeviceDebugInfo extends LitElement { return nothing; } - const dir = computeRTLDirection(this.hass!); - return html` diff --git a/src/panels/config/entities/ha-config-entities.ts b/src/panels/config/entities/ha-config-entities.ts index 187a8a14ef..0599d1e75e 100644 --- a/src/panels/config/entities/ha-config-entities.ts +++ b/src/panels/config/entities/ha-config-entities.ts @@ -35,7 +35,6 @@ import { } from "../../../common/integrations/protocolIntegrationPicked"; import { navigate } from "../../../common/navigate"; import { LocalizeFunc } from "../../../common/translations/localize"; -import { computeRTL } from "../../../common/util/compute_rtl"; import type { DataTableColumnContainer, RowClickedEvent, @@ -680,7 +679,6 @@ export class HaConfigEntities extends LitElement { extended @click=${this._addDevice} slot="fab" - ?rtl=${computeRTL(this.hass)} > ` diff --git a/src/panels/config/integrations/integration-panels/zha/zha-clusters-data-table.ts b/src/panels/config/integrations/integration-panels/zha/zha-clusters-data-table.ts index 60b8f82faf..1b14b676a8 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-clusters-data-table.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-clusters-data-table.ts @@ -1,7 +1,6 @@ import { html, LitElement, TemplateResult } from "lit"; import { customElement, property, query } from "lit/decorators"; import memoizeOne from "memoize-one"; -import { computeRTLDirection } from "../../../../../common/util/compute_rtl"; import "../../../../../components/data-table/ha-data-table"; import type { DataTableColumnContainer, @@ -82,7 +81,6 @@ export class ZHAClustersDataTable extends LitElement { .id=${"cluster_id"} selectable auto-height - .dir=${computeRTLDirection(this.hass)} .searchLabel=${this.hass.localize("ui.components.data-table.search")} .noDataText=${this.hass.localize("ui.components.data-table.no-data")} > diff --git a/src/panels/config/integrations/integration-panels/zha/zha-config-dashboard.ts b/src/panels/config/integrations/integration-panels/zha/zha-config-dashboard.ts index dbf0ae07a0..a8a7ed8a8c 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-config-dashboard.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-config-dashboard.ts @@ -19,7 +19,6 @@ import { ConfigEntry, getConfigEntries, } from "../../../../../data/config_entries"; -import { computeRTL } from "../../../../../common/util/compute_rtl"; import "../../../../../components/ha-card"; import "../../../../../components/ha-fab"; import "../../../../../components/ha-icon-button"; @@ -259,7 +258,6 @@ class ZHAConfigDashboard extends LitElement { diff --git a/src/panels/config/integrations/integration-panels/zha/zha-device-endpoint-data-table.ts b/src/panels/config/integrations/integration-panels/zha/zha-device-endpoint-data-table.ts index 78a4871dd5..d68fdb0b1e 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-device-endpoint-data-table.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-device-endpoint-data-table.ts @@ -1,7 +1,6 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property, query } from "lit/decorators"; import memoizeOne from "memoize-one"; -import { computeRTLDirection } from "../../../../../common/util/compute_rtl"; import "../../../../../components/data-table/ha-data-table"; import type { DataTableColumnContainer, @@ -142,7 +141,6 @@ export class ZHADeviceEndpointDataTable extends LitElement { .data=${this._deviceEndpoints(this.deviceEndpoints)} .selectable=${this.selectable} auto-height - .dir=${computeRTLDirection(this.hass)} .searchLabel=${this.hass.localize("ui.components.data-table.search")} .noDataText=${this.hass.localize("ui.components.data-table.no-data")} > diff --git a/src/panels/config/integrations/integration-panels/zha/zha-device-neighbors.ts b/src/panels/config/integrations/integration-panels/zha/zha-device-neighbors.ts index 64bec7d1bc..0774f8b343 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-device-neighbors.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-device-neighbors.ts @@ -1,7 +1,6 @@ import { html, LitElement, PropertyValues, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import memoizeOne from "memoize-one"; -import { computeRTLDirection } from "../../../../../common/util/compute_rtl"; import "../../../../../components/data-table/ha-data-table"; import type { DataTableColumnContainer, @@ -128,7 +127,6 @@ class ZHADeviceNeighbors extends LitElement { .columns=${this._columns(this.narrow)} .data=${this._deviceNeighbors(this.device, this._devices)} auto-height - .dir=${computeRTLDirection(this.hass)} .searchLabel=${this.hass.localize( "ui.components.data-table.search" )} diff --git a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-config-dashboard.ts b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-config-dashboard.ts index e7e8a21e0a..16f00a7178 100644 --- a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-config-dashboard.ts +++ b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-config-dashboard.ts @@ -18,7 +18,6 @@ import { } from "lit"; import { customElement, property, state } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; -import { computeRTL } from "../../../../../common/util/compute_rtl"; import "../../../../../components/ha-card"; import "../../../../../components/ha-expansion-panel"; import "../../../../../components/ha-fab"; @@ -472,7 +471,6 @@ class ZWaveJSConfigDashboard extends SubscribeMixin(LitElement) { "ui.panel.config.zwave_js.common.add_node" )} extended - ?rtl=${computeRTL(this.hass)} @click=${this._addNodeClicked} .disabled=${this._status !== "connected" || (this._network?.controller.inclusion_state !== InclusionState.Idle && diff --git a/src/panels/config/script/ha-script-picker.ts b/src/panels/config/script/ha-script-picker.ts index aa46a532a8..aca24a71ac 100644 --- a/src/panels/config/script/ha-script-picker.ts +++ b/src/panels/config/script/ha-script-picker.ts @@ -26,7 +26,6 @@ import { relativeTime } from "../../../common/datetime/relative_time"; import { HASSDomEvent, fireEvent } from "../../../common/dom/fire_event"; import { computeStateName } from "../../../common/entity/compute_state_name"; import { navigate } from "../../../common/navigate"; -import { computeRTL } from "../../../common/util/compute_rtl"; import { DataTableColumnContainer, RowClickedEvent, @@ -308,7 +307,6 @@ class HaScriptPicker extends LitElement { "ui.panel.config.script.picker.add_script" )} extended - ?rtl=${computeRTL(this.hass)} @click=${this._createNew} > diff --git a/src/panels/config/users/dialog-add-user.ts b/src/panels/config/users/dialog-add-user.ts index 3e63f216ee..e802ecdd51 100644 --- a/src/panels/config/users/dialog-add-user.ts +++ b/src/panels/config/users/dialog-add-user.ts @@ -8,7 +8,6 @@ import { nothing, } from "lit"; import { customElement, property, state } from "lit/decorators"; -import { computeRTLDirection } from "../../../common/util/compute_rtl"; import "../../../components/ha-circular-progress"; import { createCloseHeading } from "../../../components/ha-dialog"; import "../../../components/ha-formfield"; @@ -161,7 +160,6 @@ export class DialogAddUser extends LitElement { .label=${this.hass.localize( "ui.panel.config.users.editor.local_only" )} - .dir=${computeRTLDirection(this.hass)} > ` : html``} diff --git a/src/panels/config/voice-assistants/ha-config-voice-assistants-expose.ts b/src/panels/config/voice-assistants/ha-config-voice-assistants-expose.ts index 68204c96ad..46f4f6c372 100644 --- a/src/panels/config/voice-assistants/ha-config-voice-assistants-expose.ts +++ b/src/panels/config/voice-assistants/ha-config-voice-assistants-expose.ts @@ -27,7 +27,6 @@ import { isEmptyFilter, } from "../../../common/entity/entity_filter"; import { navigate } from "../../../common/navigate"; -import { computeRTL } from "../../../common/util/compute_rtl"; import { DataTableColumnContainer, DataTableRowData, @@ -618,7 +617,6 @@ export class VoiceAssistantsExpose extends LitElement { "ui.panel.config.voice_assistants.expose.add" )} extended - ?rtl=${computeRTL(this.hass)} @click=${this._addEntry} > diff --git a/src/panels/developer-tools/service/developer-tools-service.ts b/src/panels/developer-tools/service/developer-tools-service.ts index d920065d5a..fb5f374f21 100644 --- a/src/panels/developer-tools/service/developer-tools-service.ts +++ b/src/panels/developer-tools/service/developer-tools-service.ts @@ -588,13 +588,10 @@ class HaPanelDevService extends LitElement { } .attributes th { - text-align: left; + text-align: var(--float-start); background-color: var(--card-background-color); border-bottom: 1px solid var(--primary-text-color); - } - - :host([rtl]) .attributes th { - text-align: right; + direction: var(--direction); } .attributes tr { diff --git a/src/panels/developer-tools/state/developer-tools-state.ts b/src/panels/developer-tools/state/developer-tools-state.ts index d82d2bc2bb..dc7f04ed6a 100644 --- a/src/panels/developer-tools/state/developer-tools-state.ts +++ b/src/panels/developer-tools/state/developer-tools-state.ts @@ -16,9 +16,7 @@ import memoizeOne from "memoize-one"; import { formatDateTimeWithSeconds } from "../../../common/datetime/format_date_time"; import { storage } from "../../../common/decorators/storage"; import { fireEvent } from "../../../common/dom/fire_event"; -import { toggleAttribute } from "../../../common/dom/toggle_attribute"; import { escapeRegExp } from "../../../common/string/escape_regexp"; -import { computeRTL } from "../../../common/util/compute_rtl"; import { copyToClipboard } from "../../../common/util/copy-clipboard"; import "../../../components/entity/ha-entity-picker"; import "../../../components/ha-alert"; @@ -69,8 +67,6 @@ class HaPanelDevState extends LitElement { @property({ type: Boolean, reflect: true }) public narrow = false; - @property({ type: Boolean, reflect: true }) public rtl = false; - @query("ha-yaml-editor") private _yamlEditor?: HaYamlEditor; private _filteredEntities = memoizeOne( @@ -325,14 +321,6 @@ class HaPanelDevState extends LitElement { `; } - protected updated(changedProps) { - super.updated(changedProps); - const oldHass = changedProps.get("hass") as HomeAssistant | undefined; - if (!oldHass || oldHass.locale !== this.hass.locale) { - toggleAttribute(this, "rtl", computeRTL(this.hass)); - } - } - private _copyEntity(ev) { ev.preventDefault(); const entity = (ev.currentTarget! as any).entity; @@ -626,7 +614,8 @@ class HaPanelDevState extends LitElement { .entities th { padding: 0 8px; - text-align: left; + text-align: var(--float-start); + direction: var(--direction); } .filters th { @@ -652,15 +641,6 @@ class HaPanelDevState extends LitElement { bottom: -8px; } - :host([rtl]) .entities th { - text-align: right; - direction: rtl; - } - - :host([rtl]) .filters { - direction: rtl; - } - .entities tr { vertical-align: top; direction: ltr; diff --git a/src/panels/developer-tools/statistics/developer-tools-statistics.ts b/src/panels/developer-tools/statistics/developer-tools-statistics.ts index f85744ec45..0cb1399716 100644 --- a/src/panels/developer-tools/statistics/developer-tools-statistics.ts +++ b/src/panels/developer-tools/statistics/developer-tools-statistics.ts @@ -1,7 +1,7 @@ import "@material/mwc-button/mwc-button"; import { mdiSlopeUphill } from "@mdi/js"; import { HassEntity, UnsubscribeFunc } from "home-assistant-js-websocket"; -import { css, CSSResultGroup, html, LitElement } from "lit"; +import { CSSResultGroup, html, LitElement } from "lit"; import { customElement, property, state } from "lit/decorators"; import memoizeOne from "memoize-one"; import { fireEvent } from "../../../common/dom/fire_event"; @@ -26,7 +26,6 @@ import { haStyle } from "../../../resources/styles"; import { HomeAssistant } from "../../../types"; import { showStatisticsAdjustSumDialog } from "./show-dialog-statistics-adjust-sum"; import { showFixStatisticsUnitsChangedDialog } from "./show-dialog-statistics-fix-units-changed"; -import { computeRTLDirection } from "../../../common/util/compute_rtl"; import { documentationUrl } from "../../../util/documentation-url"; const FIX_ISSUES_ORDER = { @@ -183,7 +182,6 @@ class HaPanelDevStatistics extends SubscribeMixin(LitElement) { id="statistic_id" clickable @row-click=${this._rowClicked} - .dir=${computeRTLDirection(this.hass)} > `; } @@ -411,45 +409,7 @@ class HaPanelDevStatistics extends SubscribeMixin(LitElement) { }; static get styles(): CSSResultGroup { - return [ - haStyle, - css` - .content { - padding: 16px; - padding: max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-right)) - max(16px, env(safe-area-inset-bottom)) - max(16px, env(safe-area-inset-left)); - } - - th { - padding: 0 8px; - text-align: left; - } - - :host([rtl]) th { - text-align: right; - } - - tr { - vertical-align: top; - direction: ltr; - } - - tr:nth-child(odd) { - background-color: var(--table-row-background-color, #fff); - } - - tr:nth-child(even) { - background-color: var(--table-row-alternative-background-color, #eee); - } - td { - padding: 4px; - min-width: 200px; - word-break: break-word; - } - `, - ]; + return haStyle; } } diff --git a/src/panels/developer-tools/statistics/dialog-statistics-adjust-sum.ts b/src/panels/developer-tools/statistics/dialog-statistics-adjust-sum.ts index abc264adce..6ffa9790da 100644 --- a/src/panels/developer-tools/statistics/dialog-statistics-adjust-sum.ts +++ b/src/panels/developer-tools/statistics/dialog-statistics-adjust-sum.ts @@ -1,5 +1,4 @@ import "@material/mwc-button/mwc-button"; -import "@material/mwc-list/mwc-list-item"; import formatISO9075 from "date-fns/formatISO9075"; import { css, @@ -21,6 +20,7 @@ import "../../../components/ha-selector/ha-selector-datetime"; import "../../../components/ha-selector/ha-selector-number"; import "../../../components/ha-svg-icon"; import "../../../components/ha-icon-next"; +import "../../../components/ha-list-item"; import { adjustStatisticsSum, fetchStatistics, @@ -151,7 +151,7 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement { const stat = data[i]; const growth = Math.round(stat.change! * 100) / 100; rows.push(html` - - + `); } stats = html`${rows}`; @@ -413,7 +413,7 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement { ha-selector-number { margin-bottom: 20px; } - mwc-list-item { + ha-list-item { margin: 0 -24px; --mdc-list-side-padding: 24px; } diff --git a/src/panels/history/ha-panel-history.ts b/src/panels/history/ha-panel-history.ts index 56f8aeb77a..c97bf1c87d 100644 --- a/src/panels/history/ha-panel-history.ts +++ b/src/panels/history/ha-panel-history.ts @@ -15,7 +15,6 @@ import { extractSearchParamsObject, removeSearchParam, } from "../../common/url/search-params"; -import { computeRTL } from "../../common/util/compute_rtl"; import { MIN_TIME_BETWEEN_UPDATES } from "../../components/chart/ha-chart-base"; import "../../components/chart/state-history-charts"; import type { StateHistoryCharts } from "../../components/chart/state-history-charts"; @@ -355,15 +354,6 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { this._getHistory(); this._getStats(); } - - if (!changedProps.has("hass") && !changedProps.has("_entities")) { - return; - } - - const oldHass = changedProps.get("hass") as HomeAssistant | undefined; - if (!oldHass || oldHass.language !== this.hass.language) { - this.rtl = computeRTL(this.hass); - } } private _removeAll() { @@ -710,6 +700,7 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { ha-date-range-picker { margin-right: 0; margin-inline-end: 0; + margin-inline-start: initial; width: 100%; } } diff --git a/src/panels/lovelace/cards/energy/hui-energy-carbon-consumed-gauge-card.ts b/src/panels/lovelace/cards/energy/hui-energy-carbon-consumed-gauge-card.ts index b24df99a32..f7512fc981 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-carbon-consumed-gauge-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-carbon-consumed-gauge-card.ts @@ -215,6 +215,8 @@ class HuiEnergyCarbonGaugeCard ha-svg-icon { position: absolute; right: 4px; + inset-inline-end: 4px; + inset-inline-start: initial; top: 4px; color: var(--secondary-text-color); } diff --git a/src/panels/lovelace/cards/energy/hui-energy-grid-neutrality-gauge-card.ts b/src/panels/lovelace/cards/energy/hui-energy-grid-neutrality-gauge-card.ts index 1acb16fef7..558762ca15 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-grid-neutrality-gauge-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-grid-neutrality-gauge-card.ts @@ -192,6 +192,8 @@ class HuiEnergyGridGaugeCard ha-svg-icon { position: absolute; right: 4px; + inset-inline-end: 4px; + inset-inline-start: initial; top: 4px; color: var(--secondary-text-color); } diff --git a/src/panels/lovelace/cards/energy/hui-energy-self-sufficiency-gauge-card.ts b/src/panels/lovelace/cards/energy/hui-energy-self-sufficiency-gauge-card.ts index 1f87f7167f..e39450c4ff 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-self-sufficiency-gauge-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-self-sufficiency-gauge-card.ts @@ -255,6 +255,8 @@ class HuiEnergySelfSufficiencyGaugeCard ha-svg-icon { position: absolute; right: 4px; + inset-inline-end: 4px; + inset-inline-start: initial; top: 4px; color: var(--secondary-text-color); } diff --git a/src/panels/lovelace/cards/energy/hui-energy-solar-consumed-gauge-card.ts b/src/panels/lovelace/cards/energy/hui-energy-solar-consumed-gauge-card.ts index fb70fbcca4..78ffa6c750 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-solar-consumed-gauge-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-solar-consumed-gauge-card.ts @@ -194,6 +194,8 @@ class HuiEnergySolarGaugeCard ha-svg-icon { position: absolute; right: 4px; + inset-inline-end: 4px; + inset-inline-start: initial; top: 4px; color: var(--secondary-text-color); } diff --git a/src/panels/lovelace/cards/hui-tile-card.ts b/src/panels/lovelace/cards/hui-tile-card.ts index 98faa89eaf..b1c279091a 100644 --- a/src/panels/lovelace/cards/hui-tile-card.ts +++ b/src/panels/lovelace/cards/hui-tile-card.ts @@ -524,6 +524,8 @@ export class HuiTileCard extends LitElement implements LovelaceCard { position: absolute; top: -3px; right: -3px; + inset-inline-end: -3px; + inset-inline-start: initial; } .icon-container:not([role="button"]) { pointer-events: none; diff --git a/src/panels/lovelace/cards/hui-weather-forecast-card.ts b/src/panels/lovelace/cards/hui-weather-forecast-card.ts index 781f02bd42..3d0d2ac047 100644 --- a/src/panels/lovelace/cards/hui-weather-forecast-card.ts +++ b/src/panels/lovelace/cards/hui-weather-forecast-card.ts @@ -612,11 +612,6 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard { text-align: center; } - /* ============= RTL ============= */ - :host([rtl]) .temp-attribute { - text-align: left; - } - /* ============= NARROW ============= */ :host([narrow]) .icon-image { diff --git a/src/panels/lovelace/components/hui-generic-entity-row.ts b/src/panels/lovelace/components/hui-generic-entity-row.ts index f58677657e..262459b2be 100644 --- a/src/panels/lovelace/components/hui-generic-entity-row.ts +++ b/src/panels/lovelace/components/hui-generic-entity-row.ts @@ -13,7 +13,6 @@ import { DOMAINS_INPUT_ROW } from "../../../common/const"; import { toggleAttribute } from "../../../common/dom/toggle_attribute"; import { computeDomain } from "../../../common/entity/compute_domain"; import { computeStateName } from "../../../common/entity/compute_state_name"; -import { computeRTL } from "../../../common/util/compute_rtl"; import "../../../components/entity/state-badge"; import "../../../components/ha-relative-time"; import { ActionHandlerEvent } from "../../../data/lovelace/action_handler"; @@ -186,9 +185,6 @@ export class HuiGenericEntityRow extends LitElement { "no-secondary", !this.secondaryText && !this.config?.secondary_info ); - if (changedProps.has("hass")) { - toggleAttribute(this, "rtl", computeRTL(this.hass!)); - } } private _handleAction(ev: ActionHandlerEvent) { @@ -233,22 +229,11 @@ export class HuiGenericEntityRow extends LitElement { state-badge { flex: 0 0 40px; } - :host([rtl]) .flex { - margin-left: 0; - margin-right: 16px; - } - :host([rtl]) .flex ::slotted(*) { - margin-left: 0; - margin-right: 8px; - } .pointer { cursor: pointer; } .state { - text-align: right; - } - .state.rtl { - text-align: left; + text-align: var(--float-end); } .value { direction: ltr; diff --git a/src/panels/lovelace/editor/card-editor/hui-card-preview.ts b/src/panels/lovelace/editor/card-editor/hui-card-preview.ts index a1c9582900..72a652834a 100644 --- a/src/panels/lovelace/editor/card-editor/hui-card-preview.ts +++ b/src/panels/lovelace/editor/card-editor/hui-card-preview.ts @@ -1,6 +1,5 @@ import { PropertyValues, ReactiveElement } from "lit"; import { property } from "lit/decorators"; -import { computeRTL } from "../../../../common/util/compute_rtl"; import { LovelaceCardConfig } from "../../../../data/lovelace/config/card"; import { HomeAssistant } from "../../../../types"; import { createCardElement } from "../../create-element/create-card-element"; @@ -70,13 +69,6 @@ export class HuiCardPreview extends ReactiveElement { } if (changedProperties.has("hass")) { - const oldHass = changedProperties.get("hass") as - | HomeAssistant - | undefined; - if (!oldHass || oldHass.language !== this.hass!.language) { - this.style.direction = computeRTL(this.hass!) ? "rtl" : "ltr"; - } - if (this._element) { this._element.hass = this.hass; } diff --git a/src/panels/lovelace/editor/card-editor/hui-entity-picker-table.ts b/src/panels/lovelace/editor/card-editor/hui-entity-picker-table.ts index 997a4ec22d..51f42252c1 100644 --- a/src/panels/lovelace/editor/card-editor/hui-entity-picker-table.ts +++ b/src/panels/lovelace/editor/card-editor/hui-entity-picker-table.ts @@ -3,7 +3,6 @@ import { customElement, property } from "lit/decorators"; import memoizeOne from "memoize-one"; import type { HASSDomEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event"; -import { computeRTLDirection } from "../../../../common/util/compute_rtl"; import "../../../../components/data-table/ha-data-table"; import type { DataTableColumnContainer, @@ -33,7 +32,6 @@ export class HuiEntityPickerTable extends LitElement { .id=${"entity_id"} .columns=${this._columns(this.narrow!)} .data=${this.entities} - .dir=${computeRTLDirection(this.hass)} .searchLabel=${this.hass.localize( "ui.panel.lovelace.unused_entities.search" )} diff --git a/src/panels/lovelace/editor/config-elements/hui-entities-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-entities-card-editor.ts index 8e6eb4bbec..106b0b97ec 100644 --- a/src/panels/lovelace/editor/config-elements/hui-entities-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-entities-card-editor.ts @@ -18,7 +18,6 @@ import { } from "superstruct"; import { fireEvent, HASSDomEvent } from "../../../../common/dom/fire_event"; import { customType } from "../../../../common/structs/is-custom-type"; -import { computeRTLDirection } from "../../../../common/util/compute_rtl"; import "../../../../components/ha-card"; import "../../../../components/ha-formfield"; import "../../../../components/ha-icon"; @@ -265,7 +264,6 @@ export class HuiEntitiesCardEditor .label=${this.hass.localize( "ui.panel.lovelace.editor.card.entities.show_header_toggle" )} - .dir=${computeRTLDirection(this.hass)} >
    @@ -171,20 +169,13 @@ export class HuiUnusedEntities extends LitElement { } .fab { position: sticky; - float: right; + float: var(--float-end); right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); + inset-inline-end: calc(16px + env(safe-area-inset-right)); + inset-inline-start: initial; z-index: 1; } - .fab.rtl { - right: initial; - left: 0; - bottom: 0; - padding-right: 16px; - padding-left: calc(16px + env(safe-area-inset-left)); - padding-inline-end: 16px; - padding-inline-start: calc(16px + env(safe-area-inset-left)); - } ha-fab { position: relative; bottom: calc(-80px - env(safe-area-inset-bottom)); diff --git a/src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts b/src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts index 65c0ef1e27..f6888a5d02 100644 --- a/src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts @@ -7,7 +7,6 @@ import { nothing, } from "lit"; import { customElement, property, state } from "lit/decorators"; -import { computeRTLDirection } from "../../../common/util/compute_rtl"; import { debounce } from "../../../common/util/debounce"; import "../../../components/ha-slider"; import "../../../components/ha-textfield"; @@ -86,7 +85,6 @@ class HuiInputNumberEntityRow extends LitElement implements LovelaceRow {
    @@ -338,14 +333,11 @@ export class MasonryView extends LitElement implements LovelaceViewElement { position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); + inset-inline-end: calc(16px + env(safe-area-inset-right)); + inset-inline-start: initial; z-index: 1; } - ha-fab.rtl { - right: auto; - left: calc(16px + env(safe-area-inset-left)); - } - @media (max-width: 500px) { .column > * { margin-left: 0; diff --git a/src/panels/lovelace/views/hui-panel-view.ts b/src/panels/lovelace/views/hui-panel-view.ts index 2d36ba5178..aae451deaa 100644 --- a/src/panels/lovelace/views/hui-panel-view.ts +++ b/src/panels/lovelace/views/hui-panel-view.ts @@ -137,12 +137,9 @@ export class PanelView extends LitElement implements LovelaceViewElement { right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 1; - } - - ha-fab.rtl { - float: left; - right: auto; - left: calc(16px + env(safe-area-inset-left)); + float: var(--float-end); + inset-inline-end: calc(16px + env(safe-area-inset-right)); + inset-inline-start: initial; } `; } diff --git a/src/panels/lovelace/views/hui-sidebar-view.ts b/src/panels/lovelace/views/hui-sidebar-view.ts index f6085637da..1e8442880b 100644 --- a/src/panels/lovelace/views/hui-sidebar-view.ts +++ b/src/panels/lovelace/views/hui-sidebar-view.ts @@ -8,9 +8,7 @@ import { html, } from "lit"; import { property, state } from "lit/decorators"; -import { classMap } from "lit/directives/class-map"; import { fireEvent } from "../../../common/dom/fire_event"; -import { computeRTL } from "../../../common/util/compute_rtl"; import type { LovelaceViewElement } from "../../../data/lovelace"; import type { LovelaceViewConfig } from "../../../data/lovelace/config/view"; import type { HomeAssistant } from "../../../types"; @@ -100,9 +98,6 @@ export class SideBarView extends LitElement implements LovelaceViewElement { )} extended @click=${this._addCard} - class=${classMap({ - rtl: computeRTL(this.hass!), - })} > @@ -241,13 +236,10 @@ export class SideBarView extends LitElement implements LovelaceViewElement { position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); + inset-inline-end: calc(16px + env(safe-area-inset-right)); + inset-inline-start: initial; z-index: 1; } - - ha-fab.rtl { - right: auto; - left: calc(16px + env(safe-area-inset-left)); - } `; } } diff --git a/src/panels/todo/ha-panel-todo.ts b/src/panels/todo/ha-panel-todo.ts index 03a3e2b1fd..b1dcee7fb4 100644 --- a/src/panels/todo/ha-panel-todo.ts +++ b/src/panels/todo/ha-panel-todo.ts @@ -430,6 +430,8 @@ class PanelTodo extends LitElement { position: fixed; right: 16px; bottom: 16px; + inset-inline-end: 16px; + inset-inline-start: initial; } `, ]; diff --git a/src/resources/ha-sidebar-edit-style.ts b/src/resources/ha-sidebar-edit-style.ts index 50bf37c756..91d70bfa2b 100644 --- a/src/resources/ha-sidebar-edit-style.ts +++ b/src/resources/ha-sidebar-edit-style.ts @@ -62,22 +62,16 @@ export const sidebarEditStyle = css` position: absolute; top: 0; right: 4px; + inset-inline-end: 4px; + inset-inline-start: initial; --mdc-icon-button-size: 40px; } - :host([rtl]) .show-panel { - right: initial; - left: 4px; - } - .hide-panel { top: 4px; right: 8px; - } - - :host([rtl]) .hide-panel { - right: initial; - left: 8px; + inset-inline-end: 8px; + inset-inline-start: initial; } :host([expanded]) .hide-panel { diff --git a/src/state-summary/state-card-alert.ts b/src/state-summary/state-card-alert.ts index e6ee8d3e05..fb85350993 100755 --- a/src/state-summary/state-card-alert.ts +++ b/src/state-summary/state-card-alert.ts @@ -2,7 +2,6 @@ import type { HassEntity } from "home-assistant-js-websocket"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property } from "lit/decorators"; import { stateActive } from "../common/entity/state_active"; -import { computeRTL } from "../common/util/compute_rtl"; import "../components/entity/ha-entity-toggle"; import "../components/entity/state-info"; import { haStyle } from "../resources/styles"; @@ -16,9 +15,6 @@ class StateCardAlert extends LitElement { @property({ type: Boolean }) public inDialog = false; - // property used only in CSS - @property({ type: Boolean, reflect: true }) public rtl = false; - protected render(): TemplateResult { return html`
    @@ -40,18 +36,6 @@ class StateCardAlert extends LitElement { `; } - protected updated(changedProps) { - super.updated(changedProps); - if (!changedProps.has("hass")) { - return; - } - - const oldHass = changedProps.get("hass") as HomeAssistant | undefined; - if (!oldHass || oldHass.language !== this.hass.language) { - this.rtl = computeRTL(this.hass); - } - } - static get styles(): CSSResultGroup { return [ haStyle, @@ -69,7 +53,6 @@ class StateCardAlert extends LitElement { overflow-wrap: break-word; display: flex; align-items: center; - direction: ltr; } ha-entity-toggle { margin: -4px -16px -4px 0; diff --git a/src/state-summary/state-card-display.ts b/src/state-summary/state-card-display.ts index 7263ab30bd..fe232520bf 100755 --- a/src/state-summary/state-card-display.ts +++ b/src/state-summary/state-card-display.ts @@ -3,7 +3,6 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; import { computeDomain } from "../common/entity/compute_domain"; -import { computeRTL } from "../common/util/compute_rtl"; import "../components/entity/state-info"; import { isUnavailableState } from "../data/entity"; import { SENSOR_DEVICE_CLASS_TIMESTAMP } from "../data/sensor"; @@ -53,18 +52,6 @@ class StateCardDisplay extends LitElement { `; } - protected updated(changedProps) { - super.updated(changedProps); - if (!changedProps.has("hass")) { - return; - } - - const oldHass = changedProps.get("hass") as HomeAssistant | undefined; - if (!oldHass || oldHass.language !== this.hass.language) { - this.rtl = computeRTL(this.hass); - } - } - static get styles(): CSSResultGroup { return [ haStyle, @@ -83,7 +70,6 @@ class StateCardDisplay extends LitElement { word-break: break-word; display: flex; align-items: center; - direction: ltr; justify-content: flex-end; } .state.has-unit_of_measurement { diff --git a/src/state-summary/state-card-input_number.ts b/src/state-summary/state-card-input_number.ts index c5b2e177ec..884253d3e6 100644 --- a/src/state-summary/state-card-input_number.ts +++ b/src/state-summary/state-card-input_number.ts @@ -1,7 +1,6 @@ import { HassEntity } from "home-assistant-js-websocket"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property } from "lit/decorators"; -import { computeRTLDirection } from "../common/util/compute_rtl"; import { debounce } from "../common/util/debounce"; import "../components/entity/state-info"; import "../components/ha-slider"; @@ -58,7 +57,6 @@ class StateCardInputNumber extends LitElement {