Skip to content

Commit

Permalink
Refresh command palette styling (#53117)
Browse files Browse the repository at this point in the history
* Add a search icon, update placeholder

* Clean up styles

* Add back mark styling

* Remove space between groups

* Add back mark font-weight styling

* $grid-unit-05 to $radius-block-ui
  • Loading branch information
richtabor authored Aug 2, 2023
1 parent fb428fc commit ae4385a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
6 changes: 4 additions & 2 deletions packages/commands/src/components/command-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
store as keyboardShortcutsStore,
useShortcut,
} from '@wordpress/keyboard-shortcuts';
import { Icon } from '@wordpress/icons';
import { Icon, search as inputIcon } from '@wordpress/icons';

/**
* Internal dependencies
Expand Down Expand Up @@ -168,8 +168,9 @@ function CommandInput( { isOpen, search, setSearch } ) {
ref={ commandMenuInput }
value={ search }
onValueChange={ setSearch }
placeholder={ __( 'Type a command or search' ) }
placeholder={ __( 'Search for commands' ) }
aria-activedescendant={ selectedItemId }
icon={ search }
/>
);
}
Expand Down Expand Up @@ -260,6 +261,7 @@ export function CommandMenu() {
onKeyDown={ onKeyDown }
>
<div className="commands-command-menu__header">
<Icon icon={ inputIcon } />
<CommandInput
search={ search }
setSearch={ setSearch }
Expand Down
34 changes: 19 additions & 15 deletions packages/commands/src/components/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// dirty hack to clean up modal
.commands-command-menu {
width: 100%;
max-width: 480px;
max-width: 420px;
position: relative;
top: 15%;

Expand All @@ -19,6 +19,7 @@
.commands-command-menu__header {
display: flex;
align-items: center;
padding-left: $grid-unit-20;

.components-button {
height: $grid-unit-70;
Expand All @@ -42,33 +43,32 @@
[cmdk-input] {
border: none;
width: 100%;
padding: $grid-unit-20;
padding: $grid-unit-20 $grid-unit-20 $grid-unit-20 $grid-unit-10;
outline: none;
color: $gray-900;
margin: 0;
font-size: 20px;
font-size: 16px;
line-height: 28px;
border-bottom: 1px solid $gray-200;
border-radius: 0;

&::placeholder {
color: $gray-600;
color: $gray-700;
}

&:focus {
box-shadow: none;
outline: none;
border-bottom: 1px solid $gray-200;
}
}

[cmdk-item] {
border-radius: $grid-unit-05;
border-radius: $radius-block-ui;
cursor: pointer;
display: flex;
align-items: center;
padding: $grid-unit;
color: $gray-900;
font-size: $default-font-size;

&[aria-selected="true"],
&:active {
Expand All @@ -86,16 +86,16 @@
}

svg {
fill: $gray-600;
fill: $gray-900;
}
}

[cmdk-root] > [cmdk-list] {
max-height: 400px;
max-height: 368px; // Specific to not have commands overflow oddly.
overflow: auto;

& > [cmdk-list-sizer] :has([cmdk-group-items]:not(:empty)) {
padding: $grid-unit;
& > [cmdk-list-sizer]:not(:empty) {
padding: 0 $grid-unit $grid-unit;
}
}

Expand All @@ -105,7 +105,7 @@
justify-content: center;
height: $grid-unit-80;
white-space: pre-wrap;
color: $gray-800;
color: $gray-900;
}

[cmdk-loading] {
Expand All @@ -115,10 +115,14 @@
[cmdk-list-sizer] {
position: relative;
}
}

[cmdk-group]:has([cmdk-group-items]:not(:empty)):not([hidden]) + [cmdk-group]:has([cmdk-group-items]:not(:empty)) {
border-top: $border-width solid $gray-200;
}
.commands-command-menu__item span {
// Ensure commands do not run off the edge (great for post titles).
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.commands-command-menu__item mark {
Expand Down

0 comments on commit ae4385a

Please sign in to comment.