Skip to content

Commit

Permalink
Refactor "Settings" panel of Table block to use ToolsPanel instead of…
Browse files Browse the repository at this point in the history
… PanelBody (#67896)

Co-authored-by: Sukhendu2002 <sukhendu2002@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent cff73d4 commit 8d6b8c5
Showing 1 changed file with 54 additions and 20 deletions.
74 changes: 54 additions & 20 deletions packages/block-library/src/table/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import {
import { __ } from '@wordpress/i18n';
import {
Button,
PanelBody,
Placeholder,
TextControl,
ToggleControl,
ToolbarDropdownMenu,
__experimentalHasSplitBorders as hasSplitBorders,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
import {
alignLeft,
Expand Down Expand Up @@ -473,33 +474,66 @@ function TableEdit( {
</>
) }
<InspectorControls>
<PanelBody
title={ __( 'Settings' ) }
className="blocks-table-settings"
<ToolsPanel
label={ __( 'Settings' ) }
resetAll={ () => {
setAttributes( {
hasFixedLayout: true,
head: [],
foot: [],
} );
} }
>
<ToggleControl
__nextHasNoMarginBottom
<ToolsPanelItem
hasValue={ () => hasFixedLayout !== true }
label={ __( 'Fixed width table cells' ) }
checked={ !! hasFixedLayout }
onChange={ onChangeFixedLayout }
/>
onDeselect={ () =>
setAttributes( { hasFixedLayout: true } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Fixed width table cells' ) }
checked={ !! hasFixedLayout }
onChange={ onChangeFixedLayout }
/>
</ToolsPanelItem>
{ ! isEmpty && (
<>
<ToggleControl
__nextHasNoMarginBottom
<ToolsPanelItem
hasValue={ () => head && head.length }
label={ __( 'Header section' ) }
checked={ !! ( head && head.length ) }
onChange={ onToggleHeaderSection }
/>
<ToggleControl
__nextHasNoMarginBottom
onDeselect={ () =>
setAttributes( { head: [] } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Header section' ) }
checked={ !! ( head && head.length ) }
onChange={ onToggleHeaderSection }
/>
</ToolsPanelItem>
<ToolsPanelItem
hasValue={ () => foot && foot.length }
label={ __( 'Footer section' ) }
checked={ !! ( foot && foot.length ) }
onChange={ onToggleFooterSection }
/>
onDeselect={ () =>
setAttributes( { foot: [] } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Footer section' ) }
checked={ !! ( foot && foot.length ) }
onChange={ onToggleFooterSection }
/>
</ToolsPanelItem>
</>
) }
</PanelBody>
</ToolsPanel>
</InspectorControls>
{ ! isEmpty && (
<table
Expand Down

1 comment on commit 8d6b8c5

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 8d6b8c5.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12306025679
📝 Reported issues:

Please sign in to comment.