-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
CustomGradientBar: Fix insertion and control point positioning to more closely follow cursor #41492
CustomGradientBar: Fix insertion and control point positioning to more closely follow cursor #41492
Conversation
Size Change: +3 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
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.
Nice touch @andrewserong! ✨
This is testing well for me and I believe the proposed approach make sense.
✅ Could replicate issue on trunk
✅ Works well in Storybook example
✅ Works well in the editor
✅ Unit tests are passing
Storybook
Before | After |
---|---|
Screen.Recording.2022-06-02.at.5.07.54.pm.mp4 |
Screen.Recording.2022-06-02.at.5.03.25.pm.mp4 |
Editor
Before | After |
---|---|
Screen.Recording.2022-06-02.at.5.15.54.pm.mp4 |
Screen.Recording.2022-06-02.at.5.17.11.pm.mp4 |
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.
Thank you for working on this, @andrewserong — a subtle improvement, but really appreciated!
…t it more closely follows the cursor
6e3b304
to
6be7c2b
Compare
Thanks for the reviews, folks! And good idea about adding in the |
What?
Fixes part of #41390
This is a pretty subtle issue to look at visually, but it's much more noticeable when interacting with the component.
Update the
CustomGradientBar
component to fix the positioning of the control points and inserter so that it follows the cursor position more accurately.Why?
As raised in #41390, the existing logic for where to position the control points and inserter in the custom gradient bar is slightly off — it's more noticeable at larger viewport sizes when the component is rendered in Storybook, however it's still a bit fiddly in real world usage in the gradient color picker in the editor, so this PR should hopefully help improve the UX of interacting with the controls.
How?
calc()
rule when rendering the position to offset the control point so that it's centered in its position.padding-right
setting, we use a container with slightly less width.ref
for tracking the positions of control points to the container of the markers, to improve accuracy (this is the component that the markers are positioned in relation to, so I think this should help with the accuracy, too)Testing Instructions
npm run storybook:dev
Check that tests pass (they can be run locally via:
npm run test-unit -- --testPathPattern packages/components/src/custom-gradient-bar/test/utils.js
)Screenshots or screencast