From 11df1985232a54c920ac5f0bc9fc0fa9cd16426d Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Fri, 31 Mar 2023 13:58:35 +1100 Subject: [PATCH] Add consistency to control display defaults --- .../global-styles/dimensions-panel.js | 42 ++++++++++++------- .../global-styles/dimensions-panel.js | 11 +++++ 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/dimensions-panel.js b/packages/block-editor/src/components/global-styles/dimensions-panel.js index c61704396ea7f..19f9d97c02aac 100644 --- a/packages/block-editor/src/components/global-styles/dimensions-panel.js +++ b/packages/block-editor/src/components/global-styles/dimensions-panel.js @@ -183,12 +183,12 @@ 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, }; @@ -421,7 +421,10 @@ export default function DimensionsPanel( { label={ __( 'Content size' ) } hasValue={ hasUserSetContentSizeValue } onDeselect={ resetContentSizeValue } - isShownByDefault={ defaultControls.contentSize } + isShownByDefault={ + defaultControls.contentSize ?? + DEFAULT_CONTROLS.contentSize + } panelId={ panelId } > @@ -447,7 +450,9 @@ export default function DimensionsPanel( { label={ __( 'Wide size' ) } hasValue={ hasUserSetWideSizeValue } onDeselect={ resetWideSizeValue } - isShownByDefault={ defaultControls.wideSize } + isShownByDefault={ + defaultControls.wideSize ?? DEFAULT_CONTROLS.wideSize + } panelId={ panelId } > @@ -472,7 +477,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, } ) } @@ -511,7 +518,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, } ) } @@ -550,7 +559,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, } ) } @@ -596,7 +607,9 @@ export default function DimensionsPanel( { hasValue={ hasMinHeightValue } label={ __( 'Min. height' ) } onDeselect={ resetMinHeightValue } - isShownByDefault={ defaultControls.minHeight } + isShownByDefault={ + defaultControls.minHeight ?? DEFAULT_CONTROLS.minHeight + } panelId={ panelId } > diff --git a/packages/edit-site/src/components/global-styles/dimensions-panel.js b/packages/edit-site/src/components/global-styles/dimensions-panel.js index 7875591c5676f..0d43d71cec3d1 100644 --- a/packages/edit-site/src/components/global-styles/dimensions-panel.js +++ b/packages/edit-site/src/components/global-styles/dimensions-panel.js @@ -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 ) { @@ -66,6 +76,7 @@ export default function DimensionsPanel( { name, variation = '' } ) { onChange={ onChange } settings={ settings } includeLayoutControls + defaultControls={ DEFAULT_CONTROLS } /> ); }