Skip to content

Commit

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

Co-authored-by: Mayank-Tripathi32 <mayanktripathi32@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
  • Loading branch information
3 people authored Dec 13, 2024
1 parent d0d1045 commit 2b5da49
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions packages/block-library/src/details/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import {
InspectorControls,
} from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';
import { PanelBody, ToggleControl } from '@wordpress/components';
import {
ToggleControl,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';

const TEMPLATE = [
Expand Down Expand Up @@ -46,18 +50,36 @@ function DetailsEdit( { attributes, setAttributes, clientId } ) {
return (
<>
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
<ToolsPanel
label={ __( 'Settings' ) }
resetAll={ () => {
setAttributes( {
showContent: false,
} );
} }
>
<ToolsPanelItem
isShownByDefault
label={ __( 'Open by default' ) }
checked={ showContent }
onChange={ () =>
hasValue={ () => showContent }
onDeselect={ () => {
setAttributes( {
showContent: ! showContent,
} )
}
/>
</PanelBody>
showContent: false,
} );
} }
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Open by default' ) }
checked={ showContent }
onChange={ () =>
setAttributes( {
showContent: ! showContent,
} )
}
/>
</ToolsPanelItem>
</ToolsPanel>
</InspectorControls>
<details
{ ...innerBlocksProps }
Expand Down

0 comments on commit 2b5da49

Please sign in to comment.