-
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 - make function component and new specific sel…
…ector `getBlockTransformItems` (#27674) * Refactor BlockSwitcher - function component and break into more files * new selector for block transforms * jsdoc selectors * fix BlockSwitcher tests * getBlockTransformItems tests * make BlockStylesMenu named function * move icon logic in `useSelect` * fix unit tests
- Loading branch information
1 parent
35bd1cb
commit 2db6a54
Showing
8 changed files
with
654 additions
and
343 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
35 changes: 35 additions & 0 deletions
35
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,35 @@ | ||
/** | ||
* 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'; | ||
|
||
export default function 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> | ||
); | ||
} |
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.