Weather Card: Show 5 element Forecast Longer (#5885)

This commit is contained in:
Zack Arnett 2020-05-29 09:09:35 -04:00 committed by GitHub
parent d94df728e5
commit ba384b9eee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,8 +66,8 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
@property() private _config?: WeatherForecastCardConfig; @property() private _config?: WeatherForecastCardConfig;
@property({ type: Boolean, reflect: true, attribute: "narrow" }) @property({ type: Boolean, reflect: true, attribute: "veryverynarrow" })
private _narrow = false; private _veryVeryNarrow = false;
private _resizeObserver?: ResizeObserver; private _resizeObserver?: ResizeObserver;
@ -158,7 +158,7 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
const forecast = const forecast =
this._config?.show_forecast !== false && this._config?.show_forecast !== false &&
stateObj.attributes.forecast?.length stateObj.attributes.forecast?.length
? stateObj.attributes.forecast.slice(0, this._narrow ? 3 : 5) ? stateObj.attributes.forecast.slice(0, this._veryVeryNarrow ? 3 : 5)
: undefined; : undefined;
let hourly: boolean | undefined; let hourly: boolean | undefined;
@ -306,17 +306,17 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
return; return;
} }
this._narrow = this.offsetWidth < 375; if (this.offsetWidth < 375) {
this.setAttribute("narrow", "");
} else {
this.removeAttribute("narrow");
}
if (this.offsetWidth < 300) { if (this.offsetWidth < 300) {
this.setAttribute("verynarrow", ""); this.setAttribute("verynarrow", "");
} else { } else {
this.removeAttribute("verynarrow"); this.removeAttribute("verynarrow");
} }
if (this.offsetWidth < 225) { this._veryVeryNarrow = this.offsetWidth < 245;
this.setAttribute("veryverynarrow", "");
} else {
this.removeAttribute("veryverynarrow");
}
} }
static get styles(): CSSResult[] { static get styles(): CSSResult[] {