gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Consider showing block preview when hovering block in inserter

Open jasmussen opened this issue 8 years ago • 11 comments

This would be a desktop-only enhancement and would be good to pair with #4102.

You'd click the inserter and get the interface you're used to:

inserter

When hovering a block, a little preview area would pop up below the inserter:

inserter preview

The thing we'd show here would be the block, pre-filled with some dummy content (in this case the description text). The entire preview element would then be scaled down to 75%, using something like transform: scale( .75 ).

This was an idea @mtias suggested a while back.

jasmussen avatar Dec 20 '17 10:12 jasmussen

I really like this idea for helping people discover what a block is. Right now we are getting some strong feedback about discoverability not being great on types of blocks. I've seen in tests people 'trying out' blocks, in theory this means they don't have to.

karmatosed avatar Dec 20 '17 10:12 karmatosed

@jasmussen I love the direction of this. Would be great to test it out and see how it feels. But my initial reaction is that this is a good idea.

jwold avatar Dec 20 '17 21:12 jwold

@jasmussen Good idea and UI. One thing to note is it may be something that shouldn’t be required. While the core blocks are relatively simple, plugins will most definitely be introducing much more complex blocks where a preview like this could be complicated.

carlhancock avatar Dec 21 '17 00:12 carlhancock

It would not be consistent. Third party block(s) cannot be forced to have own preview.

StaggerLeee avatar Dec 21 '17 11:12 StaggerLeee

Thanks @jasmussen for exploring this one! The other side to this idea is that it'd be crucial for saved blocks — specially when you have more than a few, and the names alone don't cut it. Imagine having 5-10 testimonials and being able to quickly preview before inserting.

Third party block(s) cannot be forced to have own preview.

The preview would be a real render of the block with dummy data, so as long as a block can be inserted, it can be previewed.

Adding the ability to opt out of preview seems good.

mtias avatar Dec 26 '17 16:12 mtias

Another thing that would be nice to pair with this: snapshot tests. cc @youknowriad @gziolo in case you have ideas, but if we can make the preview be the thing we also test automatically, it could make sure we are not breaking blocks.

mtias avatar Dec 26 '17 16:12 mtias

It should be possible to pass block type to EditBlock component and shallow render it and snapshot test. I can play with that when back to from being away from desktop 😎

gziolo avatar Dec 26 '17 18:12 gziolo

The data attrs should be set in a way that accomplishes both the ability to preview and the ability to test.

mtias avatar Dec 26 '17 18:12 mtias

@mtias How would the preview scale? It would work for things that are of reasonable size, but it could break down for things that are visually larger (especially vertically) or blocks that are heavily data driven.

carlhancock avatar Dec 28 '17 16:12 carlhancock

This could be another good reason to move the inserter inline, similar to other blocks and placeholders. Kind of like a placeholder block that in not defined yet.

  • Previews are displayed inline and at real size.
  • You can move the inserter block/proto-placeholder.
  • Mobile friendly, always fits, no overlapping boxes.
  • Could be part of the undo flow: Not what you wanted, undo and you're back to the inserter.

Edit: I tried this once in https://github.com/WordPress/gutenberg/pull/2284/files#diff-713395e403ae0725760f64d46356b7b6R16

ellatrix avatar Jan 03 '18 15:01 ellatrix

How would the preview scale? It would work for things that are of reasonable size, but it could break down for things that are visually larger (especially vertically) or blocks that are heavily data driven.

Given that the purpose of the preview would be to just aid in recognition when looking through a bunch of blocks. Given that it would be prefilled with dummy data, and having only to serve this reminder purpose, we could not only use transform: scale( .5 ), but we could even put a maximum width and height to the container where the preview would be shown, and simply fade/crop the block preview if need be.

jasmussen avatar Jan 04 '18 10:01 jasmussen