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

Block Tips API #16979

Closed
youknowriad opened this issue Aug 9, 2019 · 7 comments
Closed

Block Tips API #16979

youknowriad opened this issue Aug 9, 2019 · 7 comments
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Theme Style Variations Related to style variations provided by block themes [Type] Task Issues or PRs that have been broken down into an individual action to take

Comments

@youknowriad
Copy link
Contributor

youknowriad commented Aug 9, 2019

With the introduction of the inserter help panel in #16813, we have room to explore showing previews of blocks before inserting them into the content.

In order to achieve that in a clean way, each block needs to define an example set of attributes to "fill" its preview content.

This could look something like:

const blockSettings = {
  // ... other settings

  example: {
      attributes: {
          content: __( 'Content of the block' )
      },
      innerBlocks: []
  }

}

This data need to be internationalized properly and can contain both attributes and innerBlocks.

Style Variations

In the style variations picker, we're relying on the current data of the block to preview the changes, this also often results in a less than ideal experience since, depending on the current data of the block, the preview might be "pretty" or not. Designing the example data to fit that use-case will also improve the experience there.


Edit: Example API is merged, this is left open to track the tips API proposed in #16979 (comment)

@youknowriad youknowriad added [Type] Task Issues or PRs that have been broken down into an individual action to take [Feature] Block API API that allows to express the block paradigm. labels Aug 9, 2019
@youknowriad youknowriad changed the title Example Content Block API Example Block Content API Aug 9, 2019
@youknowriad youknowriad added the [Feature] Theme Style Variations Related to style variations provided by block themes label Aug 9, 2019
@mtias
Copy link
Member

mtias commented Aug 9, 2019

I think this is a good evolution and would simplify some interactions for people that are creating selectable templates (the example content is already defined there, in a way, this would consolidate it).

A few things to consider:

  • Is there any overlap with "Patterns"? The definition is going to be pretty much the same. Is there a world where we absorb this in "patterns" and show the first one as an example in the preview?
  • I'd like to also consider "tips" a bit here (Compile a list of possible block-specific tips #16595), since my expectation is they'd be defined when registering a block as tips: [ ] and both of these would increase the API surface area.

@youknowriad
Copy link
Contributor Author

Is there any overlap with "Patterns"? The definition is going to be pretty much the same. Is there a world where we absorb this in "patterns" and show the first one as an example in the preview?

Good question, They do seem to have the same shape. So an option could be. If a block has only one pattern, use it as an example. But if a block has multiple patterns, there's a question to be asked, whether the first pattern is the one that fits the "preview" the best. It might not always be the case.

I'd like to also consider "tips" a bit here (#16595), since my expectation is they'd be defined when registering a block as tips: [ ] and both of these would increase the API surface area.

👍

@mtias
Copy link
Member

mtias commented Aug 9, 2019

But if a block has multiple patterns, there's a question to be asked, whether the first pattern is the one that fits the "preview" the best. It might not always be the case.

In one of the original mockups there was a "skip" button for patterns, which would default to initial state.

Where it gets a bit tricky is that patterns don't necessarily come with content defined, it can be only configuration attributes (number of columns, widths, etc) and we still need content for example preview.

@youknowriad
Copy link
Contributor Author

Also, lately I've been wondering if Patterns are static data like the example here where we just replace the entire block with it, or are more like "functions" where they take the current state of the block and alter it. For example, can decide to keep some attributes, change inner blocks... but not necessarily "reset" everything.

@retrofox
Copy link
Contributor

retrofox commented Aug 9, 2019

I'm not completely aware of how complex a block could get, but make sense adding a reference (or something) to those parts/elements of the blocks which really want to preview?
I think on those elements that need to be hidden in the preview such as the inserter element, drop zone, etc. No make sense show them.
Right now we are using a kind of elements blacklist and applying display none.

But thinking well and going forward, we could filter those blocks/elements used to the preview, and getting rid of the rest. It will improve performance considerably.

@retrofox
Copy link
Contributor

retrofox commented Aug 9, 2019

Another concern which comes to my mind is the preview and its integration with themes. AFAIK, themes have the capability to tweak the styles of the editor.

For instance, the preview for a dark theme looks like the following:

image

I wonder if make sense dive on this in order to create a better preview consistent with the theme. For instance, in the screenshot above, the preview should show the background color black in the whole thumbnail.

@talldan
Copy link
Contributor

talldan commented Jul 21, 2021

This seems to also be tracked in #17091. I'll close this as I feel the other issue has a clearer description.

@talldan talldan closed this as completed Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Theme Style Variations Related to style variations provided by block themes [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

No branches or pull requests

4 participants