-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Template Part: Improve insertion flow. (#23295)
* Template Part: Improve insertion flow. * Template Part: Fix styles and remove unnecessary properties. * Template Part: Update tests. * Template Part: Improve popover design. * Template Part: Improve name panel style. * Fix property handling.
- Loading branch information
Showing
15 changed files
with
220 additions
and
273 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
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
36 changes: 36 additions & 0 deletions
36
packages/block-library/src/template-part/edit/name-panel.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,36 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useEntityProp } from '@wordpress/core-data'; | ||
import { TextControl } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { cleanForSlug } from '@wordpress/url'; | ||
|
||
export default function TemplatePartNamePanel( { postId, setAttributes } ) { | ||
const [ title, setTitle ] = useEntityProp( | ||
'postType', | ||
'wp_template_part', | ||
'title', | ||
postId | ||
); | ||
const [ slug, setSlug ] = useEntityProp( | ||
'postType', | ||
'wp_template_part', | ||
'slug', | ||
postId | ||
); | ||
return ( | ||
<div className="wp-block-template-part__name-panel"> | ||
<TextControl | ||
label={ __( 'Name' ) } | ||
value={ title || slug } | ||
onChange={ ( value ) => { | ||
setTitle( value ); | ||
const newSlug = cleanForSlug( value ); | ||
setSlug( newSlug ); | ||
setAttributes( { slug: newSlug } ); | ||
} } | ||
/> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.