Skip to content

Commit

Permalink
Unify vertical/horizontal min sizes back into one variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Mar 21, 2022
1 parent e8000d4 commit 6ae3da6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
16 changes: 3 additions & 13 deletions packages/block-library/src/spacer/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,9 @@ import { useInstanceId } from '@wordpress/compose';
/**
* Internal dependencies
*/
import { MIN_SPACER_WIDTH, MIN_SPACER_HEIGHT } from './edit';
import { MIN_SPACER_SIZE } from './edit';

function DimensionInput( {
label,
onChange,
isResizing,
value = '',
min,
max,
} ) {
function DimensionInput( { label, onChange, isResizing, value = '' } ) {
const inputId = useInstanceId( UnitControl, 'block-spacer-height-input' );

// In most contexts the spacer size cannot meaningfully be set to a
Expand Down Expand Up @@ -63,8 +56,7 @@ function DimensionInput( {
<UnitControl
id={ inputId }
isResetValueOnUnitChange
min={ min }
max={ max }
min={ MIN_SPACER_SIZE }
onChange={ handleOnChange }
style={ { maxWidth: 80 } }
value={ computedValue }
Expand Down Expand Up @@ -92,7 +84,6 @@ export default function SpacerControls( {
setAttributes( { width: nextWidth } )
}
isResizing={ isResizing }
min={ MIN_SPACER_WIDTH }
/>
) }
{ orientation !== 'horizontal' && (
Expand All @@ -103,7 +94,6 @@ export default function SpacerControls( {
setAttributes( { height: nextHeight } )
}
isResizing={ isResizing }
min={ MIN_SPACER_HEIGHT }
/>
) }
</PanelBody>
Expand Down
8 changes: 2 additions & 6 deletions packages/block-library/src/spacer/controls.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { MIN_SPACER_WIDTH, MIN_SPACER_HEIGHT } from './edit';
import { MIN_SPACER_SIZE } from './edit';
import styles from './style.scss';

const DEFAULT_VALUES = { px: 100, em: 10, rem: 10, vw: 10, vh: 25 };
Expand Down Expand Up @@ -67,11 +67,7 @@ function Controls( { attributes, context, setAttributes } ) {
<PanelBody title={ __( 'Dimensions' ) }>
<UnitControl
label={ label }
min={
orientation === 'horizontal'
? MIN_SPACER_WIDTH
: MIN_SPACER_HEIGHT
}
min={ MIN_SPACER_SIZE }
value={ value }
onChange={ handleChange }
onUnitChange={ handleUnitChange }
Expand Down
7 changes: 3 additions & 4 deletions packages/block-library/src/spacer/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { View } from '@wordpress/primitives';
*/
import SpacerControls from './controls';

export const MIN_SPACER_WIDTH = 0;
export const MIN_SPACER_HEIGHT = 0;
export const MIN_SPACER_SIZE = 0;

const ResizableSpacer = ( {
orientation,
Expand Down Expand Up @@ -119,7 +118,7 @@ const SpacerEdit = ( {
if ( blockOrientation === 'horizontal' ) {
return (
<ResizableSpacer
minWidth={ MIN_SPACER_WIDTH }
minWidth={ MIN_SPACER_SIZE }
enable={ {
top: false,
right: true,
Expand All @@ -144,7 +143,7 @@ const SpacerEdit = ( {
return (
<>
<ResizableSpacer
minHeight={ MIN_SPACER_HEIGHT }
minHeight={ MIN_SPACER_SIZE }
enable={ {
top: false,
right: false,
Expand Down

0 comments on commit 6ae3da6

Please sign in to comment.