-
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 ToggleControl #64213
Conversation
@@ -67,6 +67,7 @@ export default function ImageSettingsPanel( { | |||
panelId={ panelId } | |||
> | |||
<ToggleControl | |||
__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.
@@ -201,6 +201,7 @@ function BlockHooksControlPure( { | |||
|
|||
return ( | |||
<ToggleControl | |||
__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
Apply the following diff. In the Site Editor, go to Templates ▸ Single Posts template. See the block inspector for the Content block.
diff --git a/gutenberg.php b/gutenberg.php
index b12c346741..fe14f2cafb 100644
--- a/gutenberg.php
+++ b/gutenberg.php
@@ -74,3 +74,14 @@ function gutenberg_pre_init() {
require_once __DIR__ . '/lib/load.php';
}
+
+add_filter( 'hooked_block_types', function ( $hooked_blocks, $position, $anchor_block ) {
+ if ( $anchor_block === 'core/post-content' && $position === 'after' ) {
+ // Add some core blocks after the post content.
+ $hooked_blocks[] = 'core/paragraph';
+ $hooked_blocks[] = 'core/separator';
+ $hooked_blocks[] = 'core/page-list';
+ }
+
+ return $hooked_blocks;
+}, 10, 3 );
Size Change: +1.38 kB (+0.08%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
@@ -58,6 +58,7 @@ const AvatarInspectorControls = ( { | |||
/> | |||
{ attributes.isLink && ( | |||
<ToggleControl | |||
__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.
@@ -48,6 +48,7 @@ function DetailsEdit( { attributes, setAttributes, clientId } ) { | |||
<InspectorControls> | |||
<PanelBody title={ __( 'Settings' ) }> | |||
<ToggleControl | |||
__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.
@@ -202,6 +202,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) { | |||
<InspectorControls> | |||
<PanelBody title={ __( 'Post content' ) }> | |||
<ToggleControl | |||
__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.
@@ -36,6 +36,7 @@ export default function EnhancedPaginationControl( { | |||
return ( | |||
<> | |||
<ToggleControl | |||
__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.
@@ -169,6 +169,7 @@ function TagCloudEdit( { attributes, setAttributes } ) { | |||
required | |||
/> | |||
<ToggleControl | |||
__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.
@@ -74,6 +74,7 @@ export default function InitPatternModal() { | |||
__next40pxDefaultSize | |||
/> | |||
<ToggleControl | |||
__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.
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.
Related discussion about how much space we actually want before the primary button. Tl;dr — we're not sure yet.
@@ -131,6 +131,7 @@ export function CreatePatternModalContents( { | |||
categoryMap={ categoryMap } | |||
/> | |||
<ToggleControl | |||
__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.
@@ -176,6 +176,7 @@ export default function ReusableBlockConvertButton( { | |||
placeholder={ __( 'My pattern' ) } | |||
/> | |||
<ToggleControl | |||
__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.
As far as I can tell, this package is not used in the app code anymore. And the term "reusable block" has been changed to "synced patterns". But I think we can assume this create pattern modal is the same as the previous two.
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 👍 Thanks for the thorough testing instructions 🚀
@@ -296,6 +296,7 @@ module.exports = { | |||
'RangeControl', | |||
'SearchControl', | |||
'TextareaControl', | |||
'ToggleControl', |
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 assume we're intentionally adding the rules to:
- RN occurrences
- Readme occurrences
- Test occurrences
I wonder if it makes sense to add the prop to README occurrences at least? Right now, we're suggesting code that will lead to ESLint errors.
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.
Good point, I missed some places in the README and JSDocs. I'll do a final check for the rest of the components as well.
(Not sure if a typo, but we're not adding the prop to React Native components.)
Part of #38730
What?
Adds eslint rules to prevent new instances of
ToggleControl
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.