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

Add margin-bottom lint rules for ToggleControl #64213

Merged
merged 13 commits into from
Aug 6, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default function ImageSettingsPanel( {
panelId={ panelId }
>
<ToggleControl
__nextHasNoMarginBottom
Copy link
Member Author

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 Blocks ▸ Image.

Global Styles Image block

label={ __( 'Expand on click' ) }
checked={ lightboxChecked }
onChange={ onChangeLightbox }
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/hooks/block-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ function BlockHooksControlPure( {

return (
<ToggleControl
__nextHasNoMarginBottom
Copy link
Member Author

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 );
ToggleControls in Content block inspector

checked={ checked }
key={ block.title }
label={
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/avatar/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const AvatarInspectorControls = ( {
/>
{ attributes.isLink && (
<ToggleControl
__nextHasNoMarginBottom
Copy link
Member Author

Choose a reason for hiding this comment

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

Testing instruction

In the editor, add an Avatar block. In the block inspector, enable the "Link to user profile" toggle.

Avatar block inspector

label={ __( 'Open in new tab' ) }
onChange={ ( value ) =>
setAttributes( {
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/details/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function DetailsEdit( { attributes, setAttributes, clientId } ) {
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
Copy link
Member Author

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 Details block and see the block inspector.

Details block inspector

label={ __( 'Open by default' ) }
checked={ showContent }
onChange={ () =>
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
<InspectorControls>
<PanelBody title={ __( 'Post content' ) }>
<ToggleControl
__nextHasNoMarginBottom
Copy link
Member Author

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 Latest Posts block and see the block inspector.

Latest Posts block inspector

label={ __( 'Post content' ) }
checked={ displayPostContent }
onChange={ ( value ) =>
Expand Down
Loading