-
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
UnitControl: Add lint rule for 40px size prop usage #64520
Conversation
Size Change: +207 B (+0.01%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
@@ -38,13 +38,20 @@ The current value of the letter spacing setting. | |||
|
|||
A callback function invoked when the value is changed. | |||
|
|||
### `_unstableInputWidth` | |||
### `__unstableInputWidth` |
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.
Fixed typo
@@ -35,6 +37,7 @@ export default function LetterSpacingControl( { | |||
} ); | |||
return ( | |||
<UnitControl | |||
__next40pxDefaultSize={ __next40pxDefaultSize } |
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.
This was already passed through via otherProps
, but making it explicit here.
@@ -134,8 +134,7 @@ const DimensionControls = ( { | |||
panelId={ clientId } | |||
> | |||
<SelectControl | |||
// TODO: Switch to `true` (40px size) if possible | |||
__next40pxDefaultSize={ false } | |||
__next40pxDefaultSize |
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.
Before | After |
---|---|
Incorrect column gap will be addressed separately at #64488
label={ __( 'Minimum height of cover' ) } | ||
id={ inputId } | ||
isResetValueOnUnitChange | ||
min={ min } | ||
onChange={ handleOnChange } | ||
onUnitChange={ onUnitChange } | ||
__unstableInputWidth="80px" | ||
__unstableInputWidth="116px" |
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.
Before | After |
---|---|
This custom styling that allows the label to expand wider than the control is... not great. I agree that the visual UI looks the best this way in this specific instance, but I struggle to think of a universally nice way to capture this pattern. The custom styling is applied from an English-centric eye, so it's likely that we're not doing this for UnitControls that happen to have a label that doesn't overflow in English. And what if we ever change the font size or styling of the labels, and some labels that previously fit in a single column start to overflow?
Would it be worth making this label-expanding the default behavior for "single-column" controls that have enough space for the label to expand (not sure if even feasible)?
Other more simple guidelines to maintain consistency would be:
Thoughts? @WordPress/gutenberg-design
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 personally think "Min. height" would be okay, though this question has come up in the past and suggested that "Minimum height" is better.
But can it be a full-row, with input on the left, and slider on the right? This would only work when minimum height is the only control, where for example "Width" and "Height" make a good two-column pair.
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.
Ok, I think I can do "Minimum height" for this one. I guess the universal guideline remains that these labels should ideally fit within a single column, and no cheating just because it happens to overflow in English 😂
But can it be a full-row, with input on the left, and slider on the right?
This has come up before (#60633), but there's some disagreement as to whether sliders are appropriate for inputs without a clear upper bound, as is in this case.
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 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.
This is something that should be solved universally, and not on a case-by-case basis, especially since we can't predict the length of those labels when they get translated to other languages:
- we should keep our strings as short and clear as possible;
- we should have a universal solution for when these input label don't fit in their space — could we truncate + ellipse them?
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.
They are truncated + ellipsized by default. It's just that this case was initially "cheating" by expanding only the label into two columns.
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 see — IMO it would be probably better to remove the "cheat", if possible
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.
Yes we did remove it, this is the before/after.
// TODO: Switch to `true` (40px size) if possible | ||
__next40pxDefaultSize={ false } |
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 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 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 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.
Maybe, though to me they also look clickable there :). They also wouldn't line up with other icons in the panel, though that's secondary since it's alread an issue.
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 find the InputControl prefix slot is usually used for decorative items, whereas the label suffix is usually for interactive items, yes. Ideally I'd like to put it in the prefix slot, but not sure if it'll fit in a two-column layout. I can try.
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'm not sure about the two rows, being on one row implies these are related, which they are. I think this is worth solving in design before we move that much farther.
Did you consider the 12px padding left/right with a smaller unit selector? The gaps in #64520 (comment) should be possible to reduce quite a bit.
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.
Ok, if two rows are also not great, I'll leave these controls as is for this PR. The required changes are out of scope.
I'm on board with reducing the input paddings to 12px though, as long as we do it separately and the Figma files are updated 👍 As for the unit selector, I'm not sure we have much to reduce unless we do something a bit more drastic, since this is what we're dealing with:
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.
Ooh, the new Figma file already does have tighter margins, perfect! Will reflect in code then 👍
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.
Input padding decrease proposed in #64708.
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.
Unit select dropdown changes proposed in #64712.
@@ -73,13 +73,13 @@ function CoverHeightInput( { | |||
|
|||
return ( | |||
<UnitControl | |||
label={ __( 'Minimum height of cover' ) } | |||
__next40pxDefaultSize |
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.
Before | After |
---|---|
Tweaked as discussed in #64520 (comment)
f069805
to
71fbd47
Compare
@@ -628,8 +635,8 @@ export default function DimensionsPanel( { | |||
/> | |||
) : ( | |||
<UnitControl | |||
__next40pxDefaultSize |
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.
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. |
This is ready for final review @WordPress/gutenberg-components 🙏 The Content/Wide controls will be addressed separately. |
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.
LGTM 🚀
Thank you for all the discussion and the separate clean-ups, all those small details put together can really make a difference.
* Fix in Featured Image block * Fix in Cover block * Make explicit in LetterSpacingControl * Add TODO comments * Add lint rule * Tweak in Cover block * Move to prefix slot in Dimensions Panel * Tweak padding? * Fix "Block spacing" in Dimensions Panel * Add LetterSpacingControl to linter * Fix tests * Revert "Tweak padding?" This reverts commit 7aabc76. * Revert "Move to prefix slot in Dimensions Panel" This reverts commit 2b3e3a1. * Move to less strict lint * Add link to relevant discussion Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org>
Part of #63871
What?
Add a lint rule to prevent people from introducing new usages of UnitControl that do not adhere to the new default size.
How?
I migrated all the usages, except for the Content/Wide controls that will require component-level design changes.
Testing Instructions
The lint error should trigger for violations as expected.