Skip to content

Commit e936a9b

Browse files
authored
Update weather-card-editor.js
1 parent 3c01e03 commit e936a9b

File tree

1 file changed

+38
-56
lines changed

1 file changed

+38
-56
lines changed

dist/weather-card-editor.js

Lines changed: 38 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@ const fireEvent = (node, type, detail, options) => {
1111
return event;
1212
};
1313

14+
if (
15+
!customElements.get("ha-switch") &&
16+
customElements.get("paper-toggle-button")
17+
) {
18+
customElements.define("ha-switch", customElements.get("paper-toggle-button"));
19+
}
20+
1421
const LitElement = Object.getPrototypeOf(customElements.get("hui-view"));
1522
const html = LitElement.prototype.html;
23+
const css = LitElement.prototype.css;
1624

1725
export class WeatherCardEditor extends LitElement {
1826
setConfig(config) {
@@ -57,7 +65,6 @@ export class WeatherCardEditor extends LitElement {
5765
);
5866

5967
return html`
60-
${this.renderStyle()}
6168
<div class="card-config">
6269
<div>
6370
<paper-input
@@ -101,47 +108,24 @@ export class WeatherCardEditor extends LitElement {
101108
</paper-listbox>
102109
</paper-dropdown-menu>
103110
`}
104-
${customElements.get("paper-toggle-button")
105-
? html`
106-
<paper-toggle-button
107-
.checked=${this._current}
108-
.configValue="${"current"}"
109-
@change="${this._valueChanged}"
110-
>Show current</paper-toggle-button
111-
>
112-
<paper-toggle-button
113-
.checked=${this._details}
114-
.configValue="${"details"}"
115-
@change="${this._valueChanged}"
116-
>Show details</paper-toggle-button
117-
>
118-
<paper-toggle-button
119-
.checked=${this._forecast}
120-
.configValue="${"forecast"}"
121-
@change="${this._valueChanged}"
122-
>Show forecast</paper-toggle-button
123-
>
124-
`
125-
: html`
126-
<ha-switch
127-
.checked=${this._current}
128-
.configValue="${"current"}"
129-
@change="${this._valueChanged}"
130-
>Show current</ha-switch
131-
>
132-
<ha-switch
133-
.checked=${this._details}
134-
.configValue="${"details"}"
135-
@change="${this._valueChanged}"
136-
>Show details</ha-switch
137-
>
138-
<ha-switch
139-
.checked=${this._forecast}
140-
.configValue="${"forecast"}"
141-
@change="${this._valueChanged}"
142-
>Show forecast</ha-switch
143-
>
144-
`}
111+
<ha-switch
112+
.checked=${this._current}
113+
.configValue="${"current"}"
114+
@change="${this._valueChanged}"
115+
>Show current</ha-switch
116+
>
117+
<ha-switch
118+
.checked=${this._details}
119+
.configValue="${"details"}"
120+
@change="${this._valueChanged}"
121+
>Show details</ha-switch
122+
>
123+
<ha-switch
124+
.checked=${this._forecast}
125+
.configValue="${"forecast"}"
126+
@change="${this._valueChanged}"
127+
>Show forecast</ha-switch
128+
>
145129
</div>
146130
</div>
147131
`;
@@ -169,20 +153,18 @@ export class WeatherCardEditor extends LitElement {
169153
fireEvent(this, "config-changed", { config: this._config });
170154
}
171155

172-
renderStyle() {
173-
return html`
174-
<style>
175-
paper-toggle-button {
176-
padding-top: 16px;
177-
}
178-
.side-by-side {
179-
display: flex;
180-
}
181-
.side-by-side > * {
182-
flex: 1;
183-
padding-right: 4px;
184-
}
185-
</style>
156+
static get styles() {
157+
return css`
158+
ha-switch {
159+
padding-top: 16px;
160+
}
161+
.side-by-side {
162+
display: flex;
163+
}
164+
.side-by-side > * {
165+
flex: 1;
166+
padding-right: 4px;
167+
}
186168
`;
187169
}
188170
}

0 commit comments

Comments
 (0)