Skip to content

Commit

Permalink
Organize gallery controls (#58407)
Browse files Browse the repository at this point in the history
* Move controls

* Remove extraneous crop help

* Append new tab control

* Adjust labels

* Fix unit tests

---------

Co-authored-by: richtabor <richtabor@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org>
Co-authored-by: SaxonF <saxonafletcher@git.wordpress.org>
  • Loading branch information
7 people authored Feb 5, 2024
1 parent 8174ba1 commit f294dd2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 34 deletions.
59 changes: 26 additions & 33 deletions packages/block-library/src/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,6 @@ function GalleryEdit( props ) {
setAttributes( { imageCrop: ! imageCrop } );
}

function getImageCropHelp( checked ) {
return checked
? __( 'Thumbnails are cropped to align.' )
: __( 'Thumbnails are not cropped.' );
}

function toggleRandomOrder() {
setAttributes( { randomOrder: ! randomOrder } );
}
Expand Down Expand Up @@ -548,50 +542,49 @@ function GalleryEdit( props ) {
__next40pxDefaultSize
/>
) }
{ imageSizeOptions?.length > 0 && (
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Resolution' ) }
help={ __(
'Select the size of the source images.'
) }
value={ sizeSlug }
options={ imageSizeOptions }
onChange={ updateImagesSize }
hideCancelButton={ true }
size="__unstable-large"
/>
) }
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Link to' ) }
value={ linkTo }
onChange={ setLinkTo }
options={ linkOptions }
hideCancelButton={ true }
size="__unstable-large"
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Crop images' ) }
label={ __( 'Crop images to fit' ) }
checked={ !! imageCrop }
onChange={ toggleImageCrop }
help={ getImageCropHelp }
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Random order' ) }
label={ __( 'Randomize order' ) }
checked={ !! randomOrder }
onChange={ toggleRandomOrder }
/>
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Link to' ) }
value={ linkTo }
onChange={ setLinkTo }
options={ linkOptions }
hideCancelButton={ true }
size="__unstable-large"
/>
{ hasLinkTo && (
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Open in new tab' ) }
label={ __( 'Open images in new tab' ) }
checked={ linkTarget === '_blank' }
onChange={ toggleOpenInNewTab }
/>
) }
{ imageSizeOptions?.length > 0 && (
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Resolution' ) }
help={ __(
'Select the size of the source images.'
) }
value={ sizeSlug }
options={ imageSizeOptions }
onChange={ updateImagesSize }
hideCancelButton={ true }
size="__unstable-large"
/>
) }
{ Platform.isWeb && ! imageSizeOptions && hasImageIds && (
<BaseControl className={ 'gallery-image-sizes' }>
<BaseControl.VisualLabel>
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/gallery/test/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ describe( 'Gallery block', () => {
await openBlockSettings( screen );

// Disable crop images setting
fireEvent.press( getByText( 'Crop images' ) );
fireEvent.press( getByText( 'Crop images to fit' ) );
expect( getEditorHtml() ).toMatchSnapshot();
} );
} );

0 comments on commit f294dd2

Please sign in to comment.