Skip to content

Commit

Permalink
Move common checks to a const
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong committed Sep 7, 2022
1 parent 3c36b50 commit ebff049
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/block-editor/src/hooks/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,10 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
return null;
}
const layoutType = getLayoutType( type );

const constrainedType = getLayoutType( 'constrained' );

const displayControlsForLegacyLayouts =
! usedLayout.type && ( contentSize || inherit );
const hasContentSizeOrLegacySettings = !! inherit || !! contentSize;

const onChangeType = ( newType ) =>
setAttributes( { layout: { type: newType } } );
Expand All @@ -164,25 +163,23 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
label={ __( 'Inner blocks use content width' ) }
checked={
layoutType?.name === 'constrained' ||
!! inherit ||
!! contentSize
hasContentSizeOrLegacySettings
}
onChange={ () =>
setAttributes( {
layout: {
type:
layoutType?.name ===
'constrained' ||
!! inherit ||
!! contentSize
hasContentSizeOrLegacySettings
? 'default'
: 'constrained',
},
} )
}
help={
!! inherit ||
layoutType?.name === 'constrained'
layoutType?.name === 'constrained' ||
hasContentSizeOrLegacySettings
? __(
'Nested blocks use content width with options for full and wide widths.'
)
Expand Down

0 comments on commit ebff049

Please sign in to comment.