-
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 margin-bottom lint rules for TextControl #64212
Conversation
Size Change: +73 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
@@ -63,6 +63,7 @@ function InputFieldBlock( { attributes, setAttributes, className } ) { | |||
) } | |||
<InspectorControls group="advanced"> | |||
<TextControl | |||
__nextHasNoMarginBottom |
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.
<VStack spacing={ 4 }> | ||
<TextControl | ||
__next40pxDefaultSize | ||
__nextHasNoMarginBottom |
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.
Testing instructions
Go to the Pages view in Site Editor (wp-admin/site-editor.php?postType=page
), and click the Add New Page button.
Before | After |
---|---|
@WordPress/gutenberg-design I'm seeing some inconsistency in the spacing before the CTA button in contexts like this. The Figma specs it as 24px — should I follow that everywhere? Also, would the spacing be different in a non-Modal context like Data Views Quick Edit, or a small block toolbar popover like the Language formatter?
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.
@jameskoster @mattrwalker this would be a great opportunity to fix up the modal component, bring it in sync. What's the right value?
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 there could be a case for a dedicated ModalFooter
(or similar) component that handles this. It should:
- Align the buttons (right)
- Set spacing
- Set the button order (primary always right-most)
- Limit to two buttons
- Handle small-screen behavior (make buttons full width and/or stack)
But that's probably part of a much broader update to Modal
. Until we have a clear design for that I don't suppose the spacing matters too much – I'd probably just aim for what exists on trunk.
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 we don't have spec'ed values yet, I'm going to go with the path of least resistance as long as it's in the general vicinity of what's correct. In a lot of cases, that's going to be a space equidistant between all the control gaps (i.e. throw them all in a single VStack
). This is going to be easier to deal with later once we decide on an official value.
@@ -13,6 +13,7 @@ import { | |||
Button, | |||
Popover, | |||
__experimentalHStack as HStack, | |||
__experimentalVStack as VStack, |
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.
return ( | ||
<VStack spacing={ 4 }> | ||
{ visibleFields.map( ( field ) => { | ||
return ( | ||
<field.Edit | ||
key={ field.id } | ||
data={ data } | ||
field={ field } | ||
onChange={ onChange } | ||
/> | ||
); | ||
} ) } | ||
</VStack> |
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.
Testing instructions
In Gutenberg experiments (wp-admin/admin.php?page=gutenberg-experiments), enable the "Quick Edit in DataViews" experiment. In the Site Editor, go to Pages (wp-admin/site-editor.php?postType=page
) and switch to Table view.
Select a page row. Click the "Show quick edit sidebar" button.
Before | After |
---|---|
These changes can also be seen in the Storybook for DataForm
.
__next40pxDefaultSize | ||
__nextHasNoMarginBottom |
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 the SelectControl in the Data Views Quick Edit.
@@ -54,6 +54,7 @@ function Edit< Item >( { | |||
value={ value ?? '' } | |||
onChange={ onChangeControl } | |||
__next40pxDefaultSize | |||
__nextHasNoMarginBottom |
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 the TextControl in the Data Views Quick Edit.
<VStack as="form" onSubmit={ onSubmit } spacing={ 4 }> | ||
<DataForm | ||
data={ itemWithEdits } | ||
fields={ fields } | ||
form={ form } | ||
onChange={ setEdits } | ||
/> | ||
<Button | ||
variant="primary" | ||
type="submit" | ||
accessibleWhenDisabled | ||
disabled={ isUpdateDisabled } | ||
> | ||
{ __( 'Update' ) } | ||
</Button> | ||
</form> | ||
<FlexItem> | ||
<Button | ||
variant="primary" | ||
type="submit" | ||
accessibleWhenDisabled | ||
disabled={ isUpdateDisabled } | ||
__next40pxDefaultSize | ||
> | ||
{ __( 'Update' ) } | ||
</Button> | ||
</FlexItem> | ||
</VStack> |
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 the form
wrapping the Data Views Quick Edit.
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. |
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 code looks good, and all changes test well! ✅
Thanks for the thorough instructions @mirka 🚀
I feel like the minor spacing discrepancy can be addressed separately.
Part of #38730
What?
Adds eslint rules to prevent new instances of
TextControl
to be introduced in the Gutenberg codebase without the__nextHasNoMarginBottom
prop being added.Why?
These lint rules should prevent new violating usages from being added, until we are ready to officially deprecate the margins on the BaseControl-based components all at once.
Testing Instructions
See code comments.