RTL arrow problems (#3467)

* Updated style check since load sequence must have changed

* Refactored to timeout

* Added comment
This commit is contained in:
Yosi Levy 2019-08-12 20:31:23 +03:00 committed by Paulus Schoutsen
parent 9fa8544972
commit 807dff99af
6 changed files with 52 additions and 40 deletions

View File

@ -5,13 +5,15 @@ import { HaIcon } from "./ha-icon";
export class HaIconNext extends HaIcon { export class HaIconNext extends HaIcon {
public connectedCallback() { public connectedCallback() {
this.icon =
window.getComputedStyle(this).direction === "ltr"
? "hass:chevron-right"
: "hass:chevron-left";
// calling super after setting icon to have it consistently show the icon (otherwise not always shown)
super.connectedCallback(); super.connectedCallback();
// wait to check for direction since otherwise direction is wrong even though top level is RTL
setTimeout(() => {
this.icon =
window.getComputedStyle(this).direction === "ltr"
? "hass:chevron-right"
: "hass:chevron-left";
}, 100);
} }
} }

View File

@ -5,13 +5,15 @@ import { HaIcon } from "./ha-icon";
export class HaIconPrev extends HaIcon { export class HaIconPrev extends HaIcon {
public connectedCallback() { public connectedCallback() {
this.icon =
window.getComputedStyle(this).direction === "ltr"
? "hass:chevron-left"
: "hass:chevron-right";
// calling super after setting icon to have it consistently show the icon (otherwise not always shown)
super.connectedCallback(); super.connectedCallback();
// wait to check for direction since otherwise direction is wrong even though top level is RTL
setTimeout(() => {
this.icon =
window.getComputedStyle(this).direction === "ltr"
? "hass:chevron-left"
: "hass:chevron-right";
}, 100);
} }
} }

View File

@ -10,13 +10,15 @@ const paperIconButtonClass = customElements.get(
export class HaPaperIconButtonArrowNext extends paperIconButtonClass { export class HaPaperIconButtonArrowNext extends paperIconButtonClass {
public connectedCallback() { public connectedCallback() {
this.icon =
window.getComputedStyle(this).direction === "ltr"
? "hass:arrow-right"
: "hass:arrow-left";
// calling super after setting icon to have it consistently show the icon (otherwise not always shown)
super.connectedCallback(); super.connectedCallback();
// wait to check for direction since otherwise direction is wrong even though top level is RTL
setTimeout(() => {
this.icon =
window.getComputedStyle(this).direction === "ltr"
? "hass:arrow-right"
: "hass:arrow-left";
}, 100);
} }
} }

View File

@ -12,17 +12,19 @@ export class HaPaperIconButtonArrowPrev extends paperIconButtonClass {
public hassio?: boolean; public hassio?: boolean;
public connectedCallback() { public connectedCallback() {
this.icon =
window.getComputedStyle(this).direction === "ltr"
? this.hassio
? "hassio:arrow-left"
: "hass:arrow-left"
: this.hassio
? "hassio:arrow-right"
: "hass:arrow-right";
// calling super after setting icon to have it consistently show the icon (otherwise not always shown)
super.connectedCallback(); super.connectedCallback();
// wait to check for direction since otherwise direction is wrong even though top level is RTL
setTimeout(() => {
this.icon =
window.getComputedStyle(this).direction === "ltr"
? this.hassio
? "hassio:arrow-left"
: "hass:arrow-left"
: this.hassio
? "hassio:arrow-right"
: "hass:arrow-right";
}, 100);
} }
} }

View File

@ -10,13 +10,15 @@ const paperIconButtonClass = customElements.get(
export class HaPaperIconButtonNext extends paperIconButtonClass { export class HaPaperIconButtonNext extends paperIconButtonClass {
public connectedCallback() { public connectedCallback() {
this.icon =
window.getComputedStyle(this).direction === "ltr"
? "hass:chevron-right"
: "hass:chevron-left";
// calling super after setting icon to have it consistently show the icon (otherwise not always shown)
super.connectedCallback(); super.connectedCallback();
// wait to check for direction since otherwise direction is wrong even though top level is RTL
setTimeout(() => {
this.icon =
window.getComputedStyle(this).direction === "ltr"
? "hass:chevron-right"
: "hass:chevron-left";
}, 100);
} }
} }

View File

@ -10,13 +10,15 @@ const paperIconButtonClass = customElements.get(
export class HaPaperIconButtonPrev extends paperIconButtonClass { export class HaPaperIconButtonPrev extends paperIconButtonClass {
public connectedCallback() { public connectedCallback() {
this.icon =
window.getComputedStyle(this).direction === "ltr"
? "hass:chevron-left"
: "hass:chevron-right";
// calling super after setting icon to have it consistently show the icon (otherwise not always shown)
super.connectedCallback(); super.connectedCallback();
// wait to check for direction since otherwise direction is wrong even though top level is RTL
setTimeout(() => {
this.icon =
window.getComputedStyle(this).direction === "ltr"
? "hass:chevron-left"
: "hass:chevron-right";
}, 100);
} }
} }