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: Dynamically adjust gradient percentages based on min/max values #18479

Merged
merged 4 commits into from
Nov 1, 2023

Conversation

schelv
Copy link
Contributor

@schelv schelv commented Oct 30, 2023

Updated the CSS gradient for the element to have its color stops adjust dynamically based on the and values of the color temperature selector.
This provides a more accurate visual representation of the selected range.

Proposed change

The documentation (link):

selector-color-temp

The dev branch:

image

Proposed in this pull request:
image

Blueprint used to create the images

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

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • 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:

@bramkragten
Copy link
Member

bramkragten commented Oct 30, 2023

We already have a function for that:

export const generateColorTemperatureGradient = (min: number, max: number) => {

Any reason you didn't reuse that?

@schelv
Copy link
Contributor Author

schelv commented Oct 30, 2023

We already have a function for that:

export const generateColorTemperatureGradient = (min: number, max: number) => {

Any reason you didn't reuse that?

I didn't know it existed.

@schelv
Copy link
Contributor Author

schelv commented Oct 30, 2023

The function you suggested works well.
The colors are very different than before, but this might be correct if you look at the image below.
https://en.wikipedia.org/wiki/Mired#/media/File:Planckian-locus-in-mireds.png
The default minimum value for the slider is 153, which is not as blue in the "locus" as it was in the old slider.

A bug might have been introduced when the -webkit-linear-gradient was changed to linear-gradient a few weeks ago; the direction of the gradient in the dev branch is different from the one in the documentation and the one I have running at home.
This is now restored with these changes

Updated the CSS gradient for the  element to have its color stops adjust dynamically based on the  and  values of the color temperature selector. This provides a more accurate visual representation of the selected range.
@schelv schelv force-pushed the dynamic-gradient-percentages branch from eaa6d37 to 9a0d1ae Compare October 30, 2023 22:39
@bramkragten bramkragten merged commit 5f2375f into home-assistant:dev Nov 1, 2023
12 checks passed
@schelv schelv deleted the dynamic-gradient-percentages branch November 1, 2023 16:22
@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2024
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.

2 participants