mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Default to ltr
for reading direction (#18767)
This commit is contained in:
parent
44157a5df3
commit
7356db919a
@ -3,6 +3,7 @@ import "@material/mwc-menu";
|
|||||||
import type { Corner, Menu, MenuCorner } from "@material/mwc-menu";
|
import type { Corner, Menu, MenuCorner } from "@material/mwc-menu";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property, query } from "lit/decorators";
|
import { customElement, property, query } from "lit/decorators";
|
||||||
|
import { mainWindow } from "../common/dom/get_main_window";
|
||||||
import { FOCUS_TARGET } from "../dialogs/make-dialog-manager";
|
import { FOCUS_TARGET } from "../dialogs/make-dialog-manager";
|
||||||
import type { HaIconButton } from "./ha-icon-button";
|
import type { HaIconButton } from "./ha-icon-button";
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ export class HaButtonMenu extends LitElement {
|
|||||||
protected firstUpdated(changedProps): void {
|
protected firstUpdated(changedProps): void {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
|
|
||||||
if (document.dir === "rtl") {
|
if (mainWindow.document.dir === "rtl") {
|
||||||
this.updateComplete.then(() => {
|
this.updateComplete.then(() => {
|
||||||
this.querySelectorAll("mwc-list-item").forEach((item) => {
|
this.querySelectorAll("mwc-list-item").forEach((item) => {
|
||||||
const style = document.createElement("style");
|
const style = document.createElement("style");
|
||||||
|
@ -2,6 +2,7 @@ import { FabBase } from "@material/mwc-fab/mwc-fab-base";
|
|||||||
import { styles } from "@material/mwc-fab/mwc-fab.css";
|
import { styles } from "@material/mwc-fab/mwc-fab.css";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
import { css } from "lit";
|
import { css } from "lit";
|
||||||
|
import { mainWindow } from "../common/dom/get_main_window";
|
||||||
|
|
||||||
@customElement("ha-fab")
|
@customElement("ha-fab")
|
||||||
export class HaFab extends FabBase {
|
export class HaFab extends FabBase {
|
||||||
@ -20,7 +21,7 @@ export class HaFab extends FabBase {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
// safari workaround - must be explicit
|
// safari workaround - must be explicit
|
||||||
document.dir === "rtl"
|
mainWindow.document.dir === "rtl"
|
||||||
? css`
|
? css`
|
||||||
:host .mdc-fab--extended .mdc-fab__icon {
|
:host .mdc-fab--extended .mdc-fab__icon {
|
||||||
direction: rtl;
|
direction: rtl;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { mdiArrowLeft, mdiArrowRight } from "@mdi/js";
|
import { mdiArrowLeft, mdiArrowRight } from "@mdi/js";
|
||||||
import { html, LitElement, TemplateResult } from "lit";
|
import { html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import { mainWindow } from "../common/dom/get_main_window";
|
||||||
import { HomeAssistant } from "../types";
|
import { HomeAssistant } from "../types";
|
||||||
import "./ha-icon-button";
|
import "./ha-icon-button";
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ export class HaIconButtonArrowNext extends LitElement {
|
|||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
@state() private _icon =
|
@state() private _icon =
|
||||||
document.dir === "ltr" ? mdiArrowRight : mdiArrowLeft;
|
mainWindow.document.dir === "rtl" ? mdiArrowLeft : mdiArrowRight;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { mdiArrowLeft, mdiArrowRight } from "@mdi/js";
|
import { mdiArrowLeft, mdiArrowRight } from "@mdi/js";
|
||||||
import { html, LitElement, TemplateResult } from "lit";
|
import { html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import { mainWindow } from "../common/dom/get_main_window";
|
||||||
import { HomeAssistant } from "../types";
|
import { HomeAssistant } from "../types";
|
||||||
import "./ha-icon-button";
|
import "./ha-icon-button";
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ export class HaIconButtonArrowPrev extends LitElement {
|
|||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
@state() private _icon =
|
@state() private _icon =
|
||||||
document.dir === "ltr" ? mdiArrowLeft : mdiArrowRight;
|
mainWindow.document.dir === "rtl" ? mdiArrowRight : mdiArrowLeft;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { mdiChevronLeft, mdiChevronRight } from "@mdi/js";
|
import { mdiChevronLeft, mdiChevronRight } from "@mdi/js";
|
||||||
import { html, LitElement, TemplateResult } from "lit";
|
import { html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import { mainWindow } from "../common/dom/get_main_window";
|
||||||
import { HomeAssistant } from "../types";
|
import { HomeAssistant } from "../types";
|
||||||
import "./ha-icon-button";
|
import "./ha-icon-button";
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ export class HaIconButtonNext extends LitElement {
|
|||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
@state() private _icon =
|
@state() private _icon =
|
||||||
document.dir === "ltr" ? mdiChevronRight : mdiChevronLeft;
|
mainWindow.document.dir === "rtl" ? mdiChevronLeft : mdiChevronRight;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { mdiChevronLeft, mdiChevronRight } from "@mdi/js";
|
import { mdiChevronLeft, mdiChevronRight } from "@mdi/js";
|
||||||
import { html, LitElement, TemplateResult } from "lit";
|
import { html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import { mainWindow } from "../common/dom/get_main_window";
|
||||||
import { HomeAssistant } from "../types";
|
import { HomeAssistant } from "../types";
|
||||||
import "./ha-icon-button";
|
import "./ha-icon-button";
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ export class HaIconButtonPrev extends LitElement {
|
|||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
@state() private _icon =
|
@state() private _icon =
|
||||||
document.dir === "ltr" ? mdiChevronLeft : mdiChevronRight;
|
mainWindow.document.dir === "rtl" ? mdiChevronRight : mdiChevronLeft;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { mdiChevronLeft, mdiChevronRight } from "@mdi/js";
|
import { mdiChevronLeft, mdiChevronRight } from "@mdi/js";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import { mainWindow } from "../common/dom/get_main_window";
|
||||||
import { HaSvgIcon } from "./ha-svg-icon";
|
import { HaSvgIcon } from "./ha-svg-icon";
|
||||||
|
|
||||||
@customElement("ha-icon-next")
|
@customElement("ha-icon-next")
|
||||||
export class HaIconNext extends HaSvgIcon {
|
export class HaIconNext extends HaSvgIcon {
|
||||||
@property() public override path =
|
@property() public override path =
|
||||||
document.dir === "ltr" ? mdiChevronRight : mdiChevronLeft;
|
mainWindow.document.dir === "rtl" ? mdiChevronLeft : mdiChevronRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { mdiChevronLeft, mdiChevronRight } from "@mdi/js";
|
import { mdiChevronLeft, mdiChevronRight } from "@mdi/js";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import { mainWindow } from "../common/dom/get_main_window";
|
||||||
import { HaSvgIcon } from "./ha-svg-icon";
|
import { HaSvgIcon } from "./ha-svg-icon";
|
||||||
|
|
||||||
@customElement("ha-icon-prev")
|
@customElement("ha-icon-prev")
|
||||||
export class HaIconPrev extends HaSvgIcon {
|
export class HaIconPrev extends HaSvgIcon {
|
||||||
@property() public override path =
|
@property() public override path =
|
||||||
document.dir === "ltr" ? mdiChevronLeft : mdiChevronRight;
|
mainWindow.document.dir === "rtl" ? mdiChevronRight : mdiChevronLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -3,6 +3,7 @@ import { styles as textfieldStyles } from "@material/mwc-textfield/mwc-textfield
|
|||||||
import { styles as textareaStyles } from "@material/mwc-textarea/mwc-textarea.css";
|
import { styles as textareaStyles } from "@material/mwc-textarea/mwc-textarea.css";
|
||||||
import { css, PropertyValues } from "lit";
|
import { css, PropertyValues } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import { mainWindow } from "../common/dom/get_main_window";
|
||||||
|
|
||||||
@customElement("ha-textarea")
|
@customElement("ha-textarea")
|
||||||
export class HaTextArea extends TextAreaBase {
|
export class HaTextArea extends TextAreaBase {
|
||||||
@ -11,7 +12,7 @@ export class HaTextArea extends TextAreaBase {
|
|||||||
firstUpdated() {
|
firstUpdated() {
|
||||||
super.firstUpdated();
|
super.firstUpdated();
|
||||||
|
|
||||||
this.setAttribute("dir", document.dir);
|
this.setAttribute("dir", mainWindow.document.dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
updated(changedProperties: PropertyValues) {
|
updated(changedProperties: PropertyValues) {
|
||||||
|
@ -2,6 +2,7 @@ import { TextFieldBase } from "@material/mwc-textfield/mwc-textfield-base";
|
|||||||
import { styles } from "@material/mwc-textfield/mwc-textfield.css";
|
import { styles } from "@material/mwc-textfield/mwc-textfield.css";
|
||||||
import { TemplateResult, html, PropertyValues, css } from "lit";
|
import { TemplateResult, html, PropertyValues, css } from "lit";
|
||||||
import { customElement, property, query } from "lit/decorators";
|
import { customElement, property, query } from "lit/decorators";
|
||||||
|
import { mainWindow } from "../common/dom/get_main_window";
|
||||||
|
|
||||||
@customElement("ha-textfield")
|
@customElement("ha-textfield")
|
||||||
export class HaTextField extends TextFieldBase {
|
export class HaTextField extends TextFieldBase {
|
||||||
@ -194,7 +195,7 @@ export class HaTextField extends TextFieldBase {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
// safari workaround - must be explicit
|
// safari workaround - must be explicit
|
||||||
document.dir === "rtl"
|
mainWindow.document.dir === "rtl"
|
||||||
? css`
|
? css`
|
||||||
.mdc-text-field__affix--suffix,
|
.mdc-text-field__affix--suffix,
|
||||||
.mdc-text-field--with-leading-icon,
|
.mdc-text-field--with-leading-icon,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user