Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a rotating list of tips to the inserter help panel #20163

Merged
merged 3 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ import classnames from 'classnames';
*/
import { speak } from '@wordpress/a11y';
import { __, _n, _x, sprintf } from '@wordpress/i18n';
import {
Component,
__experimentalCreateInterpolateElement,
createRef,
} from '@wordpress/element';
import { PanelBody, withSpokenMessages, Tip } from '@wordpress/components';
import { Component, createRef } from '@wordpress/element';
import { PanelBody, withSpokenMessages } from '@wordpress/components';
import {
isReusableBlock,
createBlock,
Expand All @@ -45,6 +41,7 @@ import BlockPreview from '../block-preview';
import BlockTypesList from '../block-types-list';
import BlockCard from '../block-card';
import ChildBlocks from './child-blocks';
import Tips from './tips';
import __experimentalInserterMenuExtension from '../inserter-menu-extension';
import { searchItems } from './search-items';

Expand Down Expand Up @@ -537,14 +534,7 @@ export class InserterMenu extends Component {
) }
</p>
</div>
<Tip>
{ __experimentalCreateInterpolateElement(
__(
'While writing, you can press <kbd>/</kbd> to quickly insert new blocks.'
),
{ kbd: <kbd /> }
) }
</Tip>
<Tips />
</div>
) }
</div>
Expand Down
44 changes: 44 additions & 0 deletions packages/block-editor/src/components/inserter/tips.js
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;