-
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.
First stab at editable menu items in navigator
Use Slot/Fill instead of hardcoded components Disable slots/fills in global editor block navigator Grab clientId from context instead of requiring a prop Improve readability of block-navigation/list.js Use context to determine whether or not given BlockNavigation may be customized with slots Restore default value for selectBlock in navigation-structure-panel.js Remove obsolete onChange passed to NavigationStructurePanel Use constant value for BlockNavigationContext Use memo() in BlockStyles Remove performance changes from BlockStyles Generalize BlockNavigationListItem and remove the BlockNavigationListItemFill for now Rename useBlockNavigationSlots to withBlockNavigationSlots Restore RichText in the navigator Sort out BlockNavigationListItem and BlockNavigationListItemWrapper Rename BlockNavigationListItemWrapper to BlockNavigationBranch
- Loading branch information
Showing
5 changed files
with
170 additions
and
50 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
packages/block-editor/src/components/block-navigation/list-item.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,58 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Button, VisuallyHidden } from '@wordpress/components'; | ||
import { | ||
__experimentalGetBlockLabel as getBlockLabel, | ||
getBlockType, | ||
} from '@wordpress/blocks'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockIcon from '../block-icon'; | ||
|
||
export default function BlockNavigationListItem( { | ||
block, | ||
onClick, | ||
isSelected, | ||
wrapperComponent: WrapperComponent, | ||
children, | ||
} ) { | ||
const blockType = getBlockType( block.name ); | ||
|
||
return ( | ||
<div className="block-editor-block-navigation__item"> | ||
<WrapperComponent | ||
className={ classnames( | ||
'block-editor-block-navigation__item-button', | ||
{ | ||
'is-selected': isSelected, | ||
} | ||
) } | ||
onClick={ onClick } | ||
> | ||
<BlockIcon icon={ blockType.icon } showColors /> | ||
{ children | ||
? children | ||
: getBlockLabel( blockType, block.attributes ) } | ||
{ isSelected && ( | ||
<VisuallyHidden as="span"> | ||
{ __( '(selected block)' ) } | ||
</VisuallyHidden> | ||
) } | ||
</WrapperComponent> | ||
</div> | ||
); | ||
} | ||
|
||
BlockNavigationListItem.defaultProps = { | ||
onClick: () => {}, | ||
wrapperComponent: ( props ) => <Button { ...props } />, | ||
}; |
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