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 Editor: Add predefined arrangements options support to InnerBlocks #15662

Closed
aduth opened this issue May 15, 2019 · 0 comments · Fixed by #16129
Closed

Block Editor: Add predefined arrangements options support to InnerBlocks #15662

aduth opened this issue May 15, 2019 · 0 comments · Fixed by #16129
Labels
[Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P Needs Design Needs design efforts. [Type] Enhancement A suggestion for improvement.

Comments

@aduth
Copy link
Member

aduth commented May 15, 2019

Using InnerBlocks, it is currently possible to provide a template which describes the initial set of blocks which should be inserted in a new instance of that block:

https://github.com/WordPress/gutenberg/blob/master/packages/block-editor/src/components/inner-blocks/README.md#template

This should be enhanced to allow a user to select from a number of predefined, named template options.

Prior art:

When inserting a new Row block from the Coblocks plugin, the user is presented to choose both the number and from a number of layout options:

image

Usage examples:

  • A Columns block could provide a few predefined layouts.
  • A Contact Form block (like the one included in Jetpack) may provide options for specific types of forms (support request, mailing list signup).

Implementation proposal:

This could be considered a layer atop template, inheriting the same behaviors, but expressing a set of options from which the user can choose. Therefore, I would propose this would be named similarly, as a separate templateOptions prop.

It's necessary to consider what information is necessary for each option to be able to present it in the interface:

  • Name (human-readable label)
  • Icon
  • (?) Defaultness

The Coblocks Row example is one more of a "wizard" of multiple steps to generate a block. It would be worth considering this, though also whether a more incremental or simple approach would be preferable.

Proposed usage ("Columns" as example):

<InnerBlocks
	templateOptions={ [
		{
			title: __( 'Two-thirds, one-third' ),
			icon: <svg { /* ... */ } />,
			template: [
				[ 'core/column', { width: 66.66 } ],
				[ 'core/column', { width: 33.33 } ],
			],
		},
		{
			title: __( 'Equal halves' ),
			icon: <svg { /* ... */ } />,
			template: [
				[ 'core/column', { width: 50 } ],
				[ 'core/column', { width: 50 } ],
			],
		},
		{
			title: __( 'Thirds' ),
			icon: <svg { /* ... */ } />,
			template: [
				[ 'core/column', { width: 33.33 } ],
				[ 'core/column', { width: 33.33 } ],
				[ 'core/column', { width: 33.33 } ],
			],
		},
	] }
/>	

Notes:

  • Choice of title (vs. label, name, etc) is for consistency to block registration API
@aduth aduth added [Type] Enhancement A suggestion for improvement. Needs Design Needs design efforts. [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P labels May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P Needs Design Needs design efforts. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant