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

Page template previews #19106

Merged
merged 19 commits into from
Jan 15, 2020
Merged

Page template previews #19106

merged 19 commits into from
Jan 15, 2020

Conversation

koke
Copy link
Contributor

@koke koke commented Dec 12, 2019

Description

This implements a first version of the template previews defined in wordpress-mobile/gutenberg-mobile#1466

After much wrestling with BottomSheet and react-native-modal, I couldn't find a good way to have a bottom sheet with a FlatList inside that scrolled properly. So, for now, I switched to react-native's standard Modal.

Once facebook/react-native#27618 lands on a release, we will be able to use the bottom-sheet style modals for iOS, but a cross platform solution will require more effort that's in scope for this feature.

This PR also includes some changes needed to BlockEditorProvider although I extracted those into #19120 for easier review.

This also introduces a "new" ModalHeaderBar component to show as a top bar for modals. The code came from an existing title bar in the BottomSheet code, but I haven't found any current examples of that being used in a bottom sheet. @iamthomasbishop this will need adjusting for dark mode, not sure what the colors should be there for the bar, title and close button.

@geriux I've also moved the template picker to the bottom on this PR because I needed it out of the block list. I was getting into trouble because the preview also has a block list and a BlockFooterSlot. I think I prefer your approach in #19307, and that one should replace this once merged.

So this is blocked on those three changes (BlockEditorPreview, dark mode, and moving the toolbar), but I'm about to take a week off and the bulk of the PR is ready for review

gutenberg-mobile PR: wordpress-mobile/gutenberg-mobile#1676

How has this been tested?

I tested this by forcing a postType=page and empty content in gutenberg-mobile src/index.js

Screenshots

spt-previews

🤔 The modal animation looks odd to me on Android, but I'm not sure what's going on there and if that's normal.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

@koke koke added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label Dec 27, 2019
@koke koke requested review from pinarol and geriux December 27, 2019 12:28
@koke koke marked this pull request as ready for review December 27, 2019 12:30
@geriux
Copy link
Member

geriux commented Dec 31, 2019

🤔 The modal animation looks odd to me on Android, but I'm not sure what's going on there and if that's normal.

The issue here is performance, the animation of the Modal is being affected by the blocks rendering. Do we use skeleton placeholders? I think this feature would benefit from it especially on slower/low-end devices. What do you think?

@geriux
Copy link
Member

geriux commented Dec 31, 2019

@geriux I've also moved the template picker to the bottom on this PR because I needed it out of the block list. I was getting into trouble because the preview also has a block list and a BlockFooterSlot. I think I prefer your approach in #19307, and that one should replace this once merged.

Sounds good!

@iamthomasbishop
Copy link

Nice to see this, @koke!

The modal animation looks odd to me on Android, but I'm not sure what's going on there and if that's normal.

That does look a bit odd. At first glance, I was going to ask if we could use the same screen transition we use on other full-screen dialogs on Android that we use elsewhere (the subtle scale as the window fades in), but it sounds like this could be at least partially due to a performance issue that Gerardo mentioned.

This also introduces a "new" ModalHeaderBar component to show as a top bar for modals.

Where is this style coming from? I can replicate this in Figma and start using it where necessary (and define usage guidelines in the design docs).

Will this header style remain in place when we start using the native style of the modal sheet on iOS, or will we inherit another style header (similar to the native NavigationBar style)?

I really would love to go to that new modal bottom sheet sooner rather than later so we can take advantage of the swipe-to-dismiss functionality of the native sheets. Android is less critical to have that considering we always have an OS-level back gesture.

One other question, out of curiosity: is it possible to substitute the X for a Close text label button on iOS to mimic the native NavigationBar?

this will need adjusting for dark mode, not sure what the colors should be there for the bar, title label, and close button.

I believe the icon and header title are both white in dark mode, but can we reference WPiOS to double-check? The background of the header should also match that of WPiOS, if possible – although I think we're using a dynamic system color so we might have to mimic the default color.

The issue here is performance, the animation of the Modal is being affected by the blocks rendering. Do we use skeleton placeholders? I think this feature would benefit from it especially on slower/low-end devices. What do you think?

@geriux I think skeleton placeholders would be nice to see universally for an initial "loading" state, and I proposed something similar recently.

@geriux
Copy link
Member

geriux commented Jan 3, 2020

@geriux I think skeleton placeholders would be nice to see universally for an initial "loading" state, and I proposed something similar recently.

Nice! Yes, that would be perfect for this case 😃

@koke
Copy link
Contributor Author

koke commented Jan 7, 2020

Happy to hear it's "just" a performance issue. I can't wait for Suspense to handle stuff like this more easily.

I generally like skeleton placeholders, but there's something odd about them for a preview like this one. Even if we are using actual blocks to render, it feels more like we are loading the preview of a web page, and I think I would expect everything to load at once. Also, for devices that are performant enough I wouldn't want to show a placeholder while the modal animation is happening if the real content can be rendered fast enough, and I'm not sure how to tell the difference without going too deep into react native.

@koke
Copy link
Contributor Author

koke commented Jan 7, 2020

Also, for reference, this is the performance when creating a new post on the device I was testing:

bugreport

@geriux
Copy link
Member

geriux commented Jan 7, 2020

I've just merged #19307 sorry for the conflicts 😅

@iamthomasbishop
Copy link

Also, for reference, this is the performance when creating a new post on the device I was testing:

@koke that is slow 😬 I do think skeletons would make it feel less cumbersome, but it won't completely mask the slowness.

@geriux
Copy link
Member

geriux commented Jan 8, 2020

Also, for reference, this is the performance when creating a new post on the device I was testing:

That's in prod mode, right? What specs does that device have? (I know it's not actually related to the PR but now I'm curious 😅)

@koke
Copy link
Contributor Author

koke commented Jan 8, 2020

That's a Moto G5 Plus 😁

@koke
Copy link
Contributor Author

koke commented Jan 8, 2020

Updated after the changes in #19307. @geriux ready for another look

@pinarol
Copy link
Contributor

pinarol commented Jan 9, 2020

Sorry for being late to test this one. I gave it a try today with WPiOS, WPAndroid. I have no blocker findings except for the dark mode and it is a known issue.

  • One thing that needs tackling is, the modal is not adjusting to landscape on iOS, it stays in Portrait mode even if I rotate the device. (looks configurable)

And on Android rotating the device can cause the editor close altogether sometimes, not every time though, and this can be considered as a edge case:

  • Open page on portrait, tap on title
  • Open template modal
  • Rotate to landscape
  • At this point the template doesn't show up anymore
  • Rotate again
  • The editor closes itself

Screen Shot 2020-01-09 at 19 51 24

the difference of bouncing during scrolling, on iOS is it bouncing but on Android it is not. Not sure if we can control this since we use a library to display modals.

iPhoneXS, iOS 13

Screen Shot 2020-01-09 at 19 51 24

Huawei P20 lite, Android 9

Screen Shot 2020-01-09 at 19 51 24

Another thing is we have an overlap on Landscape mode but I think this is normal since we stick the template pickers on keyboard.

IMG_3298

I also gave it a try on iPad simulator and things seem normal:

Screen Shot 2020-01-09 at 19 51 24

Code-wise, it looks ok to me. I'd just hope we wouldn't need to implement ModalHeaderBar but 🤷‍♂️Great job 🎉

@iamthomasbishop
Copy link

@koke I'm not sure if this is the right ticket to drop design feedback on, but I've got some feedback on the header specifically (some of which I mentioned last week) 😄 :

  • On Android (because we're using what looks like 20px font-size?) it looks like the icon isn't centered. The close icon-button should be vertically centered with the text label.

  • On Android, I think if we're mimicking the system App Bar style, the label should be set in Medium font-weight.

  • On iOS, it'd be great if we can use a text button that says Close or similar.

  • Are we going to add an Apply or Use button to the right side of the header?

  • Is it possible to also add a sub-title on the header? If so we might want to bring the title font-size down to ~16px.

Here are some exploratory mocks w/ different header variations:

image

@geriux
Copy link
Member

geriux commented Jan 10, 2020

  • Are we going to add an Apply or Use button to the right side of the header?

Yup, I have this draft PR that I will have ready for review today (don't mind the style changes you mentioned above in the draft PR because they're probably going to be updated in this one or in a new one =)

Copy link
Member

@geriux geriux left a comment

Choose a reason for hiding this comment

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

LGTM! Great job @koke ! 🎉 Approving since the styles improvements will be worked on in another PR.

Tested it on both iOS and Android ✅

];

export default defaultTemplates;
const parsedTemplates = memoize( () => defaultTemplates.map( ( template ) => ( {
Copy link
Member

Choose a reason for hiding this comment

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

This is super nice! 👌🏻

Comment on lines -19 to -31
const withRegistry = createHigherOrderComponent(
( OriginalComponent ) => ( props ) => (
<RegistryConsumer>
{ ( registry ) => (
<OriginalComponent
{ ...props }
registry={ registry }
/>
) }
</RegistryConsumer>
),
'withRegistry'
);
Copy link
Member

Choose a reason for hiding this comment

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

Nice clean up in favor of withRegistryProvider 👏

@koke
Copy link
Contributor Author

koke commented Jan 15, 2020

Created wordpress-mobile/gutenberg-mobile#1777 with the style feedback to work on a separate PR

@koke koke merged commit a7db562 into master Jan 15, 2020
@ellatrix ellatrix added this to the Gutenberg 7.3 milestone Jan 20, 2020
@aristath aristath deleted the add/spt-template-preview branch November 10, 2020 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants