Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch direction attribute #298

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class SliderEntityRow extends LitElement {
@property() hide_state: boolean;
@query("ha-slider") _slider?;

getDirection() {
const dir =
this.ctrl.dir ??
this.hass.translationMetadata.translations[this.hass.language || "en"]
.isRTL
? "rtl"
: "ltr";
return dir;
}

setConfig(config: ControllerConfig) {
this._config = config;
if (!config.entity) throw new Error(`No entity specified.`);
Expand Down Expand Up @@ -58,6 +68,7 @@ class SliderEntityRow extends LitElement {
async connectedCallback() {
super.connectedCallback();
await this.resized();
this._slider?.setAttribute("dir", this.getDirection());
}

render() {
Expand All @@ -74,12 +85,7 @@ class SliderEntityRow extends LitElement {
</hui-warning>
`;

const dir =
c.dir ??
this.hass.translationMetadata.translations[this.hass.language || "en"]
.isRTL
? "rtl"
: "ltr";
const dir = this.getDirection();

const showSlider =
c.stateObj.state !== "unavailable" &&
Expand Down