RTL fixes for raw config editor and card editor -> card preview (#2532)

* RTL fixes for raw config editor and card editor -> card preview

* Fixed missing line break

* Fixed weird vscode line break problems

* Refactored to LitElement + addressed updating RTL only when needed

* Refactor

* Fixed forgotten import

* Reverted to HTMLElement + added RTL check in set hass

* Added conditional update
This commit is contained in:
yosilevy 2019-02-01 19:53:08 +02:00 committed by Paulus Schoutsen
parent 25a579f7ed
commit e2ff51f425
3 changed files with 13 additions and 3 deletions

View File

@ -7,3 +7,7 @@ export function computeRTL(hass: HomeAssistant) {
}
return false;
}
export function computeRTLDirection(hass: HomeAssistant) {
return computeRTL(hass) ? "rtl" : "ltr";
}

View File

@ -9,15 +9,20 @@ import { LovelaceCard } from "../../types";
import { ConfigError } from "../types";
import { getCardElementTag } from "../../common/get-card-element-tag";
import { createErrorCardConfig } from "../../cards/hui-error-card";
import { computeRTL } from "../../../../common/util/compute_rtl";
export class HuiCardPreview extends HTMLElement {
private _hass?: HomeAssistant;
private _element?: LovelaceCard;
set hass(value: HomeAssistant) {
this._hass = value;
set hass(hass: HomeAssistant) {
if (!this._hass || this._hass.language !== hass.language) {
this.style.direction = computeRTL(hass) ? "rtl" : "ltr";
}
this._hass = hass;
if (this._element) {
this._element.hass = value;
this._element.hass = hass;
}
}

View File

@ -99,6 +99,7 @@ class LovelaceFullConfigEditor extends LitElement {
.content {
height: calc(100vh - 68px);
direction: ltr;
}
hui-code-editor {