-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Update ToggleGroupControl visual design #74036
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
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in 0b90a38. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20430333984
|
|
Thanks for the PR! I wasn't involved in the discussions about redesigning this component, but to be honest, my first impression of the new UI was that it was hard to tell what was selected. 😅 This is because the selected item is only indicated by a light background color and borders on either side. I'm not sure if there are any clear accessibility guidelines for this type of UI, but maybe we should get feedback from the accessibility team. |
|
Looking at the latest proposed design, the borders on the item wrappers appear to be a little lighter in color. This makes it easier to visually identify selected items.
Note that this screenshot was captured on Windows OS, so the button text weights will be different than those on macOS. |
|
Thanks for the feedback @t-hamano! The control border is actually a point I meant to bring up. I agree the lighter border helps clarify the selected item. But I wasn't sure whether the control border also needs to meet contrast against the background. Let's wait and see the a11y feedback. |
mirka
left a comment
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.
there can be some visual artifacts caused by border overlaps
- Pushed a fix for this in f708ede.
- Also pushed a fix for the 36px icon button case in 6e4cdd1.
- I confirmed that the component is usable in forced-colors mode.
In general I'm ok to ship these changes as an iteration, but we'll soon need to:
- Figure out how the colors play into the color token system in
@wordpress/theme. - Figure out how to show the entire component as disabled (#57862), while there is still a selection.
And these two things don't seem to be easily reconcilable with this gray-ish design 🥲 I hope we can find some solutions.
packages/components/src/toggle-group-control/toggle-group-control/styles.ts
Outdated
Show resolved
Hide resolved
|
Thanks @mirka :) I think we'll need to do a deeper dive on a design spec for this when we come to 'migrating' it to |
|
@mirka I noticed one other small quirk; the icon version is now 42px tall instead of the intended 40px. |
I fixed this in ed0f6a3 but I don't know if it's the best approach. Is there a reason we use |
|
I have no idea what's going on here because I rebooted Storybook and the width offset indeed broke. And I set the values back to the initial values where it was broken and now it works?? 🫠 Also the control sizes were still weird after ed0f6a3 so I pushed another tweak.
This is what it looks like after the two new commits and a fresh Storybook reboot. Hope it's not another mirage… |
|
Just want to say that the iteration you all have moved towards here is so much better than where it started :) Looking really nicely and balanced :) |
|
I think a gap will cause layout issues in the Inspector. I tried an alternative in 0b90a38.
It's not an elegant solution, but it works. We might want to revisit the deselect-able variant in the future as it's semantically conflicted with the others ( |
mirka
left a comment
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 think we're ready to merge? 🚀
t-hamano
left a comment
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.
|
So cool to see this land - thank you 👏 |
|
I'm late to the party and I'm on a Mac, but solely judging from @t-hamano screenshot above, the slide in |
@hanneslsm I wrote a dedicated issue here, I'll work on a fix tomorrow. |
Thanks! |











What?
Updates the visual design of
ToggleGroupControlto be less visually prominent.Why?
See #64439
How?
The implementation replaces the
scaleXtransform with direct CSS properties and adds conditional visibility:Replaced transform-based scaling with direct width/height properties: Removed the
scaleX()transform that scaled a fixed-width element (100px via--antialiasing-factor). The indicator now useswidthandheightdirectly from--selected-widthand--selected-height, with 2px added to account for borders. This fixed an issue wherescalewas affecting the border width as the indicator elongated.Simplified border-radius calculation: Removed the dynamic border-radius that compensated for
scaleX. Now uses a staticCONFIG.radiusSmallvalue since scaling is no longer applied.Adjusted positioning: Changed
leftfrom-1pxto-2pxand addedtop: -1pxandbottom: -1pxto properly position the border around the selected option.Added conditional visibility: Implemented an
opacitycalculation using CSSmin()andmax()functions to hide the indicator when both--selected-widthand--selected-heightare unset (defaulting to 0). The indicator is visible when either dimension is greater than 0. This is necessary because otherwise – due to the new border – the indicator was visible when no item was selected.Updated visual styling: Reduced overall visual prominence.
Refined focus styles: Replaced the
box-shadowfocus indicator with a more accessibleoutlineusingCONFIG.borderWidthFocusand adjusted theoutline-offsetto1pxfor better visibility. This is more aligned with the direction@wordpress/uiis headed.Removed unnecessary properties: Eliminated
transform-origin(no longer needed without scaling) and removed padding from the size variants that was causing layout issues.Testing Instructions
npm run storybookand visit http://localhost:50240/?path=/docs/components-togglegroupcontrol--docsBefore
After