-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ColorArea and ColorWheel step and pagestep size fit evenly in range #2888
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
Conversation
Build successful! 🎉 |
Build successful! 🎉 |
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.
Confirmed that the thumb snaps to max/min value regardless of the amount of remaining distance to traverse
Build successful! 🎉 |
Build successful! 🎉 |
/** The page step size for the xChannel. */ | ||
xChannelPageStep?: number, | ||
/** The page step size for the yChannel. */ | ||
yChannelPageStep?: number |
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.
What's the use case to configure these?
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.
If someone sets a step size bigger than the page step size, then they may want to increase the page step size to compensate.
It might make more sense with HSL/HSB where you can have decimals and you actually want to decrease the page step size.
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.
what if we just multiply the step by some amount to find the page step?
Co-authored-by: Michael Jordan <[email protected]>
Build successful! 🎉 |
Build successful! 🎉 |
}, | ||
decrementY(stepSize) { | ||
setYValue(snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepSize)); | ||
setYValue(snapValueToStep(yValue - stepSize, minValueY, maxValueY, yChannelStep)); | ||
}, |
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 still think increment/decrement should snap to stepSize
rather than xChannelStep
or yChannelStep
. So that snapping is based on the interval by which one increments or decrements.
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.
For example step=5 pageStep=8
step start at 0 => 5
would it be
pageStep start at 0 => 8 & start at 5 (from the regular step) => 13
or is it
pageStep start at 0 => 8 & start at 5 (from the regular step) => 16
Native sliders, when supplied a step, cannot have a value that does not fall on a multiple of step. You can see this clearly in the Chrome Date picker. I think this is more predictable.
pageStep start at 0 => 8 & start at 5 (from the regular step) => 15
Or are you suggesting that color sliders are different from regular sliders?
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.
Caught up in the other discussion on the same topic. Devon had an idea, we keep the page step size out of the API and just treat it as a multiple of the step. We currently don't support page step size in our Sliders, so this makes a fair amount of sense
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 can see where you're coming from if the uses a step size that is not a factor of the page size. With ColorSliders, the step is usually 1, or 0.01 for alpha, and default for pageSize will always snap to step. Can do something like this, using modulus?
incrementX(stepSize) {
setXValue(xValue + stepSize > maxValueX ? maxValueX : snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepSize > xChannelStep && stepSize % xChannelStep === 0 ? stepSize : xChannelStep));
},
incrementY(stepSize) {
setYValue(yValue + stepSize > maxValueY ? maxValueY : snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepSize > yChannelStep && stepSize % yChannelStep === 0 ? stepSize : yChannelStep));
},
decrementX(stepSize) {
setXValue(snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepSize > xChannelStep && stepSize % xChannelStep === 0 ? stepSize : xChannelStep));
},
decrementY(stepSize) {
setYValue(snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepSize > yChannelStep && stepSize % yChannelStep === 0 ? stepSize : yChannelStep));
},
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.
it's getting too complicated I think, see previous comment about doing away with it in our API
That way we can make sure it's a multiple of the step and eliminate that worry.
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 guess my question would be, what multiple of a step would make the most sense for color channels? The reason for returning pageSize
as part of the color channel range object returned by Color.getChannelRange
was so that we could have more useful page stepping than simply dividing the range by 10. For example for the hue channel, a pageSize of 15 seems to make sense for snapping to primary, secondary and tertiary colors around the color wheel (BTW, we should use getChannelRange('hue').pageSize
instead of the PAGE_MIN_STEP_SIZE
constant in useColorWheel
). I suggested 0x11 as a pageSize for RGB channels because it divides 0xFF evenly, and increments channel values in a way that makes sense for web developers 0x11, 0x22, 0x33, 0x44, ..., 0xDD, 0xEE, 0xFF.
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.
Another option would be to eliminate step
and pageStep
from the public API for color controls, and use values that make sense for each color channel internally. Then we wouldn't have to worry about a pageSize
that is not a multiple of a step
because we would control it.
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.
Maybe this brings up if step should be configurable too?
What is the actual use case for setting step sizes in a color area or color slider? Maybe we should consider that color sliders are different than sliders
RGB 255 is not many values. Having the step size always be 1 and the page size always be 11 makes a lot of sense, you can get quickly to any value and you are always evenly and predictably within the range.
For HSL 0-360 and 0-1 are known ranges that will not change, a step of 1 and 0.01 respectively make sense and page sizes are easy to figure out from there as well.
I think what I'm saying is every color space is well defined and knowable.
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 agree that color spaces seem well defined and knowable. I suppose there may be some use cases for floating point steps with hue, saturation and lightness/brightness channels, but it should be noted that Photoshop throws up a dialog if you try to use a floating point value in one of its inputs.
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 still think that snapping to stepSize
, the pageStep
, is preferable to snapping to step
, the channel step
, and now that we can be sure that the channel step
is a factor of the stepSize
, I don't se why we shouldn't do it this way.
Build successful! 🎉 |
Build successful! 🎉 |
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.
Reminder that the aria/spectrum docs for ColorWheel/useColorWheel should also have references/examples to step
removed (probably do that in a separate PR, I can help w/ that). The functionality seem good to me
Yeah, it's in #2666 |
Ok, sweet. I'll go ahead and pull those docs changes out of the PR since those should go in after release |
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.
Can you add testing instructions? It didn't seem like you mentioned colorslider, but it looks like it changed too.
I tested and keyboard navigation seems good for colorslider. Home and end don't seem to matter for colorwheel since they both goto the same spot.
For color area RTL, home and end key events are still ltr.
I'm not sure what slider changes you are referring to? This is only ColorArea and ColorWheel. Home/End are reversed in RTL/LTR ColorArea. That wasn't changed. We can followup if that's weird and it should remain the same. Correct for ColorWheel, Home/End both go to the same spot. We can follow up if that's weird. |
Build successful! 🎉 |
Closes
Based on changes in #2570
ColorArea behavior is, step and pagestep size fits evenly into the range for RGB with meaningful values.
step is the smallest increment possible, 1
page step steps through web safe colors, 0x11
ColorWheel behavior is, step and pagestep size fits evenly into the hue range for HSL/HSB
step is the smallest increment possible, 1
page step increments by 15, which is large enough to cover the circle quickly but small enough to easily make hitting in between values also short
neither of these are exposed as part of the color area API, instead, when we allow bring your own colorspace, you can set the step and page size through that color space
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: