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

feat: add show_legend_state #1173

Merged
merged 12 commits into from
Dec 20, 2024
Merged

Conversation

JulienDeveaux
Copy link

Iterating on #1082 as I can't push into his repo

@JulienDeveaux
Copy link
Author

JulienDeveaux commented Dec 7, 2024

In the previous PR, it was advised to add state__value & state__uom classes to the render.
It messes the visual as they are way too big for this small label, so I removed them

@ildar170975
Copy link
Collaborator

so I removed them

totally agree, missed that myself.

@ildar170975
Copy link
Collaborator

ildar170975 commented Dec 7, 2024

@akloeckner
Please have a look at this PR.
Cleaned up the changes together a bit.
I am not having enough experience to approve all changes.
For me it is looking OK.

What is not covered (and MAY BE will be fixed in other PRs):

  1. Custom order "state uom" / "uom state". Currently it is fixed as "state uom" for a legend entry.
    Note that for a "state" label a value & uom are kept in separate DOM elements - so an order can be changed by card-mod as it was explained here.
    But in this PR a legend is presented as
legend += ` (${this.computeState(state)} ${this.computeUom(index)})`;

without keeping parts in separate elements. May be they should be placed both in <span> instead to allow users to use card-mod here.

  1. There are rules in HA frontend regarding a whitespace between a value & uom. A special function is used for it. No idea if it can be used in custom cards or it should be repeated. Personally me do not care about whitespaces))).

Copy link
Collaborator

@akloeckner akloeckner left a comment

Choose a reason for hiding this comment

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

Thanks for sorting most things out already! And sorry for re-opening some of the topics. :-)

I agree with your general assessment:

  • Let's keep the UOM order for later. I also understand from your conversation that the usual classes generated a strange look. So, it is more than just adding known classes and spans and should thus be treated with more thought in another PR.
  • Same for the whitespace. If the state and UOM parts become separate tags with flexible order, it will be up to the user anyways to add or remove whitespace.

I haven't actually downloaded, compiled and tested the changes yet. I'll approve the workflow run, so maybe you can check it out, @ildar170975? You'll have to wait for the code to successfully compile...

Copy link
Collaborator

@akloeckner akloeckner left a comment

Choose a reason for hiding this comment

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

I am fine with this PR. There is a js file to use for testing as usual in the "checks" section.

@ildar170975
Copy link
Collaborator

Let's merge it. Looks great.

@akloeckner
Copy link
Collaborator

Thanks for bearing with us @JulienDeveaux!

@akloeckner akloeckner merged commit 3b1c827 into kalkih:dev Dec 20, 2024
4 checks passed
github-actions bot pushed a commit that referenced this pull request Dec 21, 2024
# [0.13.0-dev.1](v0.12.2-dev.2...v0.13.0-dev.1) (2024-12-21)

### Bug Fixes

* name and icon color respect attribute choice ([#1131](#1131)) ([cbfba7a](cbfba7a))

### Features

* Add loader ([#1180](#1180)) ([30c5263](30c5263))
* add show_legend_state ([#1173](#1173)) ([3b1c827](3b1c827))
Copy link

🎉 This PR is included in version 0.13.0-dev.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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