Skip to content

Commit

Permalink
Add gridGap unit control to native mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong committed Jun 2, 2021
1 parent 33333e0 commit 18fd3d2
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion packages/block-library/src/columns/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function ColumnsEditContainer( {
isSelected,
onDeleteBlock,
innerWidths,
setAttributes,
updateInnerColumnWidth,
editorSidebarOpened,
} ) {
Expand All @@ -103,7 +104,12 @@ function ColumnsEditContainer( {
const screenWidth = Math.floor( Dimensions.get( 'window' ).width );
const globalStyles = useContext( GlobalStylesContext );

const { verticalAlignment, align } = attributes;
const {
verticalAlignment,
align,
gridGap,
gridGapUnit = 'em',
} = attributes;
const { width } = sizes || {};

const units = useCustomUnits( {
Expand Down Expand Up @@ -189,6 +195,14 @@ function ColumnsEditContainer( {
onChangeWidth( nextWidth, valueUnit, columnId );
};

const onGridGapChange = ( value ) => {
setAttributes( { gridGap: value } );
};

const onGridGapUnitChange = ( value ) => {
setAttributes( { gridGapUnit: value } );
};

const getColumnsSliders = useMemo( () => {
if ( ! editorSidebarOpened || ! isSelected ) {
return null;
Expand Down Expand Up @@ -257,6 +271,17 @@ function ColumnsEditContainer( {
type="stepper"
/>
{ getColumnsSliders }
<UnitControl
label={ __( 'Gap' ) }
min={ 0 }
max={ 30 }
unit={ gridGapUnit }
value={ gridGap }
onChange={ onGridGapChange }
onUnitChange={ onGridGapUnitChange }
units={ units }
key={ gridGapUnit }
/>
</PanelBody>
<PanelBody>
<FooterMessageControl
Expand Down

0 comments on commit 18fd3d2

Please sign in to comment.