From e6c0a8499455c4af308267c53eaedcd889fbd940 Mon Sep 17 00:00:00 2001 From: Aidan Timson Date: Wed, 5 Nov 2025 06:07:43 +0000 Subject: [PATCH] Add hide background option to iframe card (#27792) * Add hide background option to iframe card * Fix * Add helper --- src/panels/lovelace/cards/hui-iframe-card.ts | 12 +++++++- src/panels/lovelace/cards/types.ts | 1 + .../config-elements/hui-iframe-card-editor.ts | 28 +++++++++++++++++-- src/translations/en.json | 4 ++- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/panels/lovelace/cards/hui-iframe-card.ts b/src/panels/lovelace/cards/hui-iframe-card.ts index 63955f93dc..fa0ce0d932 100644 --- a/src/panels/lovelace/cards/hui-iframe-card.ts +++ b/src/panels/lovelace/cards/hui-iframe-card.ts @@ -1,5 +1,6 @@ import { css, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; +import { classMap } from "lit/directives/class-map"; import { ifDefined } from "lit/directives/if-defined"; import { styleMap } from "lit/directives/style-map"; import parseAspectRatio from "../../../common/util/parse-aspect-ratio"; @@ -97,7 +98,10 @@ export class HuiIframeCard extends LitElement implements LovelaceCard { : `${sandbox_user_params} ${IFRAME_SANDBOX}`; return html` - +
`; @@ -65,8 +68,29 @@ export class HuiIframeCardEditor fireEvent(this, "config-changed", { config: ev.detail.value }); } - private _computeLabelCallback = (schema: SchemaUnion) => - this.hass!.localize(`ui.panel.lovelace.editor.card.generic.${schema.name}`); + private _computeLabelCallback = (schema: SchemaUnion) => { + switch (schema.name) { + case "hide_background": + return this.hass!.localize( + "ui.panel.lovelace.editor.card.iframe.hide_background" + ); + default: + return this.hass!.localize( + `ui.panel.lovelace.editor.card.generic.${schema.name}` + ); + } + }; + + private _computeHelperCallback = (schema: SchemaUnion) => { + switch (schema.name) { + case "hide_background": + return this.hass!.localize( + "ui.panel.lovelace.editor.card.iframe.hide_background_helper" + ); + default: + return ""; + } + }; } declare global { diff --git a/src/translations/en.json b/src/translations/en.json index b64f89d3bc..3672328c2d 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -7783,7 +7783,9 @@ }, "iframe": { "name": "Webpage", - "description": "The Webpage card allows you to embed your favorite webpage right into Home Assistant." + "description": "The Webpage card allows you to embed your favorite webpage right into Home Assistant.", + "hide_background": "Hide background", + "hide_background_helper": "Useful for pages which allow a transparent background." }, "light": { "name": "Light",