Skip to content

Commit cd49d46

Browse files
committed
Use hui-root
1 parent e1b6915 commit cd49d46

File tree

6 files changed

+327
-630
lines changed

6 files changed

+327
-630
lines changed

src/panels/climate/ha-panel-climate.ts

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import { haStyle } from "../../resources/styles";
1111
import type { HomeAssistant } from "../../types";
1212
import { generateLovelaceViewStrategy } from "../lovelace/strategies/get-strategy";
1313
import type { Lovelace } from "../lovelace/types";
14-
import "../lovelace/hui-lovelace";
14+
import "../lovelace/views/hui-view";
15+
import "../lovelace/views/hui-view-container";
1516

1617
const CLIMATE_LOVELACE_VIEW_CONFIG: LovelaceStrategyViewConfig = {
1718
strategy: {
@@ -25,6 +26,8 @@ class PanelClimate extends LitElement {
2526

2627
@property({ type: Boolean, reflect: true }) public narrow = false;
2728

29+
@state() private _viewIndex = 0;
30+
2831
@state() private _lovelace?: Lovelace;
2932

3033
@state() private _searchParms = new URLSearchParams(window.location.search);
@@ -89,33 +92,40 @@ class PanelClimate extends LitElement {
8992
return html`
9093
<div class="header">
9194
<div class="toolbar">
92-
${this._searchParms.has("historyBack")
93-
? html`
94-
<ha-icon-button-arrow-prev
95-
@click=${this._back}
96-
slot="navigationIcon"
97-
></ha-icon-button-arrow-prev>
98-
`
99-
: html`
100-
<ha-menu-button
101-
slot="navigationIcon"
102-
.hass=${this.hass}
103-
.narrow=${this.narrow}
104-
></ha-menu-button>
105-
`}
95+
${
96+
this._searchParms.has("historyBack")
97+
? html`
98+
<ha-icon-button-arrow-prev
99+
@click=${this._back}
100+
slot="navigationIcon"
101+
></ha-icon-button-arrow-prev>
102+
`
103+
: html`
104+
<ha-menu-button
105+
slot="navigationIcon"
106+
.hass=${this.hass}
107+
.narrow=${this.narrow}
108+
></ha-menu-button>
109+
`
110+
}
106111
<div class="main-title">${this.hass.localize("panel.climate")}</div>
107112
</div>
108113
</div>
109-
${this._lovelace
110-
? html`
111-
<hui-lovelace
112-
.hass=${this.hass}
113-
.narrow=${this.narrow}
114-
.lovelace=${this._lovelace}
115-
.curView=${0}
116-
></hui-lovelace>
117-
`
118-
: nothing}
114+
${
115+
this._lovelace
116+
? html`
117+
<hui-view-container .hass=${this.hass}>
118+
<hui-view
119+
.hass=${this.hass}
120+
.narrow=${this.narrow}
121+
.lovelace=${this._lovelace}
122+
.index=${this._viewIndex}
123+
></hui-view
124+
></hui-view-container>
125+
`
126+
: nothing
127+
}
128+
</hui-view-container>
119129
`;
120130
}
121131

@@ -133,8 +143,8 @@ class PanelClimate extends LitElement {
133143
}
134144

135145
this._lovelace = {
136-
config,
137-
rawConfig,
146+
config: config,
147+
rawConfig: rawConfig,
138148
editMode: false,
139149
urlPath: "climate",
140150
mode: "generated",
@@ -213,7 +223,7 @@ class PanelClimate extends LitElement {
213223
line-height: var(--ha-line-height-normal);
214224
flex-grow: 1;
215225
}
216-
hui-lovelace {
226+
hui-view-container {
217227
position: relative;
218228
display: flex;
219229
min-height: 100vh;
@@ -223,10 +233,14 @@ class PanelClimate extends LitElement {
223233
padding-inline-end: var(--safe-area-inset-right);
224234
padding-bottom: var(--safe-area-inset-bottom);
225235
}
226-
:host([narrow]) hui-lovelace {
236+
:host([narrow]) hui-view-container {
227237
padding-left: var(--safe-area-inset-left);
228238
padding-inline-start: var(--safe-area-inset-left);
229239
}
240+
hui-view {
241+
flex: 1 1 100%;
242+
max-width: 100%;
243+
}
230244
`,
231245
];
232246
}

0 commit comments

Comments
 (0)