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

Add props for InnerBlocksTemplatePicker icon, label and instructions #18738

Closed
richtabor opened this issue Nov 26, 2019 · 2 comments · Fixed by #18283
Closed

Add props for InnerBlocksTemplatePicker icon, label and instructions #18738

richtabor opened this issue Nov 26, 2019 · 2 comments · Fixed by #18283
Assignees
Labels
[Feature] Block API API that allows to express the block paradigm. [Status] In Progress Tracking issues with work in progress

Comments

@richtabor
Copy link
Member

Is your feature request related to a problem? Please describe.
The Placeholder component (and other similar components) allow for icon, label, and instructions props, for an "informed" component. InnerBlocksTemplatePicker does not allow for this, as each of the corresponding props are established within the component itself.

It would be useful for blocks to pass custom icon, label, and instructions props, so the template picker can be relative to the current block.

For example, we recently adapted this functionality within the CoBlocks Form block. It works great, but the template placeholder is not relative to the Form block. Without the block icon within the toolbar, you wouldn't know this was a Form block template/pattern selector.

Screen Shot 2019-11-25 at 7 35 24 PM

Describe the solution you'd like

If props were available, I would:

  1. Use the block's icon, in place of the layout icon currently provided
  2. Change "Choose layout" to "Choose form layout"
  3. Update the instructions to reference form templates.

These would all make the block's placeholder state much more relative, providing context to the pattern selector.

Describe alternatives you've considered
There are none.

@richtabor richtabor added the [Feature] Block API API that allows to express the block paradigm. label Nov 26, 2019
@gziolo
Copy link
Member

gziolo commented Nov 27, 2019

I have a patch ready in #18283 that addresses all the issues you mentioned. I also struggled with the default proposal which couldn't be customized for other block types.

The same PR renames InnerBlocksTemplatePicker to BlockPatternPicker. We still haven't decided whether it's going to be exposed as part of the public API but this PR does it and marks it as experimental.

@gziolo gziolo self-assigned this Nov 27, 2019
@gziolo gziolo added the [Status] In Progress Tracking issues with work in progress label Nov 27, 2019
@gziolo
Copy link
Member

gziolo commented Nov 28, 2019

@richtabor, thanks for sharing your use case. I see that you are using experimental props for InnerBlocks:
https://github.com/godaddy-wordpress/coblocks/blob/520869d400807659f57479107461dca1b48fdb33/src/blocks/form/edit.js#L387-L400

I propose in #18283 we remove all those experimental features in favor of standalone BlockPatternPicker which might even stay internal if we find a nice way to abstract Patterns API in a way where it's all handled by BlockEdit based on the registered patterns. This should make it easier to maintain all those predefined templates. I'm wondering if you have some thoughts on how this can be handled so CoBlocks could continue to work with the previous versions of Gutenberg. Do you think it's possible to implement some sort of feature detection?

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. [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants