-
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
Replace block variation buttons with ToggleGroupControl #45654
Replace block variation buttons with ToggleGroupControl #45654
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
It might look a bit closer to the original if we add |
Thanks for pointing this out! I'll change it! |
Thanks for looking into this one! Unfortunately switching over to While the Group block currently only has a few variations, it's possible that there are custom blocks out in the wild with larger numbers of variations with the One way to test this manually is to hard-code the social link/icon block to expose the block variations as transforms. To do this, add the following line to the
All up that area in my local environment looks like:
That then exposes all the social icon variations in the UI for testing. Would it be possible to use the |
Thanks for pointing this out @andrewserong. I'll add a check! |
padding: 0 $grid-unit-20 $grid-unit-20 52px; | ||
width: 100%; | ||
|
||
.components-dropdown-menu__toggle { |
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 for the follow-ups!
Are these style removals intentional? Most of these appear to affect the dropdown list version of the list of variations, which is used when not all of the variations have unique icons.
To test this, with the changes applied to scope the social icons for transform
, in packages/block-library/src/social-link/variations.js
also set any of the social icon blocks to use the same icon as one of the other variations. E.g. set any of them to use the YouTubeIcon
icon.
Here's a quick view of trunk versus this PR:
Trunk | This PR |
---|---|
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.
Oops, I need more coffee. I forgot to push the changes 😄 Thanks for your patience!
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.
Oops, I need more coffee.
No worries, I have the opposite problem of having drunk too much coffee!
I've re-pulled the changes, and it looks like there are still some differences in the dropdown popover for the transform to variation list. Visually it looks like there's now additional padding / a larger width of the popover, and it overflows the area so there's a horizontal scrollbar:
Trunk | This PR |
---|---|
packages/block-editor/src/components/block-variation-transforms/style.scss
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/block-variation-transforms/style.scss
Outdated
Show resolved
Hide resolved
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 work @TimBroddin, thanks for all the back-and-forth here! This is testing well for me in all three cases:
✅ Group block's variations use the ToggleGroupControl
and toggle as expected
✅ A block with a large number of variations, each with a unique icon, correctly renders the buttons approach
✅ A block with a large number of variations, where there are not unique icons, renders the drop down list approach
This LGTM! ✨ It might be worth also getting an approval from a designer before merging, too
@jasmussen just copying you in on this one as I think from memory you put together the original designs for this area? |
Hey, thanks for the PR, thanks for the ping, conceptually seems just right. Just to be sure I get the context right: when there are more than a rows worth of transforms, they still become a dropdown, correct? This is what I'm seeing in the branch: There should be no enclosing border around these controls. I thought actually that was removed as part of #45492, but it seems to be there after a rebase. Is there a prop that needs to be set/unset? CC: @mirka @ciampo |
<Flex> | ||
<ToggleGroupControl | ||
label={ __( 'Transform to variation' ) } | ||
value={ selectedValue } | ||
isBlock |
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.
Regarding @jasmussen point about the border: The isBlock
prop is what controls the border visibility for the moment. It looks like the Flex
component is being used here to undo what the isBlock
prop is for anyway, so I think all we need to do is remove both the Flex and isBlock
prop 🙂
variations, | ||
} ) { | ||
return ( | ||
<fieldset className={ className }> |
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.
Is this fieldset necessary? The ToggleGroupControl alone is semantically grouped and labeled. Maybe swap with a div
if it's just for the wrapper classes?
@TimBroddin Are you available to address the remaining feedback? If not, let us know so we can find someone to take over 🙂 |
If you could find someone to take over, that would be great. Sorry for not addressing this earlier. |
What?
The buttons to transform blocks to different variantions should be replaced with the new icon button variant of ToggleGroupControl.
Why?
Because the ToggleGroupControl is better suited for this. This will improve consistency, reduce code duplication, and add visual/semantic indications that the options are mutually exclusive.
How?
I replaced the buttons with
ToggleGroupControl
/ToggleGroupControlOptionIcon
Testing Instructions
Screenshots or screencast