-
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.
Split block label and accessibility label
- Loading branch information
Showing
27 changed files
with
490 additions
and
399 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
60 changes: 60 additions & 0 deletions
60
packages/block-editor/src/components/block-navigation/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,60 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Button } from '@wordpress/components'; | ||
import { | ||
getBlockType, | ||
} from '@wordpress/blocks'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockIcon from '../block-icon'; | ||
import ButtonBlockAppender from '../button-block-appender'; | ||
|
||
export default function BlockNavigationItem( { block, isSelected, onClick, children } ) { | ||
const { clientId, name } = block; | ||
const blockIcon = getBlockType( name ).icon; | ||
const blockLabel = useSelect( | ||
( select ) => select( 'core/block-editor' ).getBlockLabel( clientId ), | ||
[ clientId ] | ||
); | ||
|
||
return ( | ||
<li> | ||
<div className="block-editor-block-navigation-item__block"> | ||
<Button | ||
className={ classnames( 'block-editor-block-navigation-item__button', { | ||
'is-selected': isSelected, | ||
} ) } | ||
onClick={ onClick } | ||
> | ||
<BlockIcon icon={ blockIcon } showColors /> | ||
{ blockLabel } | ||
{ isSelected && <span className="screen-reader-text">{ __( '(selected block)' ) }</span> } | ||
</Button> | ||
</div> | ||
{ children } | ||
</li> | ||
); | ||
} | ||
|
||
BlockNavigationItem.Appender = function( { parentBlockClientId } ) { | ||
return ( | ||
<li> | ||
<div className="block-editor-block-navigation-item__appender"> | ||
<ButtonBlockAppender | ||
rootClientId={ parentBlockClientId } | ||
__experimentalSelectBlockOnInsert={ false } | ||
/> | ||
</div> | ||
</li> | ||
); | ||
}; |
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
Oops, something went wrong.