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] Remove non-Square layout code from Tiled Gallery mobile feature branch #22320

Closed
wants to merge 34 commits into from

Conversation

guarani
Copy link
Contributor

@guarani guarani commented Jan 12, 2022

Changes proposed in this Pull Request:

  • The project's Phase 1B is scoped to only include the Tiled Gallery's Square layout. This PR removes code associated with the block's other layouts.

Jetpack product discussion

p9ugOq-1Tb-p2

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

No, it does not.

Testing instructions:

Verify that the Square layout works on mobile and that other layouts are not available.

Setup to test from the main apps

  1. Run the packager from the add/tiled-gallery-block branch: npm run start:reset
  2. Run either of the main apps (WPiOS or WPAndroid)
  3. Open a new post in the main apps and expect the editor to load from the running packager
  1. Launch the iOS app
  2. Add the Tiled Gallery block
  3. Add images to it
  4. Preview the post
  5. Expect the layout to match that of the web's Tiled Gallery Square layout
  6. Repeat steps 1 to 5 on the Android app

guarani and others added 30 commits September 14, 2021 13:35
* Register the block: minimum changes needed for Tiled Gallery to show up and cause no errors
* Create a native version of .scss files to avoid bringing in the block's web-specific styles
* Add native variant of Tiled Gallery edit: needed because web variant uses DropZone component that is not applicable to native at the moment and generates a warning

Co-authored-by: Wendy Chen <wendy.chen@automattic.com>
…1135)

* The native mobile version of the Jetpack Tiled Gallery will use inner Image blocks, similar to how the `core/gallery` block now uses inner blocks

Co-authored-by: Wendy Chen <wendy.chen@automattic.com>
Add BottomSheet settings

Co-authored-by: Wendy Chen <wendy.chen@automattic.com>
Co-authored-by: Paul Von Schrottky <paul.von.schrottky@automattic.com>
…1466)

* Setting up columns and linkto/rounded corners to sync with the settings selected from bottom sheet.

* Adding changelog file.

* Delete tiled-gallery-columns

Removing changelog since we're merging to a feature branch.

* Update settings.native.js

Changing max columns to 8 to be in line with mobile gallery block.

Co-authored-by: Wendy Chen <wendy.chen@automattic.com>
* [not verified] WIP implementation of save.

* [not verified] WIP: Got block attributes to show up in serialization

* [not verified] Make columnWidths nested array

* [not verified] WIP: Now converts serialized HTML images to inner blocks on load if they weren't already in store.

* [not verified] WIP load from save. Hacked in stuff to make it work. Need to find root cause.

* Adding Platform checks to ensure that mobile changes don't affect web. Fixing some lint warnings.

Co-authored-by: Wendy Chen <wendy.chen@automattic.com>
Co-authored-by: Paul Von Schrottky <paul.von.schrottky@automattic.com>
* Register the block: minimum changes needed for Tiled Gallery to show up and cause no errors
* Create a native version of .scss files to avoid bringing in the block's web-specific styles
* Add native variant of Tiled Gallery edit: needed because web variant uses DropZone component that is not applicable to native at the moment and generates a warning

Co-authored-by: Wendy Chen <wendy.chen@automattic.com>
…1135)

* The native mobile version of the Jetpack Tiled Gallery will use inner Image blocks, similar to how the `core/gallery` block now uses inner blocks

Co-authored-by: Wendy Chen <wendy.chen@automattic.com>
Add BottomSheet settings

Co-authored-by: Wendy Chen <wendy.chen@automattic.com>
Co-authored-by: Paul Von Schrottky <paul.von.schrottky@automattic.com>
…1466)

* Setting up columns and linkto/rounded corners to sync with the settings selected from bottom sheet.

* Adding changelog file.

* Delete tiled-gallery-columns

Removing changelog since we're merging to a feature branch.

* Update settings.native.js

Changing max columns to 8 to be in line with mobile gallery block.

Co-authored-by: Wendy Chen <wendy.chen@automattic.com>
* [not verified] WIP implementation of save.

* [not verified] WIP: Got block attributes to show up in serialization

* [not verified] Make columnWidths nested array

* [not verified] WIP: Now converts serialized HTML images to inner blocks on load if they weren't already in store.

* [not verified] WIP load from save. Hacked in stuff to make it work. Need to find root cause.

* Adding Platform checks to ensure that mobile changes don't affect web. Fixing some lint warnings.

Co-authored-by: Wendy Chen <wendy.chen@automattic.com>
Co-authored-by: Paul Von Schrottky <paul.von.schrottky@automattic.com>
…tic/jetpack into rnmobile/add/tiled-gallery-block
Co-authored-by: Wendy Chen <wendy.chen@automattic.com>
* 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.
With this PR, the placeholder text is changed from "ADD IMAGE" to "ADD MEDIA". This is to bring consistency with the text that's seen in other, similar blocks, such as the Gallery and Story blocks.
Formerly `__experimentalUseInnerBlocksProps`, the API has now become `useInnerBlocksProps` so we update usage.
The Tiled Gallery's icon color is not the same as other blocks. By removing 'fill="currentColor"' in this PR, the block icon will go back to the general default color that's used for all block icons, thus restoring consistency.
…bile serialized HTML can match. (#21643)

Co-authored-by: Wendy Chen <wendy.chen@automattic.com>
* Add basic layout picker to Tiled Gallery in settings sub-sheet
This PR leverages the `__experimentalHideChildBlockControls` block supports introduced in WordPress/gutenberg#36371 to hide the settings tab for the inner image blocks.
…21884)

For the current phase of the Tiled Gallery block, we won't be shipping the block with "link to" settings. As such, this PR removes all references to those settings.
This PR includes the following functionality related to columns in the Tiled Gallery block:

* Allows users to set the columns to either the number of images in the gallery (up to the web's max value of 20).
* The number of columns displayed within the editor itself is set to a max of four for landscape and two for portrait.
* The columns resize depending on whether they're in portrait or landscape mode.
Removes a hard-coded dimension in the Tiled Gallery save function that was put there while iterating on the development of the block.
@github-actions github-actions bot added [Block] Tiled Gallery [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Jan 12, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2022

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.


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: February 1, 2022.
  • Scheduled code freeze: January 24, 2022.

@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 Jan 12, 2022
@guarani guarani changed the title Rnmobile/fix/tiled gallery [RNMobile] Remove non-Square layout code from Tiled Gallery mobile feature branch Jan 12, 2022
@SiobhyB SiobhyB self-requested a review January 12, 2022 16:11
name: LAYOUT_DEFAULT,
},
{
name: LAYOUT_CIRCLE,
},
{
isDefault: Platform.OS === 'native',
Copy link
Contributor

Choose a reason for hiding this comment

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

@guarani, I came across an issue when testing this across web/native. If you create a gallery on native, it's correctly set to the square layout, but this is undone if you open the editor in a web browser:

  1. Create a gallery in the app and confirm it's correctly set to the square layout.
  2. Save the post and then reopen its editor in a web browser.
  3. See how the gallery automatically converts to the tiled mosaic layout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is related to an issue I'm seeing where the className is not set in the block's serialized representation on mobile. The image below shows web

Web (includes className) Mobile (missing className)
Screen Shot 2022-01-12 at 21 39 18 Screen Shot 2022-01-12 at 21 41 04

Copy link
Contributor

@SiobhyB SiobhyB left a comment

Choose a reason for hiding this comment

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

Thanks for creating this, Paul! I know this is still a WIP but wanted to give a heads up that, in addition to this issue, the images in the gallery no longer appear as squares when previewed with this PR checked out:

Let me know if you're unable to replicate or if I can help with anything else here.

Base automatically changed from rnmobile/add/tiled-gallery-block to master January 18, 2022 15:13
@guarani
Copy link
Contributor Author

guarani commented Jan 18, 2022

I'm closing this PR since we decided to leave other layouts in #21849.

@guarani guarani closed this Jan 18, 2022
@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 Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Tiled Gallery [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.

None yet

4 participants