Set defaults for background settings, restore old behavior (#23436)

Fixes https://github.com/home-assistant/frontend/issues/23421
This commit is contained in:
Bram Kragten 2024-12-24 14:48:28 +01:00 committed by GitHub
parent a6a76155e5
commit 44423812f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 9 deletions

View File

@ -115,14 +115,24 @@ export class HuiViewBackgroundEditor extends LitElement {
};
}
background = {
transparency: 100,
alignment: "center",
size: "auto",
repeat: "no-repeat",
attachment: "scroll",
...background,
};
if (!background) {
background = {
transparency: 33,
alignment: "center",
size: "cover",
repeat: "repeat",
attachment: "fixed",
};
} else {
background = {
transparency: 100,
alignment: "center",
size: "cover",
repeat: "no-repeat",
attachment: "scroll",
...background,
};
}
return html`
<ha-form

View File

@ -52,8 +52,8 @@ export class HUIViewBackground extends LitElement {
background?: string | LovelaceViewBackgroundConfig
) {
if (typeof background === "object" && background.image) {
const size = background.size ?? "auto";
const alignment = background.alignment ?? "center";
const size = background.size ?? "cover";
const repeat = background.repeat ?? "no-repeat";
return `${alignment} / ${size} ${repeat} url('${background.image}')`;
}