mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Revert "Fix theme background of view" (#16094
Revert "Fix theme background of view (#16083)" This reverts commit 723b3844ac22e07b3ae068e8f62bd3e048aafc52.
This commit is contained in:
parent
d1ad72c6ff
commit
0364c5e493
@ -26,7 +26,13 @@ import {
|
|||||||
PropertyValues,
|
PropertyValues,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import {
|
||||||
|
customElement,
|
||||||
|
eventOptions,
|
||||||
|
property,
|
||||||
|
query,
|
||||||
|
state,
|
||||||
|
} from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
@ -87,7 +93,7 @@ class HUIRoot extends LitElement {
|
|||||||
|
|
||||||
@state() private _curView?: number | "hass-unused-entities";
|
@state() private _curView?: number | "hass-unused-entities";
|
||||||
|
|
||||||
@query("#view", true) _viewRoot!: HTMLDivElement;
|
@query("#view", true) _view!: HTMLDivElement;
|
||||||
|
|
||||||
private _viewCache?: { [viewId: string]: HUIView };
|
private _viewCache?: { [viewId: string]: HUIView };
|
||||||
|
|
||||||
@ -544,14 +550,19 @@ class HUIRoot extends LitElement {
|
|||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
<div id="view" @ll-rebuild=${this._debouncedConfigChanged}></div>
|
<div
|
||||||
|
id="view"
|
||||||
|
@ll-rebuild=${this._debouncedConfigChanged}
|
||||||
|
@scroll=${this._viewScrolled}
|
||||||
|
></div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _viewScrolled = (ev) => {
|
@eventOptions({ passive: true })
|
||||||
|
private _viewScrolled(ev) {
|
||||||
this.toggleAttribute("scrolled", ev.currentTarget.scrollTop !== 0);
|
this.toggleAttribute("scrolled", ev.currentTarget.scrollTop !== 0);
|
||||||
};
|
}
|
||||||
|
|
||||||
private _isVisible = (view: LovelaceViewConfig) =>
|
private _isVisible = (view: LovelaceViewConfig) =>
|
||||||
Boolean(
|
Boolean(
|
||||||
@ -673,6 +684,10 @@ class HUIRoot extends LitElement {
|
|||||||
return this.lovelace!.editMode;
|
return this.lovelace!.editMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private get _viewRoot(): HTMLDivElement {
|
||||||
|
return this.shadowRoot!.getElementById("view") as HTMLDivElement;
|
||||||
|
}
|
||||||
|
|
||||||
private get _showButtonMenu(): boolean {
|
private get _showButtonMenu(): boolean {
|
||||||
return (
|
return (
|
||||||
(this.narrow && this._conversation(this.hass.config.components)) ||
|
(this.narrow && this._conversation(this.hass.config.components)) ||
|
||||||
@ -859,6 +874,7 @@ class HUIRoot extends LitElement {
|
|||||||
const path = this.config.views[viewIndex].path || viewIndex;
|
const path = this.config.views[viewIndex].path || viewIndex;
|
||||||
this._navigateToView(path);
|
this._navigateToView(path);
|
||||||
}
|
}
|
||||||
|
this._view.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _selectView(viewIndex: HUIRoot["_curView"], force: boolean): void {
|
private _selectView(viewIndex: HUIRoot["_curView"], force: boolean): void {
|
||||||
@ -878,7 +894,6 @@ class HUIRoot extends LitElement {
|
|||||||
const root = this._viewRoot;
|
const root = this._viewRoot;
|
||||||
|
|
||||||
if (root.lastChild) {
|
if (root.lastChild) {
|
||||||
root.lastChild.removeEventListener("scroll", this._viewScrolled);
|
|
||||||
root.removeChild(root.lastChild);
|
root.removeChild(root.lastChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -913,7 +928,6 @@ class HUIRoot extends LitElement {
|
|||||||
view.lovelace = this.lovelace;
|
view.lovelace = this.lovelace;
|
||||||
view.hass = this.hass;
|
view.hass = this.hass;
|
||||||
view.narrow = this.narrow;
|
view.narrow = this.narrow;
|
||||||
view.addEventListener("scroll", this._viewScrolled, { passive: true });
|
|
||||||
|
|
||||||
const configBackground = viewConfig.background || this.config.background;
|
const configBackground = viewConfig.background || this.config.background;
|
||||||
|
|
||||||
@ -922,7 +936,6 @@ class HUIRoot extends LitElement {
|
|||||||
} else {
|
} else {
|
||||||
this.style.removeProperty("--lovelace-background");
|
this.style.removeProperty("--lovelace-background");
|
||||||
}
|
}
|
||||||
this.removeAttribute("scrolled");
|
|
||||||
|
|
||||||
root.appendChild(view);
|
root.appendChild(view);
|
||||||
// Recalculate to see if we need to adjust content area for tab bar
|
// Recalculate to see if we need to adjust content area for tab bar
|
||||||
@ -1033,20 +1046,18 @@ class HUIRoot extends LitElement {
|
|||||||
mwc-button.warning:not([disabled]) {
|
mwc-button.warning:not([disabled]) {
|
||||||
color: var(--error-color);
|
color: var(--error-color);
|
||||||
}
|
}
|
||||||
hui-view {
|
#view {
|
||||||
margin-top: calc(var(--header-height) + env(safe-area-inset-top));
|
margin-top: calc(var(--header-height) + env(safe-area-inset-top));
|
||||||
height: calc(100vh - var(--header-height) - env(safe-area-inset-top));
|
height: calc(100vh - var(--header-height) - env(safe-area-inset-top));
|
||||||
|
padding-left: env(safe-area-inset-left);
|
||||||
|
padding-right: env(safe-area-inset-right);
|
||||||
background: var(
|
background: var(
|
||||||
--lovelace-background,
|
--lovelace-background,
|
||||||
var(--primary-background-color)
|
var(--primary-background-color)
|
||||||
);
|
);
|
||||||
padding-left: env(safe-area-inset-left);
|
|
||||||
padding-right: env(safe-area-inset-right);
|
|
||||||
width: 100%;
|
|
||||||
padding-bottom: env(safe-area-inset-bottom);
|
|
||||||
display: block;
|
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
transform: translateZ(0);
|
transform: translateZ(0);
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* In edit mode we have the tab bar on a new line *
|
* In edit mode we have the tab bar on a new line *
|
||||||
@ -1059,6 +1070,21 @@ class HUIRoot extends LitElement {
|
|||||||
var(--header-height) + 48px + env(safe-area-inset-top)
|
var(--header-height) + 48px + env(safe-area-inset-top)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#view > * {
|
||||||
|
/**
|
||||||
|
* The view could get larger than the window in Firefox
|
||||||
|
* to prevent that we set the max-width to 100%
|
||||||
|
* flex-grow: 1 and flex-basis: 100% should make sure the view
|
||||||
|
* stays full width.
|
||||||
|
*
|
||||||
|
* https://github.com/home-assistant/home-assistant-polymer/pull/3806
|
||||||
|
*/
|
||||||
|
flex: 1 1 100%;
|
||||||
|
height: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
padding-bottom: env(safe-area-inset-bottom);
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
.hide-tab {
|
.hide-tab {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -161,8 +161,9 @@ export class HUIView extends ReactiveElement {
|
|||||||
| undefined;
|
| undefined;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
changedProperties.has("hass") &&
|
!oldHass ||
|
||||||
(!oldHass || this.hass.themes !== oldHass.themes)
|
this.hass.themes !== oldHass.themes ||
|
||||||
|
this.hass.selectedTheme !== oldHass.selectedTheme
|
||||||
) {
|
) {
|
||||||
applyThemesOnElement(this, this.hass.themes, this._viewConfigTheme);
|
applyThemesOnElement(this, this.hass.themes, this._viewConfigTheme);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user