mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-31 13:07:49 +00:00
RTL fix for range list
This commit is contained in:
parent
894f4379e6
commit
7bced28327
@ -8,6 +8,7 @@ import {
|
||||
TemplateResult,
|
||||
PropertyValues,
|
||||
} from "lit-element";
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
import { HomeAssistant } from "../types";
|
||||
import { mdiCalendar } from "@mdi/js";
|
||||
import { formatDateTime } from "../common/datetime/format_date_time";
|
||||
@ -17,6 +18,7 @@ import "./ha-svg-icon";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "@material/mwc-list/mwc-list";
|
||||
import "./date-range-picker";
|
||||
import { computeRTL } from "../common/util/compute_rtl";
|
||||
|
||||
export interface DateRangePickerRanges {
|
||||
[key: string]: [Date, Date];
|
||||
@ -36,12 +38,17 @@ export class HaDateRangePicker extends LitElement {
|
||||
|
||||
@property({ type: Boolean }) private _hour24format = false;
|
||||
|
||||
@property({ type: Boolean }) private _rtl = false;
|
||||
|
||||
protected updated(changedProps: PropertyValues) {
|
||||
if (changedProps.has("hass")) {
|
||||
const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
|
||||
if (!oldHass || oldHass.language !== this.hass.language) {
|
||||
this._hour24format = this._compute24hourFormat();
|
||||
}
|
||||
if (!oldHass || computeRTL(oldHass) !== computeRTL(this.hass)) {
|
||||
this._rtl = computeRTL(this.hass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,7 +83,10 @@ export class HaDateRangePicker extends LitElement {
|
||||
></paper-input>
|
||||
</div>
|
||||
${this.ranges
|
||||
? html`<div slot="ranges" class="date-range-ranges">
|
||||
? html`<div
|
||||
slot="ranges"
|
||||
class=${classMap({ "date-range-ranges": true, rtl: this._rtl })}
|
||||
>
|
||||
<mwc-list @click=${this._setDateRange}>
|
||||
${Object.entries(this.ranges).map(
|
||||
([name, dates]) => html`<mwc-list-item
|
||||
@ -161,6 +171,9 @@ export class HaDateRangePicker extends LitElement {
|
||||
.date-range-ranges {
|
||||
border-right: 1px solid var(--divider-color);
|
||||
}
|
||||
.date-range-ranges.rtl {
|
||||
direction: rtl;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 800px) {
|
||||
.date-range-ranges {
|
||||
|
Loading…
x
Reference in New Issue
Block a user