gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Responsive View Controls in Gutenberg

Open mapk opened this issue 7 years ago • 38 comments

Problem

Users who are concerned about their site's mobile experience can't view the entire content area of Gutenberg in smaller screens easily to see how it all looks. Some of the user interviews from wporg showed this concern.

Solution

Research, design, and implement responsive screen sizes for Gutenberg. Many of today's browsers include responsive controls that change the screen size. Some examples below:

Chrome: screen shot 2019-01-04 at 5 28 14 pm

Firefox: screen shot 2019-01-04 at 5 28 53 pm

mapk avatar Jan 05 '19 02:01 mapk

For reference, Divi has a feature quite similar to this: https://www.youtube.com/watch?v=OG01IaoeFPs

ZebulanStanphill avatar Jan 05 '19 21:01 ZebulanStanphill

Squarespace:

squarespace-responsive

Weebly:

weebly-responsive

Wix (pretty much the same as Weebly:

wix-responsive

melchoyce avatar Jan 10 '19 17:01 melchoyce

SurveyMonkey has two ways they show this:

  1. In Preview & Score mode: http://cld.wthms.co/Goj3iw+ Direct Link: http://cld.wthms.co/Goj3iw

  2. In external Preview mode: http://cld.wthms.co/SP8EZg+ Direct Link: http://cld.wthms.co/SP8EZg

I kind of like the awareness of the browser window size, in the second example, auto shifting to mobile preview under x viewport. (is an animated gif, click if not playing)

msdesign21 avatar Jan 10 '19 20:01 msdesign21

Sure. Users will first make all possible editor acrobatics. Later they will call website developer(s) and complain "You did not finish the job !".

StaggerLeee avatar Jan 17 '19 14:01 StaggerLeee

For completeness, here's how the Customizer handles responsive previews:

customizer-responsive


Also, it strikes me that there are (at least) two possible ways this could manifest in Gutenberg:

  1. As a preview-only enhancement. Currently when you hit preview in Gutenberg, it passes the preview off to a new window/tab. One option for us would be to keep the preview more contextual and open it up without a page refresh, and then include controls in a new toolbar or something:

preview-responsive (Figma)

  1. As a control somewhere within the editor itself, enabling you to actually edit inside of the different device previews:

gutenberg-responsive (Figma)

Both have their pros and cons, but the preview-only mode seems like it'd be potentially less complicated? Not sure.

kjellr avatar Jan 17 '19 21:01 kjellr

Thanks to everyone who has been sharing ideas and for tackling this challenge :) Some of the options shared above are also interesting – particularly the Wix and Squarespace examples that @melchoyce shared. Throwing my 2¢ in, from the mobile perspective.

Most of the anxieties we (the mobile team @ Automattic) have heard during research seem to be related to "double-checking" that their site looks good right before publishing. In other words, I'm not sure to what extent they're concerned with a sophisticated responsive-building process, as much as a gut-check to see what their users see.

With that in mind, I agree with @kjellr – a simple toggle during preview might solve the bulk of the anxiety, so I would start there and test to see how far that gets us – especially bc (in my opinion) that control should exist regardless of any in-editor things we might build. This is essentially what we've been considering on the native mobile apps as well.

I'm also not super familiar with the research on the Core Research side (vs our mobile-centric research), so maybe y'all are hearing different.

iamthomasbishop avatar Jan 21 '19 16:01 iamthomasbishop

Big fan of Kjell's mockups combined with Thomas' thoughts. That seems like an approach. Worth noting that Calypso has the preview in a modal that features similar sizing tools.

For a future exploration, inspired by ideas by @alexislloyd, I've been exploring having padding around the editing canvas:

site frame

The key reason being so you could click that padding to, among other things, fit a block toolbar on the document itself. This padding area could also feature responsive control buttons such as those shown by Kjell, and the editing canvas could resize itself in response to that.

For the time being, this is a half baked idea shared early in hopes that it might inspire other ideas from the community, so don't consider it a proposal as such.

jasmussen avatar Jan 22 '19 12:01 jasmussen

Google Sites has a nice approach:

google-sites

melchoyce avatar Jan 22 '19 18:01 melchoyce

@jasmussen I like that idea of adding padding around the canvas, and like the example @melchoyce shared (Google Sites), I imagine the distinction would be clearer with a different color background for contrast and perhaps a slight elevation.

iamthomasbishop avatar Jan 22 '19 20:01 iamthomasbishop

👋 @kjellr et al

the preview-only mode seems like it'd be potentially less complicated? Not sure.

I agree - it does seem less complicated. TL:DR - After a recent round of WooCommerce Blocks usability testing our designs are heading in that direction. However, we could still use some more testing.


We ran small test on the WooCommerce product blocks, ( p6riRB-3Ri-p2 ) and responsive previewing was included. Both of the prototypes we used featured the blended approach mentioned in the comment above: (https://github.com/WordPress/gutenberg/issues/13203#issuecomment-455331923)

It proved to be tricky, as our blocks have a few different settings, and not all of them should be editable on a device by device basis. Some of the challenges our participants faced are directly related to a couple of the questions @mapk is asking in this released issue: #13363 - In the last iteration linked below (v3), we've moved-block specific responsive controls to the settings level, to remove confusion about what exactly was being manipulated.

Here's a bit more info on what we've tested thus far:

The first version of the prototype showed all the settings all the time, no matter what device you were previewing.

screen shot 2019-01-22 at 8 18 08 pm

We added more explicit copy to indicate that changing layout controls while in mobile preview mode would only affect the mobile layout. The copy helped with the layout controls, but changing the category filter while in mobile preview mode still tripped people up. Participants were split on whether changing it would only affect mobile, or if the change would apply globally.

The second version of the prototype performed incrementally better. This version would show or hide settings depending on the screen size selection at the top of the sidebar settings.

screen shot 2019-01-22 at 8 20 57 pm

It removed confusion about what you could and couldn't edit on mobile, but it was still unclear if filtering by category in "Large screens" would carry over to mobile.

screen shot 2019-01-22 at 8 19 24 pm

Feedback from the usability test is guiding a third version of the prototype, which we hope to test soon.

screen shot 2019-01-22 at 9 01 52 pm

This version still allows a user to edit settings while previewing, but it completely de-couples previewing from the block-specific responsive controls.

In any case, the more I click around on the latest version of the prototype, and the more I look at all the great examples linked in other comments above, I think it's worth testing a preview-only version of this as well.

LevinMedia avatar Jan 23 '19 05:01 LevinMedia

Thanks for sharing David, it's so good to see such amazing mockups shared here.

jasmussen avatar Jan 23 '19 07:01 jasmussen

Don't forget about the issue of when previewing from devices that are "smaller than the desktop size." IE I use a standard display 1280×1024 laptop, and don't keep my window 100% full screen, I'm often times seen as a "tablet" user, yet I'm shown in the bottom of the customizer for instance that I'm previewing the desktop size. Clicking on tablet - I have the same view because i'm within that breakpoint. The preview of devices should reflect an actual preview from the device with respect to the content either being scaled down to fit within the viewport or allowing scrolling horizontally. Tablets are increasing popular to do work in a portable fashion as well, so those user should be able to click a button to see an actual desktop size preview without having to go somewhere else in their browser to try and view the "desktop site," as this breaks the entire writing/previewing flow by needing a refresh and saving changes etc. All of the above videos and gifs, it's clear that they are all on very large displays because most designers and developers are using equipment that is "above average" to the normal user - and those people are a much higher percentage of the user base.

timelsass avatar Mar 08 '19 18:03 timelsass

Adding on to the discussion

Block-specific responsive controls https://github.com/WordPress/gutenberg/issues/13363

Add Block: Responsive https://github.com/WordPress/gutenberg/issues/6650

Support for Responsive Columns https://github.com/WordPress/gutenberg/issues/6048

paaljoachim avatar Apr 23 '19 17:04 paaljoachim

I am removing the 'User Experience (UX)' label as part of a label cleanup. It's not being used anymore consistently so let's try and keep to 'needs design' and 'needs design feedback'. If we find a need for another label we can consider it but having those 2 should cover this.

karmatosed avatar May 07 '19 19:05 karmatosed

+1

klihelp avatar Jun 10 '19 18:06 klihelp

1. As a control somewhere within the editor itself, enabling you to actually edit inside of the different device previews:

gutenberg-responsive (Figma)

Both have their pros and cons, but the preview-only mode seems like it'd be potentially less complicated? Not sure.

I think its necessary to have the controls in the editor itself, it makes it so much easier to build your pages in gutenberg for different devices. I really like the mockup Levinmedia provided!

KevinUme avatar Jun 20 '19 09:06 KevinUme

1. As a control somewhere within the editor itself, enabling you to actually edit inside of the different device previews:

gutenberg-responsive (Figma) Both have their pros and cons, but the preview-only mode seems like it'd be potentially less complicated? Not sure.

I think its necessary to have the controls in the editor itself, it makes it so much easier to build your pages in gutenberg for different devices. I really like the mockup Levinmedia provided!

It also makes it usefull for headless implimentations that may not have a wordpress frontend to preview.

afridley avatar Sep 10 '19 18:09 afridley

Related: #11833

iandunn avatar Sep 27 '19 15:09 iandunn

Noting that this is also related https://github.com/WordPress/gutenberg/pull/16730.

Note we have <ResponsiveBlockControl /> which already allows per viewport Block settings to be created.

https://github.com/WordPress/gutenberg/tree/1d8ccc5054da58e25e320542789c66293add0467/packages/block-editor/src/components/responsive-block-control

I think a global canvas toggle for different viewports would be great. Would also help to have an API to define the viewports for the site/theme/editor.

getdave avatar Nov 06 '19 13:11 getdave

I'm not sure if there's any prior comments about the technical implementation, but to me, the primary challenge there is in forcing media queries to take effect artificially (i.e. when in-fact the viewport has not changed), if we assume these styles are made responsive via media queries.

The options I could imagine for addressing this include:

  • Using an iframe for the preview. This is what's used for Customizer previews. This may be more challenging / fragile to implement in the editor while preserving intended styles and interactions.
    • Specifically, to maintain interactions in the iframe (modifying blocks), I would imagine there would need to be some communication layer to maintain state between the top-level editor and the iframe'd content. There are some options here, particularly if the actions can be serialized, but it seems reasonably complex. It would likely be simpler if the content could be assumed to be static/non-interactive while previewed.
  • Dynamically transforming editor styles. There is some precedent here with the <BlockEditor /> component transformStyles prop, which is used to dynamically apply a wrapper class to selectors in CSS enqueued in the editor.

If we reconsider the original assumption that these styles take effect via media queries, there can be "simpler" alternatives. Notably, we could add modifier classes to the body or editor container (e.g. .is-tablet) which a block developer could then use to apply styles relevant for those offsets. A downside here is it is less obvious for those who'd otherwise be accustomed to media queries, and it eliminates some option for code reuse between front-end and editor block styles.

aduth avatar Nov 06 '19 16:11 aduth