Skip to content

SPT: Update the preview responsive styles - #37744

Closed
apeatling wants to merge 4 commits into
masterfrom
update/spt-preview-sizing
Closed

apeatling wants to merge 4 commits into
masterfrom
update/spt-preview-sizing

Conversation

@apeatling

@apeatling apeatling commented Nov 20, 2019 •

Copy link
Copy Markdown
Contributor

Changes proposed in this Pull Request

  • Update the preview so that it always is consistently aligned with the left and right edge, no matter what size the viewport is. The preview is scaled depending on the viewport size, so any width preview works well. This makes it feel more like an app and visually consistent.

Before:

Screen Shot 2019-11-19 at 6 05 15 PM

After:

Screen Shot 2019-11-19 at 6 04 45 PM

Testing instructions

  • Checkout the branch, and try resizing the window. The preview pane should expand to fill the width of the modal, minus the space for the preview thumbnails and never move away from the left edge.

… and keep a consistent left margin. Do not limit the width since the contents are being scaled and it becomed detatched from the preview thumbnail sidebar.
@apeatling apeatling added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Goal] Page Templates labels Nov 20, 2019
@apeatling apeatling added this to the Experience Issues milestone Nov 20, 2019
@apeatling
apeatling requested review from a team and Copons November 20, 2019 02:08
@apeatling
apeatling requested a review from a team as a code owner November 20, 2019 02:08
@apeatling apeatling self-assigned this Nov 20, 2019
@matticbot

Copy link
Copy Markdown
Contributor

@matticbot

Copy link
Copy Markdown
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@noahtallen noahtallen left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This definitely works as intended, so if you'd like to have it in for tomorrow, go for it! note that this requires a plugin sync

I do have a couple thoughts about it:

  1. Many templates feel very large, almost as if we are zooming in on them. I know we aren't, but I imagine it's something to do with the way block preview works:

Screen Shot 2019-11-19 at 9 35 48 PM

  1. What if instead of scrolling the whole page and keeping the preview fixed, we kept the whole page fixed as well and just scrolled the list? I.e. the scrollbar wouldn't be on the far right, but beside the list of layouts.

Screen Shot 2019-11-19 at 9 37 36 PM

@Copons Copons left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Removing the wp-admin sidebar calculations won't work on wp-admin though!
(And, admittedly, those calculations don't consider the fact that on Calypso there is no sidebar...)

See how the preview overflows to the right, covering the browser scrollbar:
Screenshot 2019-11-20 at 11 48 48

Unfortunately this is not a super trivial fix, also because as @noahtallen mentioned, the BlockPreview scales the preview content based on an hardcoded 960px of viewport.
Meaning that if the preview container is 960px wide, the preview looks exactly like it will be rendered; if the container is narrower than 960px, the preview will look incrementally smaller; and if the container is wider, it will look larger.

This happens in order to get a "large screen preview" even if the actual user screen is small, instead of being responsive.

I think this is why @Automattic/ajax settled to a container max width === BlockPreview viewport width, which would only scale the preview down, and not up.

A solution might be to provide a variable viewport width to the BlockPreview, giving it a lower limit of 960px (so that the preview will scale down instead of being responsive), and no upper limit (so that the preview will always at its 1:1 scale on large screens).
I don't know the kind of performance impact this might have though.

@apeatling

Copy link
Copy Markdown
Contributor Author

Good catch on the WP-Admin view, I have everything set to full screen. :D

I think we can fix this by sticking to percentages and avoiding pixel values all together. I'll have a look at the viewport issue. I honestly don't mind the zoomed view, because it avoids users seeing the tablet view even when their browser is wide enough for a full width view. Will dig some more on this one.

@vindl vindl added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 24, 2019
@apeatling

apeatling commented Nov 25, 2019 •

Copy link
Copy Markdown
Contributor Author

Unfortunately this has broken preview rendering. The actual preview container is now sizing perfectly in all circumstances. Getting the scaling of the preview to work correctly and actually render the template is eluding me.

A solution might be to provide a variable viewport width to the BlockPreview, giving it a lower limit of 960px (so that the preview will scale down instead of being responsive), and no upper limit (so that the preview will always at its 1:1 scale on large screens).

This seems like the right way to go. If the scale is set to 1 all the time, on larger screens this works well and shows space either side of the template preview, rather than it just scaling everything up. I don't think I'm going to get this going however, so unless someone else wants to try, I'll likely close this PR out.

@apeatling apeatling closed this Nov 28, 2019
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 28, 2019
@Copons
Copons deleted the update/spt-preview-sizing branch November 29, 2019 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Goal] Page Templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants