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 #20541

Merged
merged 5 commits into from
Apr 24, 2024
Merged

Conversation

karwosts
Copy link
Contributor

@karwosts karwosts commented Apr 17, 2024

Proposed change

Continuation of #17074 by @christophwen

To that PR added yaml migration, and fixed some of the behavior which broke when we changed darkmode from a ternary option to a strict boolean.

Light Mode Base:

image

Dark Mode Base:

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

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:

christophwen and others added 5 commits November 16, 2023 19:03
- 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
@karwosts karwosts changed the title Visual map issues (attempt #2) Fix visual map issues (attempt #2) Apr 18, 2024
@silamon silamon changed the title Fix visual map issues (attempt #2) Fix visual map issues Apr 19, 2024
@silamon
Copy link
Contributor

silamon commented Apr 20, 2024

I did a review of the code and a test run, and it looks ready to be merged. The only thing that bothers me is that it doesn't actually "fix" the visual map issues right away. I would propose to have it a different title.

If we're out to "fix" the issue we should have dark mode base with dark_mode: false to be light according to the comment in the linked issues.

@karwosts
Copy link
Contributor Author

I had maybe thought we were trying to get away from the "ternary booleans", which was the point of migrating to the new variable, which does not have ambiguity between false and undefined. That's why I didn't add anything for dark === false.

@bramkragten
Copy link
Member

We can also just make it an enum instead of a boolean; default, light, dark.

Or prepare to remove and deprecate this option and have it handled in themes completely 🙃

@karwosts
Copy link
Contributor Author

We can also just make it an enum instead of a boolean; default, light, dark.

I believe that's what this has now. theme_mode is auto, light or dark,

@@ -170,6 +180,7 @@ class HuiMapCard extends LitElement implements LovelaceCard {
"ui.panel.lovelace.cards.map.reset_focus"
)}
.path=${mdiImageFilterCenterFocus}
style=${isDarkMode ? "color:#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.

This should be done with a class

selector: { number: { mode: "box", min: 0 } },
},
{
name: "theme_mode",
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we just leave this out of the UI and promote the use of the theme variable map-filter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you say this option should be removed, and build it all with themes, I can understand that argument. I don't know if I fully agree with it, as I think that is pretty complicated to ask users to do, but I understand not wanting to maintain multiple solutions. In the past I have added theme vars to solve problems and I get a lot of "what's a theme? how do I add what where? help I broke my config", etc. So I think many are not too familiar with it, it's somewhat advanced. The map filter string is pretty intimidating as well.

If we did want to replicate this functionality with themes I think we at least need one new theme var, to set the color of the map icons, and the color of the Reset Focus button. If overall map background color is independently themable then those need to be independently themable as well to not clash.

So that is one decision to make.

However if we do decide to keep this theme_mode as an option, I'm not sure what the point is to build it, but then hide it by removing from the UI. Just seems kind of user-hostile for no reason.

Anyway let me know what you think so we can try to align on that and get this issue closed out. Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

I guess one of the issues I have is that once you set a theme_mode you can no longer theme the color of the controls, as they are hard coded then.

But I do agree that it is not easy to create a theme for things like this, but ideally a user using a community created theme doesnt have to change the config of cards to get it to match the theme.

Not sure what the right approach her would be.

@bramkragten bramkragten merged commit 713763f into home-assistant:dev Apr 24, 2024
14 checks passed
@piitaya piitaya mentioned this pull request Apr 24, 2024
9 tasks
@karwosts karwosts deleted the visual-map-issues branch April 24, 2024 12:32
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.

4 participants