mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-27 23:07:20 +00:00
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import {
|
|
LitElement,
|
|
property,
|
|
internalProperty,
|
|
TemplateResult,
|
|
html,
|
|
customElement,
|
|
} from "lit-element";
|
|
import { mdiChevronRight, mdiChevronLeft } from "@mdi/js";
|
|
import "@material/mwc-icon-button/mwc-icon-button";
|
|
import "./ha-svg-icon";
|
|
import { HomeAssistant } from "../types";
|
|
|
|
@customElement("ha-icon-button-prev")
|
|
export class HaIconButtonPrev extends LitElement {
|
|
@property({ attribute: false }) public hass?: HomeAssistant;
|
|
|
|
@property({ type: Boolean }) public disabled = false;
|
|
|
|
@property() public label?: string;
|
|
|
|
@internalProperty() private _icon = 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"
|
|
? mdiChevronLeft
|
|
: mdiChevronRight;
|
|
}, 100);
|
|
}
|
|
|
|
protected render(): TemplateResult {
|
|
return html`
|
|
<mwc-icon-button
|
|
.disabled=${this.disabled}
|
|
.label=${this.label || this.hass?.localize("ui.common.back") || "Back"}
|
|
>
|
|
<ha-svg-icon .path=${this._icon}></ha-svg-icon>
|
|
</mwc-icon-button>
|
|
`;
|
|
}
|
|
}
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
"ha-icon-button-prev": HaIconButtonPrev;
|
|
}
|
|
}
|