Skip to content

Commit

Permalink
Add check for command icons
Browse files Browse the repository at this point in the history
  • Loading branch information
richtabor committed Aug 14, 2023
1 parent 45678ad commit 716380a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/commands/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@wordpress/icons": "file:../icons",
"@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts",
"@wordpress/private-apis": "file:../private-apis",
"classnames": "^2.3.1",
"cmdk": "^0.2.0",
"rememo": "^4.0.2"
},
Expand Down
16 changes: 12 additions & 4 deletions packages/commands/src/components/command-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import { Command, useCommandState } from 'cmdk';
import classnames from 'classnames';

/**
* WordPress dependencies
Expand Down Expand Up @@ -53,9 +54,14 @@ function CommandMenuLoader( { name, search, hook, setLoader, close } ) {
>
<HStack
alignment="left"
className="commands-command-menu__item"
className={ classnames(
'commands-command-menu__item',
{
'with-no-icon': ! command.icon,
}
) }
>
<Icon icon={ command.icon } />
{ command.icon && <Icon icon={ command.icon } /> }
<span>
<TextHighlight
text={ command.label }
Expand Down Expand Up @@ -123,9 +129,11 @@ export function CommandMenuGroup( { isContextual, search, setLoader, close } ) {
>
<HStack
alignment="left"
className="commands-command-menu__item"
className={ classnames( 'commands-command-menu__item', {
'with-no-icon': ! command.icon,
} ) }
>
<Icon icon={ command.icon } />
{ command.icon && <Icon icon={ command.icon } /> }
<span>
<TextHighlight
text={ command.label }
Expand Down

0 comments on commit 716380a

Please sign in to comment.