Skip to content

Commit

Permalink
Add backward compatibility with 2024.7
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Jul 23, 2024
1 parent 59f8743 commit 436009f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/utils/base-element.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css, CSSResultGroup, LitElement, PropertyValues } from "lit";
import { property } from "lit/decorators.js";
import { HomeAssistant } from "../ha";
import { atLeastHaVersion, HomeAssistant } from "../ha";
import "../shared/badge-icon";
import "../shared/card";
import "../shared/shape-avatar";
Expand All @@ -18,6 +18,13 @@ export function computeDarkMode(hass?: HomeAssistant): boolean {
export class MushroomBaseElement extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;

protected firstUpdated(_changedProperties: PropertyValues): void {
this.toggleAttribute(
"pre-2024-8",
!atLeastHaVersion(this.hass.config.version, 2024, 8)
);
}

protected updated(changedProps: PropertyValues): void {
super.updated(changedProps);
if (changedProps.has("hass") && this.hass) {
Expand All @@ -43,6 +50,12 @@ export class MushroomBaseElement extends LitElement {
${themeColorCss}
${themeVariables}
}
:host([pre-2024-8]) {
--spacing: var(--mush-spacing, 12px);
--control-height: var(--mush-control-height, 40px);
--control-spacing: var(--mush-spacing, 12px);
--icon-size: var(--mush-icon-size, 40px);
}
`,
];
}
Expand Down

0 comments on commit 436009f

Please sign in to comment.