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

How can I preview AMP pages in Gutenberg? #2934

Closed
TwisterMc opened this issue Aug 2, 2019 · 23 comments · Fixed by #3323
Closed

How can I preview AMP pages in Gutenberg? #2934

TwisterMc opened this issue Aug 2, 2019 · 23 comments · Fixed by #3323
Labels
Enhancement New feature or improvement of an existing one Integration: Gutenberg QA passed Has passed QA and is done
Milestone

Comments

@TwisterMc
Copy link

In the classic editor, next to the preview button was an AMP icon which allowed a user to preview the AMP page. In Gutenberg this button doesn't show and there doesn't seem to be a way to preview AMP pages in Gutenberg.

Is there a button someplace that I just don't see? Or is it not available in Gutenberg?

I do know I can just add &amp=1 to the preview URL, but that's not client friendly. They like buttons. :)

@swissspidy swissspidy added Integration: Gutenberg Enhancement New feature or improvement of an existing one labels Aug 2, 2019
@swissspidy
Copy link
Collaborator

I don't think we currently add an AMP Preview button in Gutenberg. But I suppose we should :-)

@westonruter
Copy link
Member

Yeah, the classic editor has a preview button for AMP in Transitional and Reader modes (IIRC). We didn't add it to Gutenberg because... we probably didn't know how.

@TwisterMc
Copy link
Author

Love the honesty. What about adding a text link below the Enable AMP toggle that says Preview AMP Post? It doesn't have to be next to the preview button.

@swissspidy
Copy link
Collaborator

For comparison, here's the preview button in the classic editor:

Screenshot 2019-08-05 at 13 00 06

And here is the same section in the block editor:

Screenshot 2019-08-05 at 13 02 20

Since the preview button in the block editor could only be modified using direct DOM manipulation or perhaps by overriding wp.editor.PostPreviewButton. Both options would be prone to breakage when new versions.

So using the same PluginPostStatusInfo slot as we already do for the AMP toggle makes most sense to me.

I think that is a reasonably small enhancement to include in the next release. It might mean duplicating larges parts of the PostPreviewButton component though.

@TwisterMc
Copy link
Author

This is what I was thinking.

Screen Shot 2019-08-28 at 8 47 04 AM

I don't think this would require us to worry about the PostPreviewButton component.

@swissspidy
Copy link
Collaborator

Right, that's my suggested location as well. Needs lots of the logic from PostPreviewButton either way though in order to get the correct preview link, saveable status, to open the preview window etc. Otherwise the preview might not be accurate.

This is currently in the backlog, so we will get to it at some point.

@westonruter
Copy link
Member

If possible to integrate with the existing Preview button, that'd be great, otherwise having a separate AMP preview button makes sense.

@cathibosco
Copy link

For consideration - Options 2 & 3 are improved UX/UI due to label "preview" being duplicated in option 1 - check it out for feasibility.
2934--AMP-Preview

@schlessera
Copy link
Collaborator

I think Option 2 is the nicest. The question is whether we can reliably decorate the existing Preview button here.

@cathibosco
Copy link

Agreed - yes that would be optimal.

@TwisterMc
Copy link
Author

I concur; as long as the effort is not a lot more.

@schlessera schlessera removed their assignment Sep 17, 2019
@kienstra
Copy link
Contributor

Hi @schlessera,
Hope you had a great Friday.

Would you mind if I worked on this?

@schlessera
Copy link
Collaborator

@kienstra No, not at all. I saw you were already looking into it, so I skipped it and went to the first item in the back log already.

@kienstra
Copy link
Contributor

OK, thanks! Have a great weekend!

@kienstra
Copy link
Contributor

kienstra commented Sep 23, 2019

Update: please ignore these, as this has changed.

Testing Steps
For when #3323 passes review

  1. Select 'Transitional' mode
  2. Create a new post
  3. Enter any title
  4. Expected: as long as AMP is enabled, there should be a button to preview AMP:

amp-enabled-preview-button

  1. Toggle off 'Enable AMP'
  2. Expected: the preview button shouldn't appear anymore
  3. Toggle the 'Enable AMP' button back on
  4. Change the mode to 'Reader Mode'
  5. Reload the post editor
  6. Expected: the 'AMP Preview' button should still appear
  7. Change the AMP mode to 'Standard'
  8. Reload the post editor
  9. Expected: the 'AMP Preview' button should not appear anymore
  10. Change the mode to 'Transitional'
  11. Reload the editor
  12. Click the 'AMP Preview button

17: Expected: it should open a new tab for an AMP URL:

amp-preview-g

@kienstra
Copy link
Contributor

I'll make a screencast for this when #3323 is approved, as there might be changes to the button or the preview <svg>.

@swissspidy
Copy link
Collaborator

Can this new preview button be used to enhance the existing one as in option 2 mentioned above? I thought that was the consensus.

@kienstra
Copy link
Contributor

Option 2

Hi @swissspidy,
Yeah, Option 2 would be really nice.

But I couldn't find a way to do that, other than maybe manipulating the DOM.

dom-here

That PostPreviewButton doesn't look to be filterable, nor does the Header that uses it.

@swissspidy
Copy link
Collaborator

Yes, DOM manipulation was mentioned earlier in this thread as the potentially only possible way to do this.

@kienstra For the sake of testing, could you perhaps create a PR against your add/block-editor-amp-preview branch to explore this option?

@kienstra
Copy link
Contributor

kienstra commented Sep 24, 2019

Hi @swissspidy,
Sure, I'll create a PR to the add/block-editor-amp-preview branch to try DOM manipulation.

@kienstra
Copy link
Contributor

Steps To Test

  1. Enable 'Paired' mode
  2. Create a new post
  3. Add any content to it
  4. Click the AMP preview button:

amp-preview-here

  1. Expected: A new tab opens with 'Generating AMP preview...', and it is a preview of the edited post:

generating-pr

  1. Click the non-AMP 'Preview' button:

non-amp-preview-here

  1. Expected: This should still work as expected, showing a preview of the non-AMP post
  2. Change the mode to 'Standard'
  3. Go back to the same post
  4. Expected: the AMP 'Preview' button should no longer appear, as there isn't a separate AMP URL

@kienstra
Copy link
Contributor

Request For Testing

Hi @csossi,
Sorry for the lack of testing instructions earlier. Here are some instructions above, and it looks like this is now deployed to the testing environment.

@csossi
Copy link

csossi commented Nov 11, 2019

Verified in QA

@csossi csossi added the QA passed Has passed QA and is done label Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or improvement of an existing one Integration: Gutenberg QA passed Has passed QA and is done
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants