mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 14:56:37 +00:00
Replace host-context with css properties
This commit is contained in:
parent
552c474feb
commit
6c73ae5bf7
@ -11,11 +11,9 @@ export class HaFab extends Fab {
|
|||||||
|
|
||||||
static override styles = Fab.styles.concat([
|
static override styles = Fab.styles.concat([
|
||||||
css`
|
css`
|
||||||
:host-context([style*="direction: rtl;"])
|
.mdc-fab--extended .mdc-fab__icon {
|
||||||
.mdc-fab--extended
|
margin-left: var(--rtl-12px, calc(12px - 20px)) !important;
|
||||||
.mdc-fab__icon {
|
margin-right: var(--rtl--8px, 12px) !important;
|
||||||
margin-left: 12px !important;
|
|
||||||
margin-right: calc(12px - 20px) !important;
|
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
]);
|
]);
|
||||||
|
@ -235,8 +235,8 @@ class ErrorLogCard extends LitElement {
|
|||||||
color: var(--warning-color);
|
color: var(--warning-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
:host-context([style*="direction: rtl;"]) mwc-button {
|
mwc-button {
|
||||||
direction: rtl;
|
direction: var(--rtl-dir, ltr);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -180,12 +180,29 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
|||||||
|
|
||||||
private _applyTranslations(hass: HomeAssistant) {
|
private _applyTranslations(hass: HomeAssistant) {
|
||||||
document.querySelector("html")!.setAttribute("lang", hass.language);
|
document.querySelector("html")!.setAttribute("lang", hass.language);
|
||||||
this.style.direction = computeRTL(hass) ? "rtl" : "ltr";
|
this._applyDirection(hass);
|
||||||
this._loadCoreTranslations(hass.language);
|
this._loadCoreTranslations(hass.language);
|
||||||
this.__loadedFragmetTranslations = new Set();
|
this.__loadedFragmetTranslations = new Set();
|
||||||
this._loadFragmentTranslations(hass.language, hass.panelUrl);
|
this._loadFragmentTranslations(hass.language, hass.panelUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _applyDirection(hass: HomeAssistant) {
|
||||||
|
if (computeRTL(hass)) {
|
||||||
|
this.style.direction = "rtl";
|
||||||
|
// apply custom properties used to fix RTL appearance throughout the system
|
||||||
|
this.style.setProperty("--rtl-12px", "12px");
|
||||||
|
this.style.setProperty("--rtl--8px", "-8px");
|
||||||
|
this.style.setProperty("--rtl-dir", "rtl");
|
||||||
|
} else {
|
||||||
|
// clear all custom properties (can't use "all" for this)
|
||||||
|
for (let i = this.style.length; i--; ) {
|
||||||
|
this.style.removeProperty(this.style[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.style.direction = "ltr";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load translations from the backend
|
* Load translations from the backend
|
||||||
* @param language language to fetch
|
* @param language language to fetch
|
||||||
|
Loading…
x
Reference in New Issue
Block a user