Skip to content

Weather Card: Beautify#5387

Merged
bramkragten merged 25 commits intohome-assistant:devfrom
zsarnett:weather-card
Apr 22, 2020
Merged

Weather Card: Beautify#5387
bramkragten merged 25 commits intohome-assistant:devfrom
zsarnett:weather-card

Conversation

@zsarnett
Copy link
Copy Markdown
Contributor

Proposed change

Previous

image

New

image

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

- entity: weather.dark_sky
  type: weather-forecast
- type: weather-forecast
  entity: weather.dark_sky
  show_forecast: false

Additional information

  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@zsarnett
Copy link
Copy Markdown
Contributor Author

zsarnett commented Apr 1, 2020

0babd1b0539196883c8a36653b64c064

There a few hitches in the gif. Just because with the recorder and the speed I am changing the size it doesn't catch up

@zsarnett zsarnett changed the title Weather card Weather Card: Beautify Apr 1, 2020
@Misiu
Copy link
Copy Markdown
Contributor

Misiu commented Apr 1, 2020

What about humidity and wind speed? Are those going to be displayed (if available)?

@zsarnett
Copy link
Copy Markdown
Contributor Author

zsarnett commented Apr 1, 2020

Those attributes will be available via more-info window. With all of our cards the goal should not to show all details available but the most important so the card is glancable and more information can be found my clicking the card

@zsarnett
Copy link
Copy Markdown
Contributor Author

zsarnett commented Apr 1, 2020

Technically, the attributes will be shown in this priority:

Extrema
Precipitation
Humidity
None

Comment thread src/panels/lovelace/cards/hui-weather-forecast-card.ts Outdated
@zsarnett
Copy link
Copy Markdown
Contributor Author

zsarnett commented Apr 1, 2020

image

Comment thread src/panels/lovelace/cards/hui-weather-forecast-card.ts Outdated
Comment thread src/panels/lovelace/cards/hui-weather-forecast-card.ts Outdated
Comment thread src/panels/lovelace/cards/hui-weather-forecast-card.ts Outdated
this.removeAttribute("verynarrow");
}
if (card.offsetWidth < 200) {
this.setAttribute("veryverynarrow", "");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need veryverynarrow? Can't we just use verynarrow?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very very narrow is to deal with times when its in a horizontal stack on a phone. Makes the icon and temp stacked nicely in the center

@zsarnett
Copy link
Copy Markdown
Contributor Author

Thank you to cgtobi (I cant find your github username) for the new images that don't include a shadow

@zsarnett
Copy link
Copy Markdown
Contributor Author

@bramkragten This is ready for review.

}

get _show_forecast(): boolean {
return this._config!.show_forecast || true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bool, so it will always return true now.

Comment thread src/panels/lovelace/editor/config-elements/hui-weather-forecast-card-editor.ts Outdated
Comment on lines -52 to -54
get _show_forecast(): boolean {
return this._config!.show_forecast || true;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be still needed for the check in _valueChanged?

@bramkragten
Copy link
Copy Markdown
Member

Comment on the layout, I think the left and right side should be aligned, now the right is higher than the left.

@zsarnett
Copy link
Copy Markdown
Contributor Author

image

}

public getCardSize(): number {
return 4;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should change depending on if we show forecast

Comment on lines +146 to +158
const forecast = stateObj.attributes.forecast?.length
? stateObj.attributes.forecast.slice(0, this._narrow ? 3 : 5)
: undefined;

let hourly: boolean | undefined;

if (forecast?.length && forecast?.length > 1) {
const date1 = new Date(forecast[0].datetime);
const date2 = new Date(forecast[1].datetime);
const timeDiff = date2.getTime() - date1.getTime();

hourly = timeDiff < DAY_IN_MILLISECONDS;
}
Copy link
Copy Markdown
Member

@bramkragten bramkragten Apr 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only do this if we are going to show the forecast

@bramkragten
Copy link
Copy Markdown
Member

In edit mode the card is always rendered as veryverynarrow because the card doesn't get display: block from hui-card-options

@bramkragten
Copy link
Copy Markdown
Member

bramkragten commented Apr 22, 2020

Is that a weird cut off shadow in the png?
image

@bramkragten bramkragten merged commit fdf7b51 into home-assistant:dev Apr 22, 2020
@bramkragten bramkragten mentioned this pull request Apr 22, 2020
@cgtobi
Copy link
Copy Markdown
Contributor

cgtobi commented Apr 23, 2020

Great work, my github handle is @cgtobi ;-)

@lock lock Bot locked and limited conversation to collaborators Apr 25, 2020
@zsarnett zsarnett deleted the weather-card branch May 3, 2020 03:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants