-
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.
Add a dismissible hint about the rename instead of changing menu labe…
…ling
- Loading branch information
1 parent
3419143
commit 8f9158d
Showing
10 changed files
with
94 additions
and
9 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
50 changes: 50 additions & 0 deletions
50
packages/block-editor/src/components/inserter/reusable-block-rename-hint.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,50 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Button } from '@wordpress/components'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { focus } from '@wordpress/dom'; | ||
import { useRef } from '@wordpress/element'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { close } from '@wordpress/icons'; | ||
import { store as preferencesStore } from '@wordpress/preferences'; | ||
|
||
const PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible'; | ||
|
||
export default function ReusableBlocksRenameHint() { | ||
const isReusableBlocksRenameHint = useSelect( | ||
( select ) => | ||
select( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true, | ||
[] | ||
); | ||
|
||
const ref = useRef(); | ||
|
||
const { set: setPreference } = useDispatch( preferencesStore ); | ||
if ( ! isReusableBlocksRenameHint ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div ref={ ref } className="reusable-blocks-menu-items__rename-hint"> | ||
<div className="reusable-blocks-menu-items__rename-hint-content"> | ||
{ __( 'Reusable blocks are now called "patterns".' ) } | ||
</div> | ||
<Button | ||
className="reusable-blocks-menu-items__rename-hint-dismiss" | ||
icon={ close } | ||
iconSize="16" | ||
label={ __( 'Dismiss hint' ) } | ||
onClick={ () => { | ||
// Retain focus when dismissing the element. | ||
const previousElement = focus.tabbable.findPrevious( | ||
ref.current | ||
); | ||
previousElement?.focus(); | ||
setPreference( 'core', PREFERENCE_NAME, false ); | ||
} } | ||
showTooltip={ false } | ||
/> | ||
</div> | ||
); | ||
} |
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
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