Skip to content

Commit

Permalink
[RNMobile] Tiled Gallery Block: Aspect Ratio for Square Layout (#21166)
Browse files Browse the repository at this point in the history
* Pass 'squared' class back to image for styling

* Crop images in Tiled Gallery by default

By adding an "imageCrop" and setting it to true, images in the Tiled Gallery will now appear cropped by default. This is important so that images don't appear unusually distorted when their shape is changed to be square.

* Hide image block's caption component

As the image block's caption component is not a part of the Tiled Gallery block's design, it's hidden with this commit. This is done by adding an "hideImageCaption" context and setting it to true. This is passed back to the image block, which is set to hide the component when this context is detected.

* Remove uncessary code

"imageCrop" and "hideImageCaption" don't need to be set as props.

* Set aspect ratio of images so that they are squares

With this commit, the image's aspect ratio is being set in Jetpack's CSS files. It was previously set in Gutenberg's files, but this wasn't inline with our guidelines for Jetpack code appearing in the open source project.

* Remove caption, as it's unused

* Fix reference to CSS class

The previous version of this code wasn't working as expected, as it included quotation marks. With this commit, the issue is fixed and the reference to the CSS class now works as expected.

* Remove 'hideImageCaption' context from PR's scope

In order to limit the PR's scope to the square aspect ratio, this commit removes the 'hideImageCaption'. New contexts for hiding the image block's caption and settings will be moved to #21278.

* Create native-specific index file to avoid impact to web

* Remove unused contexts from web-only index file

As a native-specific index file was introdued in 128667a, we no longer need to include contexts in the web-only index file, as they're only used with the apps.

* Revert unecessary code removal

The removal of the image's caption goes beyond the scope of this specific PR, so its removal is reverted with this PR.

* Combine native-specific file into shared file

As discussed here, there isn't currently a compelling need to keep the changes to the index file in a native-specific file: #21166 (comment)

This change therefore reverts the use of a native-specific file, combining its changes into the shared index file.

* Remove layout constant, for clarity

As the layout constant doesn't currently have any values other than "squared", it's removed with this commit.
  • Loading branch information
Siobhan Bamber authored Nov 2, 2021
1 parent 4ba035f commit b11a395
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const TiledGalleryEdit = props => {
url: image.url,
caption: image.caption,
alt: image.alt,
className: styles[ 'is-style-squared' ],
} );
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ const blockAttributes = {
},
},
},
imageCrop: {
type: 'boolean',
default: true,
},
linkTo: {
default: 'none',
type: 'string',
Expand Down Expand Up @@ -292,6 +296,9 @@ export const settings = {
},
edit,
save,
providesContext: {
imageCrop: 'imageCrop',
},
deprecated,
example: {
attributes: exampleAttributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
.horizontalBorderDark {
border-color: $gray-70;
}

.is-style-squared {
aspect-ratio: 1;
}

0 comments on commit b11a395

Please sign in to comment.