-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add visualizers for padding and margin for all blocks #40505
Conversation
@aaronrobertshaw I noticed that you've added a new visualizer for border, maybe we can use the same technique as this PR? How can I experience it? |
Size Change: -281 B (0%) Total Size: 1.23 MB
ℹ️ View Unchanged
|
Does this supersede #40253, or will the new |
Thanks for the ping. @kevin940726 is currently working on #40253 which reimagines the visualizer. I believe the plan was to support borders via that. I'm not sure we can call the new |
I actually didn't know about #40253 :) In principle, it's the same thing but I think "Popover" is already capable of handing what the new component is trying to do without the added code and complexity. (I do think there are opportunities to improve the internals of Popover) though. |
@jasmussen I haven't been able to reproduce neither of these issues 🤔 |
I can still reproduce after a fresh npm install. Try these steps exactly:
What do you see? |
@jasmussen I reproduced once, but I'm failing to reproduce now 😬 |
@jasmussen oh, I see now, It is actually a bug in trunk as well, it's independent of this PR. Basically when I try to undo a change of padding, it undo but then restores the old value right away. I think it's probably a bug in |
@jasmussen the fix for the padding change is here #40518 but I might need help from components folks to make sure the tests and everything is correct. I think we shouldn't block the work in the current PR though since the bug is already in trunk. |
Definitely agree, this one feels amazing. I'd be happy to give a green check. |
I love this is being accomplished with more code removed than added :) |
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 like the approach, and this seems to be working well.
As far as implementation details go, I like the locality: the relationship between the hooks, BlockPopover and Popover is fairly intuitive, and it's clear what each piece is responsible for.
Bonus points for cutting down on unused components and converging. :)
<BoxControlVisualizer | ||
values={ styleAttribute?.spacing?.padding } | ||
showValues={ styleAttribute?.visualizers?.padding } | ||
className="block-library-cover__padding-visualizer" | ||
/> |
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.
👏
Co-authored-by: Miguel Fonseca <[email protected]>
Going to merge this as it's gets the feature in without new APIs or overhead but it doesn't mean we can't extract reusable components from this later if needed. |
closes #36418
closes #40057
What?
This PR adds "visualizers" when editing padding/margin controls in blocks that support them.
Why?
The visualizers gives the user clarity of the impact its changes are having on the block.
How?
Previously we had
BoxControl.Visualizer
components, it was used in the Cover block padding for instance, but it suffered two major issues:Note
I'm planning to use the BlockPopover (with cover argument) in #40376 to render the side remove buttons... So this PR is also a requirement for that.
Testing Instructions
1- Insert a block that supports padding or margin (group, cover...)
2- Tweak the value for these controls
3- Notice the visual effect (blue squares) when changing the value.
Screenshots or screencast
Screen.Recording.2022-04-21.at.10.15.46.AM.mov