Skip to content

Commit

Permalink
Rename "Navigation Menu Item" to "Link".
Browse files Browse the repository at this point in the history
  • Loading branch information
mtias committed Nov 10, 2019
1 parent 0552712 commit eec040f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation-menu-item/block.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "core/navigation-menu-item",
"name": "core/navigation-link",
"category": "layout",
"attributes": {
"label": {
Expand Down
36 changes: 18 additions & 18 deletions packages/block-library/src/navigation-menu-item/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const updateLinkSetting = ( setter ) => ( setting, value ) => {
* through of the `onLinkChange` LinkControl callback.
*
* @param {Function} setter Setter attribute function.
* @param {string} label ItemMenu link label.
* @param {string} label Link label.
*/
const updateLink = ( setter, label ) => ( { title: newTitle = '', url: newURL = '' } = {} ) => {
setter( {
Expand All @@ -70,13 +70,13 @@ const updateLink = ( setter, label ) => ( { title: newTitle = '', url: newURL =
}
};

function NavigationMenuItemEdit( {
function NavigationLinkEdit( {
attributes,
hasDescendants,
isSelected,
isParentOfSelectedBlock,
setAttributes,
insertMenuItemBlock,
insertLinkBlock,
} ) {
const { label, opensInNewTab, title, url } = attributes;
const link = title ? { title, url } : null;
Expand Down Expand Up @@ -116,7 +116,7 @@ function NavigationMenuItemEdit( {
* `onKeyDown` LinkControl handler.
* It takes over to stop the event propagation to make the
* navigation work, avoiding undesired behaviors.
* For instance, it will block to move between menu items
* For instance, it will block to move between link blocks
* when the LinkControl is focused.
*
* @param {Event} event
Expand All @@ -130,7 +130,7 @@ function NavigationMenuItemEdit( {
}
};

const itemLabelPlaceholder = __( 'Add item…' );
const itemLabelPlaceholder = __( 'Add link…' );

return (
<Fragment>
Expand All @@ -152,14 +152,14 @@ function NavigationMenuItemEdit( {
<ToolbarButton
name="submenu"
icon={ <SVG xmlns="http://www.w3.org/2000/svg" width="24" height="24"><Path d="M14 5h8v2h-8zm0 5.5h8v2h-8zm0 5.5h8v2h-8zM2 11.5C2 15.08 4.92 18 8.5 18H9v2l3-3-3-3v2h-.5C6.02 16 4 13.98 4 11.5S6.02 7 8.5 7H12V5H8.5C4.92 5 2 7.92 2 11.5z" /><Path fill="none" d="M0 0h24v24H0z" /></SVG> }
title={ __( 'Add submenu item' ) }
onClick={ insertMenuItemBlock }
title={ __( 'Add Submenu' ) }
onClick={ insertLinkBlock }
/>
</Toolbar>
</BlockControls>
<InspectorControls>
<PanelBody
title={ __( 'Menu Settings' ) }
title={ __( 'Link Settings' ) }
>
<ToggleControl
checked={ attributes.opensInNewTab }
Expand Down Expand Up @@ -192,12 +192,12 @@ function NavigationMenuItemEdit( {
onChange={ ( nofollow ) => {
setAttributes( { nofollow } );
} }
label={ __( 'Add nofollow to menu item' ) }
label={ __( 'Add nofollow to link' ) }
help={ (
<Fragment>
{ __( 'Don\'t let search engines follow this link.' ) }
<ExternalLink
className="wp-block-navigation-menu-item__nofollow-external-link"
className="wp-block-navigation-link__nofollow-external-link"
href={ __( 'https://codex.wordpress.org/Nofollow' ) }
>
{ __( 'What\'s this?' ) }
Expand All @@ -208,22 +208,22 @@ function NavigationMenuItemEdit( {
</PanelBody>
</InspectorControls>
<div className={ classnames(
'wp-block-navigation-menu-item', {
'wp-block-navigation-link', {
'is-editing': isSelected || isParentOfSelectedBlock,
'is-selected': isSelected,
} ) }
>
<div className="wp-block-navigation-menu-item__inner">
<div className="wp-block-navigation-link__inner">
<RichText
className="wp-block-navigation-menu-item__content"
className="wp-block-navigation-link__content"
value={ label }
onChange={ ( labelValue ) => setAttributes( { label: labelValue } ) }
placeholder={ itemLabelPlaceholder }
withoutInteractiveFormatting
/>
{ isLinkOpen && (
<LinkControl
className="wp-block-navigation-menu-item__inline-link-input"
className="wp-block-navigation-link__inline-link-input"
onKeyDown={ handleLinkControlOnKeyDown }
onKeyPress={ ( event ) => event.stopPropagation() }
currentLink={ link }
Expand All @@ -243,7 +243,7 @@ function NavigationMenuItemEdit( {
) }
</div>
<InnerBlocks
allowedBlocks={ [ 'core/navigation-menu-item' ] }
allowedBlocks={ [ 'core/navigation-link' ] }
renderAppender={ hasDescendants ? InnerBlocks.ButtonBlockAppender : false }
/>
</div>
Expand All @@ -263,14 +263,14 @@ export default compose( [
} ),
withDispatch( ( dispatch, ownProps ) => {
return {
insertMenuItemBlock() {
insertLinkBlock() {
const { clientId } = ownProps;

const {
insertBlock,
} = dispatch( 'core/block-editor' );

const blockToInsert = createBlock( 'core/navigation-menu-item' );
const blockToInsert = createBlock( 'core/navigation-link' );
insertBlock(
blockToInsert,
0,
Expand All @@ -279,4 +279,4 @@ export default compose( [
},
};
} ),
] )( NavigationMenuItemEdit );
] )( NavigationLinkEdit );
6 changes: 3 additions & 3 deletions packages/block-library/src/navigation-menu-item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const { name } = metadata;
export { metadata, name };

export const settings = {
title: __( 'Menu Item' ),
title: __( 'Navigation Link' ),

parent: [ 'core/navigation-menu' ],
parent: [ 'core/navigation-link' ],

icon: <SVG xmlns="http://www.w3.org/2000/svg" width="24" height="24"><Path d="M12 7.27l4.28 10.43-3.47-1.53-.81-.36-.81.36-3.47 1.53L12 7.27M12 2L4.5 20.29l.71.71L12 18l6.79 3 .71-.71L12 2z" /></SVG>,

description: __( 'Add a page, link, or other item to your Navigation Menu.' ),
description: __( 'Add a page, link, or other item to your navigation.' ),

__experimentalDisplayName: 'label',

Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/navigation-menu/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function NavigationMenu( {
}

return pages.map( ( { title, type, link: url, id } ) => (
[ 'core/navigation-menu-item', {
[ 'core/navigation-link', {
label: title.rendered,
title: title.raw,
type,
Expand Down Expand Up @@ -154,7 +154,7 @@ function NavigationMenu( {
{ pages &&
<InnerBlocks
template={ defaultMenuItems ? defaultMenuItems : null }
allowedBlocks={ [ 'core/navigation-menu-item' ] }
allowedBlocks={ [ 'core/navigation-link' ] }
templateInsertUpdatesSelection={ false }
__experimentalMoverDirection={ 'horizontal' }
/>
Expand Down

0 comments on commit eec040f

Please sign in to comment.