-
Notifications
You must be signed in to change notification settings - Fork 47
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
Don't update saturation based on parsed color #536
Don't update saturation based on parsed color #536
Conversation
Hi there @bjarnef, thank you for this contribution! 👍 While we wait for the team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
Excellent, @bjarnef. Can we just cross saturation out like that for all scenarios? If yes, feel free to fix the linting errors and remove the console.log's and we'll get it merged 😎 |
@iOvergaard an issue with this is that saturation (and eventually hue as well) is not set the specific color value. It is fine that I think we may need some variables to keeper track of the grid handle coordinates, initially from color value and updated as handle is moved around, which update e.g. hue and saturation values, but doesn't affect current handle position Even though color is black at different positions. However when a color from palette is selected it update the value property in Another thing I noticed is that moving the handle using left/right arrow keys no longer seems to keep same Y-coordinate as it originally did https://shoelace.style/components/color-picker - it does in |
Ok, @bjarnef, I think I see what you are getting at. I think we could try your proposal out by not updating the saturation. We can add additional variables to keep the handle coordinates in sync if needed down the road. Would you like to try and get this PR to pass the automated tests? |
@iOvergaard yeah, but not updating the saturation in value property means the spectrum isn't initially correct from color value set, or e.g. when hue slider change or a color from palette is selected. It is also a similar issue with hue, e.g. with a green'ish gradient in color area, when dragging handle to bottom (black) it updates the value, which then parse the color and from chrome_VAGHi5Gj69.mp4E.g. compare with how the Shoelace color picker handle this, where but it also parsed color as where we here parse from
|
@iOvergaard I think it is related to this, but I noticed when color is black and changing the hue slider, the color area doesn't change - probably due how it parse the HSL values from In the Shoelace color picker the values are modified directly, but here we have e.g. color area in an isolated component. It also seems a change has been made and the picker icon is no longer shown here? |
@iOvergaard regarding change of hue slider, something weird happens in Even though hue parsed in is greather than zero, the parse color using I added a workaround in 9fe8a29 chrome_nLnJEbp5c6.mp4I also noticed something that has affected the opacity slider - when dragging the slider value, it shouldn't change opacify of the slider itself, only the preview, so it still show the color gradient like this: https://shoelace.style/components/color-picker#opacity Fixed in dd34062 as well. |
…d value itself may contain alpha
@iOvergaard can you review these changes? 👍 It solves a few issues.
It also noticed some issues with vertical slider mostly where click/drag to a position, sometimes the handle jumps back or move a few pixels afterwards, but we can looks at this in another PR. |
Hi @bjarnef, thanks for your updates and yes, we'll get it reviewed 👍 |
I think there may be a bug in Colord, when passing in |
Hi @loivsen Yes, I think it may be because of saturation: https://github.com/umbraco/Umbraco.UI/pull/536/files#diff-e26cfd40613cb37d73b2bf9ca447a92b2d7caac910979aa0dc992c7976494c0bR161 Maybe we could update it as well like with hue if value is not zero. Regarding the duplicate 194 value, it was to output the hue in color picker (the other is inside hue slider). I will remove that. |
Regarding the disabled feature its another issue, but in e.g. Codepen example of the Shoelace Color Picker, it looks something like this: However it's still possible to toggle color format and pick a color via the eyedropper. |
I would like to get these improvements merged in. @bjarnef can you look into the build error and then get the branch up to date as well? 😊 |
@iOvergaard I tried creating a Pen to use the color picker from UI library.
chrome_PFTfloSGK8.mp4 |
this.hue = h; | ||
} | ||
|
||
//this.saturation = s; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried the following here, but it seem it made the handle "jump" and bit anyway and the color spectrum seemed to be affected. When dragging the handle in the spectrum, I would expect the gradient shouldn't change.
if (s !== 0) {
this.saturation= s;
}
@bjarnef that's a bit spooky, could you try with the latest RC to see if any related fixes are working? The link is: https://cdn.jsdelivr.net/npm/@umbraco-ui/[email protected]/dist/uui.min.js Something could also be happening in the CJS version, which your pen is using. BTW @loivsen briefly mentioned that she thought it might not work in Firefox, did you notice if there are problems there? |
@iOvergaard that didn't make a difference :)
It does seem the Color Picker works in Firefox as well at least when checking from https://uui.umbraco.com/ |
@iOvergaard do you want to have another look at this? or maybe @nielslyngsoe knows? Although it don't quite fix this ensure issue, it also handle when hue and opacity change. Also any idea why the sliders doesn't work from codepen?
|
@iOvergaard can we merge this for now and improve later? I think this work better than the current version, but there is space for improvement. |
@bjarnef sure thing... would you take a look at the failing build? |
@iOvergaard it shows this, but it doesn't seem to be related to these changes. |
@bjarnef Storybook won't deploy from forks, but still the "Tests" job is failing as well as the linter. |
@iOvergaard the tests are happy now 😅 |
Description
This PR fixes an issue in color picker component, when dragging the handle to the bottom, where it sometimes jump to bottom left, because when the color value of
#000000
thenconst { h, s, l } = parsed.toHsl();
returns a saturation value of0
, which affect thegridHandleX
to be0
.#533
chrome_qFG9VWOgbD.mp4
Types of changes
Motivation and context
How to test?
Screenshots (if appropriate)
Checklist