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

Site Editing: Simplify template part toolbar #27397

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/block-library/src/template-part/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default function TemplatePartEdit( {
<ToolbarButton
aria-expanded={ isOpen }
icon={ isOpen ? chevronUp : chevronDown }
label={ __( 'Choose another' ) }
label={ __( 'Switch template part' ) }
onClick={ onToggle }
// Disable when open to prevent odd FireFox bug causing reopening.
// As noted in https://github.com/WordPress/gutenberg/pull/24990#issuecomment-689094119 .
Expand Down
31 changes: 5 additions & 26 deletions packages/block-library/src/template-part/edit/name-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,25 @@
* WordPress dependencies
*/
import { useEntityProp } from '@wordpress/core-data';
import { TextControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { cleanForSlug } from '@wordpress/url';
import { __experimentalText as Text } from '@wordpress/components';

export default function TemplatePartNamePanel( { postId, setAttributes } ) {
const [ title, setTitle ] = useEntityProp(
export default function TemplatePartNamePanel( { postId } ) {
const [ title ] = useEntityProp(
'postType',
'wp_template_part',
'title',
postId
);
const [ slug, setSlug ] = useEntityProp(
const [ slug ] = useEntityProp(
'postType',
'wp_template_part',
'slug',
postId
);
const [ status, setStatus ] = useEntityProp(
'postType',
'wp_template_part',
'status',
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 );
if ( status !== 'publish' ) {
setStatus( 'publish' );
}
setAttributes( { slug: newSlug, postId } );
} }
onFocus={ ( event ) => event.target.select() }
/>
<Text variant="body">{ title || slug }</Text>
</div>
);
}
14 changes: 13 additions & 1 deletion packages/block-library/src/template-part/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@

.wp-block-template-part__name-panel {
outline: 1px solid transparent;
padding: $grid-unit-10 0 $grid-unit-10 $grid-unit-15;
padding: $grid-unit-10 0 $grid-unit-10 $grid-unit-20;
display: flex;
align-items: center;

.components-base-control__field {
align-items: center;
Expand All @@ -89,3 +91,13 @@
box-shadow: 0 0 0 $border-width var(--wp-admin-theme-color);
}
}

.block-editor-block-toolbar__slot {
.components-toolbar-group {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful with "order", as they might make for inopportune tabbing flows.

order: 1;
}

.wp-block-template-part__block-control-group {
order: 0;
}
}