-
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 BaseControl #64355
Conversation
<BaseControl className="gallery-image-sizes"> | ||
<BaseControl | ||
className="gallery-image-sizes" | ||
__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.
<BaseControl | ||
label={ __( 'Width' ) } | ||
id={ unitControlInputId } | ||
<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 the editor, add a Search block and see the block inspector.
Before | After |
---|---|
This UI probably should be updated to DimensionTool
, but I'll just do a quick fix here.
Spacing is the same as a similar pattern in the Latest Posts block.
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.
Looks good, but it would have been suitable for another PR, perhaps with a design person taking a look 🤔
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.
You may be right! This is still bad though, just incrementally better. I'm keeping an eye on #52223 to figure out what this UI should be ideally.
Size Change: +194 B (+0.01%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
# Conflicts: # packages/block-library/src/latest-posts/edit.js
.wp-block-tag-cloud__inspector-settings { | ||
.components-base-control, | ||
.components-base-control:last-child { | ||
// Cancel out extra margins added by block inspector | ||
margin-bottom: 0; | ||
} | ||
} |
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 painful 😭 I'm going to propose a better way to deal with these once the deprecation work is done.
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.
Indeed. Let's definitely open an issue to keep track of those 👍
setAttributes( { taxonomy: selectedTaxonomy } ) | ||
} | ||
/> | ||
<BaseControl> |
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.
@@ -83,6 +83,7 @@ const VideoSettings = ( { setAttributes, attributes } ) => { | |||
) } | |||
/> | |||
<SelectControl | |||
__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 is the "Preload" dropdown in the Video block inspector controls. (It's named like it's a reused component, but currently only used in the Video block.)
@@ -219,7 +219,7 @@ function VideoEdit( { | |||
attributes={ attributes } | |||
/> | |||
<MediaUploadCheck> | |||
<BaseControl className="editor-video-poster-control"> | |||
<div className="editor-video-poster-control"> |
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.
/** | ||
* `BaseControl` is a component used to generate labels and help text for components handling user inputs. | ||
* |
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.
Moved the JSDocs so they are correctly associated with the exported components. Also made sure the code snippets both have the no margin prop.
@@ -45,7 +49,7 @@ function SizeControl( props ) { | |||
}; | |||
|
|||
return ( | |||
<BaseControl { ...baseControlProps }> | |||
<BaseControl { ...baseControlProps } __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
In Global Styles, go to Typography ▸ Font size presets ▸ (whatever option). Enable the Fluid typography and Custom fluid values toggles.
Before | After |
---|---|
I normalized the spacing.
I extracted out a labeling bug as a separate issue: #64406.
// Do not allow manipulation of margin bottom | ||
__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.
No back compat concerns because this component is private.
@@ -323,6 +323,7 @@ function PushChangesToGlobalStylesControl( { | |||
|
|||
return ( | |||
<BaseControl | |||
__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.
@@ -143,6 +143,7 @@ export function CreateTemplatePartModalContents( { | |||
required | |||
/> | |||
<BaseControl | |||
__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.
@@ -92,6 +92,7 @@ function PatternOverridesControls( { | |||
<> | |||
<InspectorControls group="advanced"> | |||
<BaseControl | |||
__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.
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.
Tests as expected 👍
The looks good ✅
Thanks for the extra thorough instructions and context 💯
🚀
<BaseControl | ||
label={ __( 'Width' ) } | ||
id={ unitControlInputId } | ||
<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.
Looks good, but it would have been suitable for another PR, perhaps with a design person taking a look 🤔
.wp-block-tag-cloud__inspector-settings { | ||
.components-base-control, | ||
.components-base-control:last-child { | ||
// Cancel out extra margins added by block inspector | ||
margin-bottom: 0; | ||
} | ||
} |
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.
Indeed. Let's definitely open an issue to keep track of those 👍
* Fix in Gallery block * Fix in Latest Posts block * Fix in Search block * Fix in Tag Cloud block * Fix in Video block * Fix in Global Styles Font Size * Fix in Global Styles PushChangesToGlobalStylesControl * Fix in new template part modal * Fix in pattern overrides block inspector * Add lint rule * Update docs Co-authored-by: mirka <[email protected]> Co-authored-by: tyxla <[email protected]>
Part of #38730
What?
Adds eslint rules to prevent new instances of
BaseControl
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.