Skip to content

Commit

Permalink
Button block: Use empty initial border radius value
Browse files Browse the repository at this point in the history
  • Loading branch information
stokesman committed Feb 23, 2021
1 parent 26560b6 commit 7537b6b
Showing 1 changed file with 13 additions and 32 deletions.
45 changes: 13 additions & 32 deletions packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,9 @@ import getColorAndStyleProps from './color-props';
const NEW_TAB_REL = 'noreferrer noopener';
const MIN_BORDER_RADIUS_VALUE = 0;
const MAX_BORDER_RADIUS_VALUE = 50;
const INITIAL_BORDER_RADIUS_POSITION = 5;

const EMPTY_ARRAY = [];

function BorderPanel( { borderRadius = '', setAttributes } ) {
const initialBorderRadius = borderRadius;
const setBorderRadius = useCallback(
( newBorderRadius ) => {
if ( newBorderRadius === undefined )
setAttributes( {
borderRadius: initialBorderRadius,
} );
else setAttributes( { borderRadius: newBorderRadius } );
},
[ setAttributes ]
);
return (
<PanelBody title={ __( 'Border settings' ) }>
<RangeControl
value={ borderRadius }
label={ __( 'Border radius' ) }
min={ MIN_BORDER_RADIUS_VALUE }
max={ MAX_BORDER_RADIUS_VALUE }
initialPosition={ INITIAL_BORDER_RADIUS_POSITION }
allowReset
onChange={ setBorderRadius }
/>
</PanelBody>
);
}

function WidthPanel( { selectedWidth, setAttributes } ) {
function handleChange( newWidth ) {
// Check if we are toggling the width off
Expand Down Expand Up @@ -282,10 +254,19 @@ function ButtonEdit( props ) {
anchorRef={ blockProps.ref }
/>
<InspectorControls>
<BorderPanel
borderRadius={ borderRadius }
setAttributes={ setAttributes }
/>
<PanelBody title={ __( 'Border settings' ) }>
<RangeControl
value={ borderRadius }
label={ __( 'Border radius' ) }
min={ MIN_BORDER_RADIUS_VALUE }
max={ MAX_BORDER_RADIUS_VALUE }
initialPosition=""
allowReset
onChange={ ( radius ) =>
setAttributes( { borderRadius: radius } )
}
/>
</PanelBody>
<WidthPanel
selectedWidth={ width }
setAttributes={ setAttributes }
Expand Down

0 comments on commit 7537b6b

Please sign in to comment.