-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat(ui): slider for brush and eraser tool #8525
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(ui): slider for brush and eraser tool #8525
Conversation
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.
Thanks!
There is some layout shift when swapping between popover and slider:
Screen.Recording.2025-09-04.at.3.50.42.pm.mov
Maybe we can use a different style for the number input to prevent it from increasing the toolbar's height when slider is selected.
On my Macbook screen, the slider is large enough to push the canvas settings popover button into overflow. To find it and change the the setting back to drop-down, I need to collapse one of the panels:
Screen.Recording.2025-09-04.at.3.53.49.pm.mov
I also noticed that the slider kinda smooshes up against the color picker circles when there isn't enough room for it.
One solution might be to use container queries or a ResizeObserver
to determine if we have enough room for the slider. If there isn't enough room, render the popover version. No need for a user-facing setting in this case, which is nice.
a228e66
to
42c1682
Compare
|
8623af0
to
47eabfd
Compare
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.
Thanks!
- I updated the styling a bit to better fit in the toolbar.
- The logic to conditionally render the slider vs dropdown was hard to follow. I simplified it and removed the dependency on the external hook*, instead using a
ResizeObserver
directly in the component.
*I do like how the hook uses a singleton ResizeObserver
instance as an optimization. But we only have a couple observers across the whole app and one of them is not in react. So I don't think it's really worth an extra dependency at this time.
Summary
A new feature was implemented to set the width of the Brush and Eraser tools using a slider.
toolWidthSelector
, was added tocanvasSettingsSlice.ts
to perist the current tool with selector type, which can bedrop-down
orslider
CanvasSettingsToolWidthSelectorDropdown
, to be able to choose the used tool width selectorDropDownToolWidthSelector
component and new slide based selector was created inSliderToolWidthSelector
componentToolWidth
component, which is used to buildToolBrushWith
andToolEraserWidth
componentscontrolLayers.toolWidthSelector
,controlLayers.toolWidthSelectorDropDown
andcontrolLayers.toolWidthSelectorSlider
, were added toen.json
Related Issues / Discussions
Closes #8382
Checklist
What's New
copy (if doing a release after this PR)