This commit is contained in:
Bram Kragten 2022-05-11 14:16:44 +02:00
parent 7db28c0156
commit 96d375cb84
No known key found for this signature in database
GPG Key ID: FBE2DFDB363EF55B
2 changed files with 8 additions and 15 deletions

View File

@ -12,8 +12,9 @@ export class HaFab extends Fab {
static override styles = Fab.styles.concat([ static override styles = Fab.styles.concat([
css` css`
.mdc-fab--extended .mdc-fab__icon { .mdc-fab--extended .mdc-fab__icon {
margin-left: var(--rtl-12px, -8px) !important; margin-inline-start: -8px !important;
margin-right: var(--rtl--8px, 12px) !important; margin-inline-end: 12px !important;
direction: var(--direction) !important;
} }
`, `,
]); ]);

View File

@ -1,6 +1,6 @@
import { atLeastVersion } from "../common/config/version"; import { atLeastVersion } from "../common/config/version";
import { computeLocalize, LocalizeFunc } from "../common/translations/localize"; import { computeLocalize, LocalizeFunc } from "../common/translations/localize";
import { computeRTL } from "../common/util/compute_rtl"; import { computeRTLDirection } from "../common/util/compute_rtl";
import { debounce } from "../common/util/debounce"; import { debounce } from "../common/util/debounce";
import { import {
getHassTranslations, getHassTranslations,
@ -187,18 +187,10 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
} }
private _applyDirection(hass: HomeAssistant) { private _applyDirection(hass: HomeAssistant) {
if (computeRTL(hass)) { const direction = computeRTLDirection(hass);
this.style.direction = "rtl"; this.style.direction = direction;
// apply custom properties used to fix RTL appearance throughout the system document.dir = direction;
this.style.setProperty("--rtl-12px", "12px"); this.style.setProperty("--direction", direction);
this.style.setProperty("--rtl--8px", "-8px");
this.style.setProperty("--dir", "rtl");
} else {
// clear all custom properties (can't use "all" for this)
this.style.cssText = "";
this.style.direction = "ltr";
}
} }
/** /**