Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RNMobile] Tiled Gallery Block: Aspect Ratio for Square Layout #21166

Merged

Conversation

SiobhyB
Copy link

@SiobhyB SiobhyB commented Sep 23, 2021

Gutenberg Mobile: wordpress-mobile/gutenberg-mobile#4017

This PR is one part of a wider effort to port the Jetpack Tiled Gallery block to Mobile Gutenberg. It will be merged into a feature branch, rnmobile/add/tiled-gallery-block.

For this specific PR, the purpose is to define the aspect ratio of images in the editor, so that they appear as squares.

Changes proposed in this Pull Request:

  • With this PR, the images in the Tiled Gallery block will appear as squares in the editor by default.

Brief overview of code changes proposed in this Pull Request:

Jetpack product discussion

Tiled Gallery project thread: p9ugOq-1Tb-p2

Does this pull request change what data or activity we track or use?

No, it doesn't.

Testing instructions:

  • With these branches checked out and the Gutenberg Mobile demo app running, add the Tiled Gallery block.
  • Add a few images to the block.
  • Observe the shape of the images and verify that they're squares.

A few ideas for testing:

  • Add varying numbers of images to ensure the images are squares even when there are different numbers per row.
  • Switch between portrait and landscape to check for any inconsistencies.
  • Test the core image and gallery blocks for any regressions.

Screenshots

Before After

@github-actions github-actions bot added [Block] Tiled Gallery [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Sep 23, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Sep 23, 2021

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • 🔴 Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • 🔴 Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


🔴 Action required: Please add missing changelog entries for the following projects: projects/plugins/jetpack

Use the Jetpack CLI tool to generate changelog entries by running the following command: jetpack changelog add.
Guidelines: /docs/writing-a-good-changelog-entry.md


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: December 7, 2021.
  • Scheduled code freeze: November 30, 2021.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Sep 23, 2021
@SiobhyB SiobhyB added the [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack label Sep 26, 2021
Siobhan added 6 commits September 27, 2021 11:15
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.
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.
"imageCrop" and "hideImageCaption" don't need to be set as props.
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.
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.
@SiobhyB SiobhyB requested review from guarani and illusaen September 27, 2021 22:17
@SiobhyB SiobhyB marked this pull request as ready for review September 27, 2021 22:17
@SiobhyB SiobhyB changed the title [RNMobile] Tiled Gallery Block: Aspect Ratio [RNMobile] Tiled Gallery Block: Aspect Ratio for Square Layout Sep 28, 2021
Comment on lines 133 to 136
hideImageCaption: {
type: 'boolean',
default: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is shared between native and web so hideImageCaption is being added as a new block attribute on both platforms. Do you think we should copy this file into a new index.native.js and only add this attribute there?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a good idea, I've gone ahead to create a native-specific file in 128667a, let me know if anything looks off with that to you.

Copy link
Contributor

@guarani guarani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments, we might need to make an index.native.js file to avoid impacting the web, but overall the approach is solid and I learned about these block contexts 🙇‍♂️

Siobhan added 3 commits October 4, 2021 10:32
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.
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.
@SiobhyB
Copy link
Author

SiobhyB commented Oct 4, 2021

Thank you for taking a first pass @guarani 🙇‍♀️

I've gone ahead to add the mobile-specific file in 128667a.

As we've chatted about, too, I've also removed the hideImageCaption context from this PR, so that the focus is solely on the aspect ratio of the images. I'll create a separate PR for the introduction of other contexts, like hideImageCaption.

@SiobhyB SiobhyB requested a review from guarani October 5, 2021 09:29
Siobhan added 2 commits October 28, 2021 16:39
The removal of the image's caption goes beyond the scope of this specific PR, so its removal is reverted with this PR.
@SiobhyB
Copy link
Author

SiobhyB commented Oct 28, 2021

@guarani, this PR is ready for review again whenever you have the chance. Thanks in advance! 🙇‍♀️

@guarani
Copy link
Contributor

guarani commented Oct 28, 2021

This PR is one part of a wider effort to port the Jetpack Tiled Gallery block to Mobile Gutenberg. It will be merged into a feature branch, for which the main PR can be found at #20831.

I just realized that #20831 should actually be closed since its changes have already been merged to the feature branch, so I closed it now.

Copy link
Contributor

@guarani guarani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this on iOS and Android and it looks perfect 💯. I've held off approving so I can get clarification on whether a single index file would still be preferable, but apart from that this is ready to approve.

@guarani
Copy link
Contributor

guarani commented Oct 28, 2021

@SiobhyB, I think the three failing PR checks are not an issue. The failing changelog check can be ignored because we're merging to a feature branch, the failing wpcom check is not an issue for the same reason. The failing PHP test could be flaky, but I don't think it's required.

Siobhan added 2 commits October 29, 2021 14:51
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.
As the layout constant doesn't currently have any values other than "squared", it's removed with this commit.
@SiobhyB
Copy link
Author

SiobhyB commented Oct 29, 2021

@guarani, thanks for your review! I've addressed all your comments and updated the PR description 🙇‍♀️

@guarani guarani self-requested a review October 29, 2021 14:16
Copy link
Contributor

@guarani guarani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 👍 Thanks @SiobhyB!

@SiobhyB SiobhyB merged commit b11a395 into rnmobile/add/tiled-gallery-block Nov 2, 2021
@SiobhyB SiobhyB deleted the rnmobile/add/squared-aspect-ratio branch November 2, 2021 14:49
@github-actions github-actions bot removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Tiled Gallery [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Touches WP.com Files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants