Skip to content

Commit

Permalink
Removing block gap control for global styles since: (#39601)
Browse files Browse the repository at this point in the history
1. It's not supported at the root level in ROOT_BLOCK_SUPPORTS
2. It doesn't work at the individual block level in global styles
  • Loading branch information
ramonjd authored Mar 21, 2022
1 parent b243dc9 commit dcad2b4
Showing 1 changed file with 1 addition and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
__experimentalBoxControl as BoxControl,
__experimentalUnitControl as UnitControl,
__experimentalUseCustomUnits as useCustomUnits,
} from '@wordpress/components';
import { __experimentalUseCustomSides as useCustomSides } from '@wordpress/block-editor';
Expand All @@ -21,9 +20,8 @@ const AXIAL_SIDES = [ 'horizontal', 'vertical' ];
export function useHasDimensionsPanel( name ) {
const hasPadding = useHasPadding( name );
const hasMargin = useHasMargin( name );
const hasGap = useHasGap( name );

return hasPadding || hasMargin || hasGap;
return hasPadding || hasMargin;
}

function useHasPadding( name ) {
Expand All @@ -40,13 +38,6 @@ function useHasMargin( name ) {
return settings && supports.includes( 'margin' );
}

function useHasGap( name ) {
const supports = getSupportedGlobalStylesPanels( name );
const [ settings ] = useSetting( 'spacing.blockGap', name );

return settings && supports.includes( '--wp--style--block-gap' );
}

function filterValuesBySides( values, sides ) {
if ( ! sides ) {
// If no custom side configuration all sides are opted into by default.
Expand Down Expand Up @@ -88,7 +79,6 @@ function splitStyleValue( value ) {
export default function DimensionsPanel( { name } ) {
const showPaddingControl = useHasPadding( name );
const showMarginControl = useHasMargin( name );
const showGapControl = useHasGap( name );
const units = useCustomUnits( {
availableUnits: useSetting( 'spacing.units', name )[ 0 ] || [
'%',
Expand Down Expand Up @@ -128,15 +118,9 @@ export default function DimensionsPanel( { name } ) {
const resetMarginValue = () => setMarginValues( {} );
const hasMarginValue = () =>
!! marginValues && Object.keys( marginValues ).length;

const [ gapValue, setGapValue ] = useStyle( 'spacing.blockGap', name );
const resetGapValue = () => setGapValue( undefined );
const hasGapValue = () => !! gapValue;

const resetAll = () => {
resetPaddingValue();
resetMarginValue();
resetGapValue();
};

return (
Expand Down Expand Up @@ -177,23 +161,6 @@ export default function DimensionsPanel( { name } ) {
/>
</ToolsPanelItem>
) }
{ showGapControl && (
<ToolsPanelItem
hasValue={ hasGapValue }
label={ __( 'Block spacing' ) }
onDeselect={ resetGapValue }
isShownByDefault={ true }
>
<UnitControl
label={ __( 'Block spacing' ) }
__unstableInputWidth="80px"
min={ 0 }
onChange={ setGapValue }
units={ units }
value={ gapValue }
/>
</ToolsPanelItem>
) }
</ToolsPanel>
);
}

0 comments on commit dcad2b4

Please sign in to comment.