-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Columns template options, support InnerBlock templateOptions (#16129
- Loading branch information
1 parent
c3f65fb
commit 855be79
Showing
24 changed files
with
433 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
packages/block-editor/src/components/inner-blocks/template-picker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { Button, IconButton, Placeholder } from '@wordpress/components'; | ||
|
||
function InnerBlocksTemplatePicker( { | ||
options, | ||
onSelect, | ||
allowSkip, | ||
} ) { | ||
const classes = classnames( 'block-editor-inner-blocks__template-picker', { | ||
'has-many-options': options.length > 4, | ||
} ); | ||
|
||
const instructions = allowSkip ? | ||
__( 'Select a layout to start with, or make one yourself.' ) : | ||
__( 'Select a layout to start with.' ); | ||
|
||
return ( | ||
<Placeholder | ||
icon="layout" | ||
label={ __( 'Choose Layout' ) } | ||
instructions={ instructions } | ||
className={ classes } | ||
> | ||
{ | ||
/* | ||
* Disable reason: The `list` ARIA role is redundant but | ||
* Safari+VoiceOver won't announce the list otherwise. | ||
*/ | ||
/* eslint-disable jsx-a11y/no-redundant-roles */ | ||
} | ||
<ul className="block-editor-inner-blocks__template-picker-options" role="list"> | ||
{ options.map( ( templateOption, index ) => ( | ||
<li key={ index }> | ||
<IconButton | ||
isLarge | ||
icon={ templateOption.icon } | ||
onClick={ () => onSelect( templateOption.template ) } | ||
className="block-editor-inner-blocks__template-picker-option" | ||
label={ templateOption.title } | ||
/> | ||
</li> | ||
) ) } | ||
</ul> | ||
{ /* eslint-enable jsx-a11y/no-redundant-roles */ } | ||
{ allowSkip && ( | ||
<div className="block-editor-inner-blocks__template-picker-skip"> | ||
<Button | ||
isLink | ||
onClick={ () => onSelect( undefined ) } | ||
> | ||
{ __( 'Skip' ) } | ||
</Button> | ||
</div> | ||
) } | ||
</Placeholder> | ||
); | ||
} | ||
|
||
export default InnerBlocksTemplatePicker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.