-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor BlockSwitcher to function component and use the new hook
- Loading branch information
1 parent
f0d9db2
commit 2b13593
Showing
3 changed files
with
221 additions
and
220 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
packages/block-editor/src/components/block-switcher/block-styles-menu.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 { __ } from '@wordpress/i18n'; | ||
import { MenuGroup } from '@wordpress/components'; | ||
import { useState } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockStyles from '../block-styles'; | ||
import PreviewBlockPopover from './preview-block-popover'; | ||
|
||
const BlockStylesMenu = ( { hoveredBlock, onSwitch } ) => { | ||
const [ hoveredClassName, setHoveredClassName ] = useState(); | ||
return ( | ||
<MenuGroup | ||
label={ __( 'Styles' ) } | ||
className="block-editor-block-switcher__styles__menugroup" | ||
> | ||
{ hoveredClassName && ( | ||
<PreviewBlockPopover | ||
hoveredBlock={ hoveredBlock } | ||
hoveredClassName={ hoveredClassName } | ||
/> | ||
) } | ||
<BlockStyles | ||
clientId={ hoveredBlock.clientId } | ||
onSwitch={ onSwitch } | ||
onHoverClassName={ setHoveredClassName } | ||
itemRole="menuitem" | ||
/> | ||
</MenuGroup> | ||
); | ||
}; | ||
export default BlockStylesMenu; |
Oops, something went wrong.