Skip to content

Commit

Permalink
updates LayoutTypeSwitcher to use ToggleGroupControl (#65498)
Browse files Browse the repository at this point in the history
* updates LayoutTypeSwitcher to useToggleGroupControl

* updates label and corrects LayoutTypeSwitcher component misconfiguration

Co-authored-by: spadeshoe <spdft@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
  • Loading branch information
3 people authored Sep 30, 2024
1 parent 66bd5e2 commit 65e7db0
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions packages/block-editor/src/hooks/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { addFilter } from '@wordpress/hooks';
import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
import { useSelect } from '@wordpress/data';
import {
Button,
ButtonGroup,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
ToggleControl,
PanelBody,
privateApis as componentsPrivateApis,
Expand Down Expand Up @@ -315,21 +315,26 @@ export default {

function LayoutTypeSwitcher( { type, onChange } ) {
return (
<ButtonGroup>
<ToggleGroupControl
__next40pxDefaultSize
isBlock
label={ __( 'Layout type' ) }
__nextHasNoMarginBottom
hideLabelFromVision
isAdaptiveWidth
value={ type }
onChange={ onChange }
>
{ getLayoutTypes().map( ( { name, label } ) => {
return (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
<ToggleGroupControlOption
key={ name }
isPressed={ type === name }
onClick={ () => onChange( name ) }
>
{ label }
</Button>
value={ name }
label={ label }
/>
);
} ) }
</ButtonGroup>
</ToggleGroupControl>
);
}

Expand Down

0 comments on commit 65e7db0

Please sign in to comment.