gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Block Styles: Show style preview when hovered or focused

Open shaunandrews opened this issue 5 years ago • 7 comments

image

Block Styles appear in both the block's toolbar and in the editor's sidebar. Currently, styles are shown with both a rendered preview and a name. The previews are a little too small to be helpful, but also add to the overall height of the sidebar accordion. Here's how it look when a plugin adds just a few styles to the Button block:

image

The overall height of the accordion in the screenshot above is about 570px. It ends up pushing down more important controls like Typography and Color.

Lets move the previews so they only appear when the style is hovered or has keyboard focus. This reduces the overall footprint, and also puts more emphasis on the style's name.

Style Previews on Hover

shaunandrews avatar Aug 06 '21 15:08 shaunandrews

I like the way this feels - it appears more functional while also feeling a bit more modern when handling the preview.

fwazeter avatar Aug 07 '21 12:08 fwazeter

I agree. This makes styles still be featured - but take up a lot less space in the sidebar.

richtabor avatar Aug 09 '21 16:08 richtabor

I tried this out using a Popover. I had to rely on a Popover SlotFill at the outer, Post Editor level since the sidebar hides any overflow.

Screen Capture on 2021-09-01 at 11-08-21

On mouseover, rendering the preview is not entirely reliable as you can see from the screen capture above.

Often there's not enough time for the preview container to calculate the correct height, something it does on the fly. My guess the Popover animation and the bevy of nested iframes don't help much.

Still, this happens sometimes in the block inserter previews as well.

Also, for mobile (and if the popovers prove too unruly/inaccessible) I thought maybe we could reduce the preview to the currently selected (no previews)

styes-mobile-batman

Also were there any preferences for the Default Style dropdown?

Thanks!

ramonjd avatar Sep 01 '21 01:09 ramonjd

One thing that stands out in terms of componetry — because this is a design pattern we don't have anywhere else — is that it looks fairly aligned with the new proposal for font pair selection in global styles:

image

It might be good to be explicit about aligning there in terms of component semantics.

mtias avatar Sep 08 '21 11:09 mtias

@shaunandrews have you thought about the "default style" dropdown and how it'd fit? It's even more pronounced now with the smaller footprint of the style selectors and seems off. Might make sense to think of a panel ellipsis menu to handle reset and setting a new default instead, like "set current option as default".

mtias avatar Sep 08 '21 11:09 mtias

Worked on in https://github.com/WordPress/gutenberg/pull/34522

apeatling avatar Nov 03 '21 15:11 apeatling

Using the more menu could help with resetting and changing the default style:

image

shaunandrews avatar Nov 03 '21 15:11 shaunandrews