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

Table Block: Refactor settings panel to use ToolsPanel #67896

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading