Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix visual map issues #17074

Closed

Conversation

christophwen
Copy link
Contributor

@christophwen christophwen commented Jun 28, 2023

  • hover background color of zoom control in dark mode
  • map light mode when dark theme is used
  • background color of zoom control with map dark mode when light theme is used

Breaking change

Proposed change

This PR contains multiple fixes for different visual issues with the map (card).

  1. The hover background color of the maps zoom control when the map is in dark mode is way to white
    ha-map-hover-zoom-fix
  2. When setting the map to light mode when dark theme is used, the map isn't shown in light mode (it is dark mode but with a bit more contrast)
    ha-map-force-light-theme-fix
  3. The background color of the maps zoom control with the map in dark mode when light theme is used is white (should be dark, so that the icons are visible)
    ha-map-lt-dm-zoom-bg-fix

This summery shows how the map's look with all possible configurations:
ha-map-differences

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

Additional information

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:

@@ -286,7 +286,7 @@ export interface MapCardConfig extends LovelaceCardConfig {
entities?: Array<EntityConfig | string>;
hours_to_show?: number;
geo_location_sources?: string[];
dark_mode?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

This is a breaking change, if we are going to change this, we should at least make it backwards compatible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for that, I will fix this.

@christophwen
Copy link
Contributor Author

I forgot this image which shows the new Theme Mode selection in the map editor.
ha-map-editor-new

@christophwen christophwen requested a review from bramkragten June 28, 2023 15:18
@karwosts
Copy link
Contributor

Does that radio button set need a title?

@christophwen
Copy link
Contributor Author

Does that radio button set need a title?

Good questions, I didn't thought about that. I just assumed that it is clear. I will think about that and maybe I get more opinions on that.

@christophwen
Copy link
Contributor Author

I got some feedback about the radio buttons that a title is preferred. (11/11 people)
I also got the suggestion to use a dropdown for this.
@karwosts and @bramkragten what are your opinions about the dropdown idea?

@karwosts
Copy link
Contributor

I will point out the default behavior of selector-select is radio buttons with 5 or less options, and dropdown with 6 or more.

Personally I have no opinion between the two, but if the design decision was previously made that selectors with less than 6 items use radio buttons, I see no reason to override that, might as well stay consistent?

Note to get the title I think all you need to do is provide a translation key for "theme_mode", but you've already used that as a group name for the modes. Maybe just rename "theme_mode" : { ... } -> "theme_modes" : { ... }, and then you can add "theme_mode" : "Theme Mode"

@christophwen
Copy link
Contributor Author

I will point out the default behavior of selector-select is radio buttons with 5 or less options, and dropdown with 6 or more.

Personally I have no opinion between the two, but if the design decision was previously made that selectors with less than 6 items use radio buttons, I see no reason to override that, might as well stay consistent?

I see no reason too. In the user's profile the dropdown is used multiple times with less than 6 options.
In the M3 Design Guide I found out that if saving space is important a dropdown is a good alternative. (This applies kinda to this issue here)
image

Note to get the title I think all you need to do is provide a translation key for "theme_mode", but you've already used that as a group name for the modes. Maybe just rename "theme_mode" : { ... } -> "theme_modes" : { ... }, and then you can add "theme_mode" : "Theme Mode"

Thank you!

@siw1973
Copy link

siw1973 commented Jul 4, 2023

@christophwen @bramkragten Thanks for working on this, it looks like this has had all the checks passed.

I don't know the process but will this now make the next release ?

@bramkragten
Copy link
Member

I don't know the process but will this now make the next release ?

No, the beta for the next release (tomorrow) started last Wednesday. We don't add new features after the beta has started, only bug fixes.

This will be in the release of August.

@christophwen
Copy link
Contributor Author

Changed ratio button selection of theme mode to dropdown and reorganized the editor view a little bit.
(Fixed unpleasant horizontal scroll view, see screenshots above)

ha-map-issue

@siw1973
Copy link

siw1973 commented Jul 5, 2023

I don't know the process but will this now make the next release ?

No, the beta for the next release (tomorrow) started last Wednesday. We don't add new features after the beta has started, only bug fixes.

This will be in the release of August.

Thanks for the update 👍

Comment on lines 484 to 513
#map.light {
background: #ffffff;
color: #000000;
Copy link
Member

Choose a reason for hiding this comment

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

I think we should only use hard coded colors when the map darkmode setting differs from the theme darkmode. Otherwise we should just use theme colors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The #000000 is needed to show the icon of the home (house) in black, when HA is in dark mode and map should use the light theme. I will change it to --white-color. (#ffffff--black-color)

Copy link
Member

Choose a reason for hiding this comment

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

We should add a force flag to ha-map, that only hardcodes colors when the mode doesnt match the theme hass.themes.darkMode.

#map.light {
background: #ffffff;
color: #000000;
--map-filter: invert(0);
Copy link
Member

Choose a reason for hiding this comment

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

What does this do? --map-filter: unset;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This forces the map to appear in light mode when HA is in dark mode. With --map-filter: unset; the map stays in dark mode.

.leaflet-tile-pane {
filter: var(--map-filter);
}
.dark .leaflet-bar a {
background-color: var(--card-background-color, #1c1c1c);
background-color: #1c1c1c;
Copy link
Member

Choose a reason for hiding this comment

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

Same, use theme if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed to show the + and - of the zoom control in black, when HA is in light theme and the map in dark mode.

@@ -94,33 +125,32 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
<ha-form
.hass=${this.hass}
.data=${this._config}
Copy link
Member

Choose a reason for hiding this comment

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

We should migrate the old config (dark_mode) to the new config so it is displayed correctly in the form, and is saved in the new format

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be great if we can discuss this on Discord, because right now, I am not sure what I have to do here.

@bramkragten
Copy link
Member

Please open a documentation PR for these changes.

@christophwen
Copy link
Contributor Author

Please open a documentation PR for these changes.

Could you please explain to me what a documentation PR is, I have never created one before. Then I will do that :)

@karwosts
Copy link
Contributor

Could you please explain to me what a documentation PR is, I have never created one before. Then I will do that :)

If we're changing the options for map card, go here:

https://www.home-assistant.io/dashboards/map/

Go down to the bottom of the page, click the Edit button. It will take you to github page with the markdown for that webpage. Click the edit button, make changes detailing the new configuration options, and submit them as a PR to the next branch. Once the PR is created, add a link back here.

@christophwen
Copy link
Contributor Author

Short Update: I will continue as soon as I get some answers. Then I will finish the PR and create the documentation PR as follow-up.

@christophwen
Copy link
Contributor Author

Hey, I was on vacation, but now I am back. I will continue soon with this PR.

@adechant

This comment was marked as off-topic.

@github-actions github-actions bot added Supervisor Related to the supervisor panel Cast Related to Home Assistant Cast UI Dependencies Pull requests that update a dependency file GitHub Actions Pull requests that update GitHub Actions code Build Related to building the code Demo Related to frontend demo content labels Sep 26, 2023
@github-actions github-actions bot removed the Design Related to Home Assistant design gallery label Sep 26, 2023
@smithbill17
Copy link

Is this still progressing?

The original issue #15587 had been marked as stale but the problem is still present in Home Assistant 2023.9.3 & Companion App 2023.9.2-full

@siw1973
Copy link

siw1973 commented Oct 21, 2023

Short Update: I will continue as soon as I get some answers. Then I will finish the PR and create the documentation PR as follow-up.

@christophwen did you get the feedback you needed to raise the PR?

I know a few people are waiting for and appreciate the work you have put in so far.

@christophwen
Copy link
Contributor Author

@siw1973 Sorry, I got carried away by something else. I will do my best to finish the PR.

@bramkragten
Copy link
Member

Check #18667, it added a class for forced dark that you should use in this PR too.

@smithbill17
Copy link

Aren't we adding a 'Lite' mode map, even when the Home Assistant theme is set to 'Dark' mode? (basically so the map can actually be seen clearly)

@redam
Copy link

redam commented Nov 16, 2023

yes we need a way to force "light" mode, not dark mode

@bramkragten
Copy link
Member

We need both.

- hover background color of zoom control in dark mode
- map light mode when dark theme is used
- background color of zoom control with map dark mode when light theme is used
- Additionally fixed unpleasant horizontal scrollbar in map editor
@christophwen
Copy link
Contributor Author

Check #18667, it added a class for forced dark that you should use in this PR too.

I rebased and added the class. (+ 'force-light')

@@ -159,6 +159,7 @@ export class HaMap extends ReactiveElement {
const map = this.shadowRoot!.getElementById("map");
map!.classList.toggle("dark", darkMode);
map!.classList.toggle("forced-dark", this.darkMode);
map!.classList.toggle("foced-light", !darkMode);
Copy link
Member

Choose a reason for hiding this comment

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

forced-light should only be set when this.darkMode === false otherwise it will also add the forced class when then theme is actually light mode. forced here means the map dark mode is different than the dark mode of the theme.

@ildar170975
Copy link
Contributor

Imho the dark_mode option should (kind of a FR):
– force the map to be dark - if TRUE
– force the map to be light - if FALSE
– force the map to follow a current theme - if not defined.

@karwosts karwosts mentioned this pull request Jan 29, 2024
9 tasks
Copy link

github-actions bot commented Mar 8, 2024

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 8, 2024
@siw1973
Copy link

siw1973 commented Mar 14, 2024

This is a real shame as this has had some work done on it, but seems to have been bogged down by a lack of understanding on process and clarity as to what the next steps need to be.

If this could be resurected and dragged over the line then it would be really helpful to a few people linked to this issue and also I expect many other people who just don't use GitHub.

@github-actions github-actions bot removed the stale label Mar 14, 2024
@karwosts
Copy link
Contributor

@christophwen - If you have no intention of returning to this in the near future, I will push some changes that I think can bring this to completion.

If you don't want me to make edits to your branch, please state your objection, otherwise I will do so in a few days.

@christophwen
Copy link
Contributor Author

@karwosts it would be great if you make changes to get this done. My free time is very limited right now and I am not the best with CSS changes. Thank you :)

@karwosts karwosts mentioned this pull request Apr 17, 2024
9 tasks
@karwosts
Copy link
Contributor

karwosts commented Apr 17, 2024

Hmm I thought I would be able to push to this from the CLI, but I'm getting 403 authorization problems whatever I try to do.

Pushing to https://github.com/christophwen/home-assistant-frontend
remote: Permission to christophwen/home-assistant-frontend.git denied to karwosts.
fatal: unable to access 'https://github.com/christophwen/home-assistant-frontend/': The requested URL returned error: 403

(Maybe I should have cloned the upstream PR branch instead of your repo's branch? not exactly sure)

Unless I get that figured out I just spawned a new PR at #20541 with these changes and fixes to get around the 403 problem.

@silamon silamon changed the title Fix visual map issues (#15587) Fix visual map issues Apr 19, 2024
@bramkragten
Copy link
Member

#20541

@karwosts
Copy link
Contributor

The duplicate PR was merged. Thanks @christophwen

@christophwen
Copy link
Contributor Author

@karwosts thanks for finishing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

too dark map issue when using dark theme
8 participants