-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Template Parts: Show existing template parts and a list of block patterns at creation flow. #38814
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
Changes from 1 commit
1a2a04e
20ef770
7ea39d1
a33b0ee
fb31d12
3b1eee1
4fbb342
a4e25b3
c11e04a
9992c51
6ebdd90
cb5c7b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { useState } from '@wordpress/element'; | ||
| import { __, sprintf } from '@wordpress/i18n'; | ||
| import { | ||
| TextControl, | ||
| Flex, | ||
| FlexItem, | ||
| Button, | ||
| Modal, | ||
| } from '@wordpress/components'; | ||
|
|
||
| export default function TitleModal( { areaLabel, onClose, onSubmit } ) { | ||
| // Restructure onCreate to set the blocks on local state. | ||
| // Add modal to confirm title and trigger onCreate. | ||
| const [ title, setTitle ] = useState( __( 'Untitled Template Part' ) ); | ||
|
|
||
| const submitForCreation = ( event ) => { | ||
| event.preventDefault(); | ||
| onSubmit( title ); | ||
| }; | ||
|
|
||
| return ( | ||
| <Modal | ||
| title={ sprintf( | ||
| // Translators: %s as template part area title ("Header", "Footer", etc.). | ||
| __( 'Name and create your new %s' ), | ||
| areaLabel.toLowerCase() | ||
| ) } | ||
| closeLabel={ __( 'Cancel' ) } | ||
| overlayClassName="wp-block-template-part__placeholder-create-new__title-form" | ||
| onRequestClose={ onClose } | ||
| > | ||
| <form onSubmit={ submitForCreation }> | ||
| <TextControl | ||
| label={ __( 'Name' ) } | ||
| value={ title } | ||
| onChange={ setTitle } | ||
| /> | ||
| <Flex | ||
| className="wp-block-template-part__placeholder-create-new__title-form-actions" | ||
| justify="flex-end" | ||
| > | ||
| <FlexItem> | ||
| <Button | ||
| variant="primary" | ||
| type="submit" | ||
| disabled={ ! title.length } | ||
| aria-disabled={ ! title.length } | ||
| > | ||
| { __( 'Create' ) } | ||
| </Button> | ||
| </FlexItem> | ||
| </Flex> | ||
| </form> | ||
| </Modal> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,14 @@ | ||
| .block-editor-template-part-placeholder__modal { | ||
| .block-editor-template-part__selection-modal { | ||
| @include break-medium() { | ||
| width: $break-medium - $grid-unit-20 * 2; | ||
| } | ||
|
|
||
| .components-modal__content { | ||
| padding: 0; | ||
| } | ||
| } | ||
|
|
||
| .block-library-template-part__selection .block-editor-block-patterns-list { | ||
| .block-library-template-part__selection-content .block-editor-block-patterns-list { | ||
| display: grid; | ||
| grid-template-columns: 1fr 1fr 1fr; | ||
|
||
| grid-gap: $grid-unit-10; | ||
|
|
@@ -13,3 +17,20 @@ | |
| margin-bottom: 0; | ||
| } | ||
| } | ||
|
|
||
| .block-library-template-part__selection-content { | ||
| padding: 0 $grid-unit-40 $grid-unit-20; | ||
| } | ||
|
|
||
| .block-library-template-part__selection-footer { | ||
| position: sticky; | ||
| bottom: 0; | ||
| background: $white; | ||
| border-top: $border-width solid $gray-300; | ||
| padding: $grid-unit-20 $grid-unit-40; | ||
| display: flex; | ||
| flex-direction: row; | ||
| justify-content: flex-end; | ||
| width: 100%; | ||
| z-index: z-index(".components-modal__header"); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.