Make the "icon next/prev" series load faster (#18087)

This commit is contained in:
Kendell R 2023-10-04 04:59:51 -07:00 committed by GitHub
parent c25447d001
commit 242b018ece
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 74 deletions

View File

@ -12,19 +12,8 @@ export class HaIconButtonArrowNext extends LitElement {
@property() public label?: string; @property() public label?: string;
@state() private _icon = mdiArrowRight; @state() private _icon =
document.dir === "ltr" ? mdiArrowRight : mdiArrowLeft;
public 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"
? mdiArrowRight
: mdiArrowLeft;
}, 100);
}
protected render(): TemplateResult { protected render(): TemplateResult {
return html` return html`

View File

@ -12,19 +12,8 @@ export class HaIconButtonArrowPrev extends LitElement {
@property() public label?: string; @property() public label?: string;
@state() private _icon = mdiArrowLeft; @state() private _icon =
document.dir === "ltr" ? mdiArrowLeft : mdiArrowRight;
public 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"
? mdiArrowLeft
: mdiArrowRight;
}, 100);
}
protected render(): TemplateResult { protected render(): TemplateResult {
return html` return html`

View File

@ -12,19 +12,8 @@ export class HaIconButtonNext extends LitElement {
@property() public label?: string; @property() public label?: string;
@state() private _icon = mdiChevronRight; @state() private _icon =
document.dir === "ltr" ? mdiChevronRight : mdiChevronLeft;
public 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"
? mdiChevronRight
: mdiChevronLeft;
}, 100);
}
protected render(): TemplateResult { protected render(): TemplateResult {
return html` return html`

View File

@ -12,19 +12,8 @@ export class HaIconButtonPrev extends LitElement {
@property() public label?: string; @property() public label?: string;
@state() private _icon = mdiChevronLeft; @state() private _icon =
document.dir === "ltr" ? mdiChevronLeft : mdiChevronRight;
public 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"
? mdiChevronLeft
: mdiChevronRight;
}, 100);
}
protected render(): TemplateResult { protected render(): TemplateResult {
return html` return html`

View File

@ -4,17 +4,7 @@ import { HaSvgIcon } from "./ha-svg-icon";
@customElement("ha-icon-next") @customElement("ha-icon-next")
export class HaIconNext extends HaSvgIcon { export class HaIconNext extends HaSvgIcon {
public connectedCallback() { path = document.dir === "ltr" ? mdiChevronRight : mdiChevronLeft;
super.connectedCallback();
// wait to check for direction since otherwise direction is wrong even though top level is RTL
setTimeout(() => {
this.path =
window.getComputedStyle(this).direction === "ltr"
? mdiChevronRight
: mdiChevronLeft;
}, 100);
}
} }
declare global { declare global {

View File

@ -4,17 +4,7 @@ import { HaSvgIcon } from "./ha-svg-icon";
@customElement("ha-icon-prev") @customElement("ha-icon-prev")
export class HaIconPrev extends HaSvgIcon { export class HaIconPrev extends HaSvgIcon {
public connectedCallback() { path = document.dir === "ltr" ? mdiChevronLeft : mdiChevronRight;
super.connectedCallback();
// wait to check for direction since otherwise direction is wrong even though top level is RTL
setTimeout(() => {
this.path =
window.getComputedStyle(this).direction === "ltr"
? mdiChevronLeft
: mdiChevronRight;
}, 100);
}
} }
declare global { declare global {