Skip to content
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

UnitControl: Update unit select styles #64712

Merged
merged 3 commits into from
Aug 22, 2024
Merged

UnitControl: Update unit select styles #64712

merged 3 commits into from
Aug 22, 2024

Conversation

mirka
Copy link
Member

@mirka mirka commented Aug 22, 2024

What?

Makes the following improvements to the UnitControl unit select styles when in the 40px size:

  • Adds field-sizing: content so the select can hug the width of the current unit label. This will make the whitespace look more consistent across units. (Consider this a progressive enhancement, because the field-sizing property is not implemented in Safari and Firefox yet.)
  • Fixes the hover style, which didn't properly reflect the border radius.

Testing Instructions

See Storybook for UnitControl.

Screenshots or screencast

Before After
UnitControl, before UnitControl, after

@mirka mirka added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Aug 22, 2024
@mirka mirka self-assigned this Aug 22, 2024
@mirka mirka requested a review from ajitbohra as a code owner August 22, 2024 08:38
Copy link

github-actions bot commented Aug 22, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@@ -114,7 +115,7 @@ const unitSelectSizes = ( { selectSize = 'default' }: SelectProps ) => {
align-items: center;

&:where( :not( :disabled ) ):hover {
box-shadow: inset 0 0 0
box-shadow: 0 0 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be curious to know the reason for using inset in the first place

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was copypasta from the older 36px size.

UnitControl 36px size with inset box-shadow

Copy link

Flaky tests detected in af44d19.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10504728508
📝 Reported issues:

@jameskoster
Copy link
Contributor

Nice :)

I'm curious about where the styling for the unit selector comes from, is it custom? It seems that we could save a little space by removing the padding and the min-width?

@mirka
Copy link
Member Author

mirka commented Aug 22, 2024

It seems that we could save a little space by removing the padding and the min-width?

@jameskoster Could you clarify to make sure I'm understanding you correctly? The padding is already the lowest we can go (4px), and a 24px min-width seems reasonable to maintain as a tap target.

@jameskoster
Copy link
Contributor

I meant that if we remove the padding then the select width could be reduced slightly, which might be helpful in certain situations like the Content / Wide inputs we were discussing recently. We could save 4px:

Screenshot 2024-08-22 at 12 34 59

(Top is current, bottom is 0 padding). It seems like the padding is only there to accommodate the hover style (outline), but that could easily be tweaked to something else like an underline.

and a 24px min-width seems reasonable to maintain as a tap target

Fair point!

@mirka
Copy link
Member Author

mirka commented Aug 22, 2024

I see, thanks for clarifying!

It seems like the padding is only there to accommodate the hover style (outline), but that could easily be tweaked to something else like an underline.

Personally, an underline for a hover/focus style seems quite foreign in our look & feel, like it comes from a different universe (Google Material). We can consider it separately from this PR if you want to propose it though!

@mirka mirka merged commit e7674d6 into trunk Aug 22, 2024
61 checks passed
@mirka mirka deleted the unit-select-styles branch August 22, 2024 11:56
@github-actions github-actions bot added this to the Gutenberg 19.2 milestone Aug 22, 2024
bph pushed a commit to bph/gutenberg that referenced this pull request Aug 31, 2024
* UnitControl: Update unit select styles

* Add changelog

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants