Skip to content

Commit

Permalink
Show child layout controls by default (#49389)
Browse files Browse the repository at this point in the history
* Show child layout controls by default

* Add consistency to control display defaults
  • Loading branch information
tellthemachines authored Mar 31, 2023
1 parent 195c68e commit a1f2679
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,13 @@ function DimensionsToolsPanel( {
}

const DEFAULT_CONTROLS = {
contentSize: true,
wideSize: true,
padding: true,
margin: true,
blockGap: true,
minHeight: true,
contentSize: false,
wideSize: false,
padding: false,
margin: false,
blockGap: false,
minHeight: false,
childLayout: true,
};

export default function DimensionsPanel( {
Expand Down Expand Up @@ -391,7 +392,10 @@ export default function DimensionsPanel( {
label={ __( 'Content size' ) }
hasValue={ hasUserSetContentSizeValue }
onDeselect={ resetContentSizeValue }
isShownByDefault={ defaultControls.contentSize }
isShownByDefault={
defaultControls.contentSize ??
DEFAULT_CONTROLS.contentSize
}
panelId={ panelId }
>
<HStack alignment="flex-end" justify="flex-start">
Expand All @@ -417,7 +421,9 @@ export default function DimensionsPanel( {
label={ __( 'Wide size' ) }
hasValue={ hasUserSetWideSizeValue }
onDeselect={ resetWideSizeValue }
isShownByDefault={ defaultControls.wideSize }
isShownByDefault={
defaultControls.wideSize ?? DEFAULT_CONTROLS.wideSize
}
panelId={ panelId }
>
<HStack alignment="flex-end" justify="flex-start">
Expand All @@ -442,7 +448,9 @@ export default function DimensionsPanel( {
hasValue={ hasPaddingValue }
label={ __( 'Padding' ) }
onDeselect={ resetPaddingValue }
isShownByDefault={ defaultControls.padding }
isShownByDefault={
defaultControls.padding ?? DEFAULT_CONTROLS.padding
}
className={ classnames( {
'tools-panel-item-spacing': showSpacingPresetsControl,
} ) }
Expand Down Expand Up @@ -481,7 +489,9 @@ export default function DimensionsPanel( {
hasValue={ hasMarginValue }
label={ __( 'Margin' ) }
onDeselect={ resetMarginValue }
isShownByDefault={ defaultControls.margin }
isShownByDefault={
defaultControls.margin ?? DEFAULT_CONTROLS.margin
}
className={ classnames( {
'tools-panel-item-spacing': showSpacingPresetsControl,
} ) }
Expand Down Expand Up @@ -520,7 +530,9 @@ export default function DimensionsPanel( {
hasValue={ hasGapValue }
label={ __( 'Block spacing' ) }
onDeselect={ resetGapValue }
isShownByDefault={ defaultControls.blockGap }
isShownByDefault={
defaultControls.blockGap ?? DEFAULT_CONTROLS.blockGap
}
className={ classnames( {
'tools-panel-item-spacing': showSpacingPresetsControl,
} ) }
Expand Down Expand Up @@ -566,7 +578,9 @@ export default function DimensionsPanel( {
hasValue={ hasMinHeightValue }
label={ __( 'Min. height' ) }
onDeselect={ resetMinHeightValue }
isShownByDefault={ defaultControls.minHeight }
isShownByDefault={
defaultControls.minHeight ?? DEFAULT_CONTROLS.minHeight
}
panelId={ panelId }
>
<HeightControl
Expand All @@ -583,7 +597,10 @@ export default function DimensionsPanel( {
hasValue={ hasChildLayoutValue }
label={ childLayoutOrientationLabel }
onDeselect={ resetChildLayoutValue }
isShownByDefault={ defaultControls.childLayout }
isShownByDefault={
defaultControls.childLayout ??
DEFAULT_CONTROLS.childLayout
}
panelId={ panelId }
>
<ChildLayoutControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ const {
DimensionsPanel: StylesDimensionsPanel,
} = unlock( blockEditorPrivateApis );

const DEFAULT_CONTROLS = {
contentSize: true,
wideSize: true,
padding: true,
margin: true,
blockGap: true,
minHeight: true,
childLayout: false,
};

export default function DimensionsPanel( { name, variation = '' } ) {
let prefixParts = [];
if ( variation ) {
Expand Down Expand Up @@ -66,6 +76,7 @@ export default function DimensionsPanel( { name, variation = '' } ) {
onChange={ onChange }
settings={ settings }
includeLayoutControls
defaultControls={ DEFAULT_CONTROLS }
/>
);
}

0 comments on commit a1f2679

Please sign in to comment.