-
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 rotating list of tips to the inserter help panel (#20163)
Co-authored-by: Matias Ventura <mv@matiasventura.com>
- Loading branch information
1 parent
a46cd2f
commit 9d67638
Showing
2 changed files
with
48 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
__experimentalCreateInterpolateElement, | ||
useState, | ||
} from '@wordpress/element'; | ||
import { Tip } from '@wordpress/components'; | ||
|
||
const globalTips = [ | ||
__experimentalCreateInterpolateElement( | ||
__( | ||
'While writing, you can press <kbd>/</kbd> to quickly insert new blocks.' | ||
), | ||
{ kbd: <kbd /> } | ||
), | ||
__experimentalCreateInterpolateElement( | ||
__( | ||
'Indent a list by pressing <kbd>space</kbd> at the beginning of a line.' | ||
), | ||
{ kbd: <kbd /> } | ||
), | ||
__experimentalCreateInterpolateElement( | ||
__( | ||
'Outdent a list by pressing <kbd>backspace</kbd> at the beginning of a line' | ||
), | ||
{ kbd: <kbd /> } | ||
), | ||
__( 'Drag files into the editor to automatically insert media blocks.' ), | ||
__( "Change a block's type by pressing the block icon on the toolbar." ), | ||
]; | ||
|
||
function Tips() { | ||
const [ randomIndex ] = useState( | ||
// Disable Reason: I'm not generating an HTML id. | ||
// eslint-disable-next-line no-restricted-syntax | ||
Math.floor( Math.random() * globalTips.length ) | ||
); | ||
|
||
return <Tip>{ globalTips[ randomIndex ] }</Tip>; | ||
} | ||
|
||
export default Tips; |