-
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.
Zoom Out: Only show the inserters when a block is selected or hovered (…
…#63668) * Zoom Out: Only show the inserters when a block is selected or hovered * Correct logic for rendering the zoom out inserters We want to show the inserters on hover, even if there is no selection. * Update shouldRenderInsertionPoint condition * Make the inserters always present and just toggle visibility * Update docs/reference-guides/data/data-core-block-editor.md * Update packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.js * Update packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.js * Update packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.js * Update packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.js * Update packages/block-editor/src/store/reducer.js * Update packages/block-editor/src/store/reducer.js * Update packages/block-editor/src/store/selectors.js * fix the property name * Reduce number of select calls by lifting useSelect calls to ZoomOutModeInserters --------- Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com> Co-authored-by: scruffian <scruffian@git.wordpress.org> Co-authored-by: jeryj <jeryj@git.wordpress.org>
- Loading branch information
1 parent
6b0b4e4
commit 6a466a0
Showing
9 changed files
with
191 additions
and
33 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
47 changes: 47 additions & 0 deletions
47
packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.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,47 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import clsx from 'clsx'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useState } from '@wordpress/element'; | ||
import { Button } from '@wordpress/components'; | ||
import { plus } from '@wordpress/icons'; | ||
import { _x } from '@wordpress/i18n'; | ||
|
||
function ZoomOutModeInserterButton( { isVisible, onClick } ) { | ||
const [ | ||
zoomOutModeInserterButtonHovered, | ||
setZoomOutModeInserterButtonHovered, | ||
] = useState( false ); | ||
|
||
return ( | ||
<Button | ||
variant="primary" | ||
icon={ plus } | ||
size="compact" | ||
className={ clsx( | ||
'block-editor-button-pattern-inserter__button', | ||
'block-editor-block-tools__zoom-out-mode-inserter-button', | ||
{ | ||
'is-visible': isVisible || zoomOutModeInserterButtonHovered, | ||
} | ||
) } | ||
onClick={ onClick } | ||
onMouseOver={ () => { | ||
setZoomOutModeInserterButtonHovered( true ); | ||
} } | ||
onMouseOut={ () => { | ||
setZoomOutModeInserterButtonHovered( false ); | ||
} } | ||
label={ _x( | ||
'Add pattern', | ||
'Generic label for pattern inserter button' | ||
) } | ||
/> | ||
); | ||
} | ||
|
||
export default ZoomOutModeInserterButton; |
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