Skip to content

Commit

Permalink
add search results header info
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Oct 20, 2021
1 parent ea6ca1f commit cf7fe53
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ function PatternsExplorer( {
} ) {
const [ filterValue, setFilterValue ] = useState( '' );
const patternList = !! filterValue ? (
<PatternExplorerSearchResults
filterValue={ filterValue }
// onSelect={ onSelect }
/>
<PatternExplorerSearchResults filterValue={ filterValue } />
) : (
children
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function PatternExplorerSearchResults( {
isAppender,
__experimentalInsertionIndex,
maxBlockPatterns,
// maxBlockTypes,
shouldFocusBlock = true,
} ) {
const debouncedSpeak = useDebounce( speak, 500 );
Expand Down Expand Up @@ -71,17 +70,33 @@ function PatternExplorerSearchResults( {

const hasItems = !! filteredBlockPatterns?.length;
return (
<InserterListbox>
{ ! hasItems && <InserterNoResults /> }
<>
{ hasItems && (
<BlockPatternsList
shownPatterns={ currentShownPatterns }
blockPatterns={ filteredBlockPatterns }
onClickPattern={ onSelectBlockPattern }
isDraggable={ false }
/>
<h2 className="block-editor-block-patterns-explorer__search-results-count">
{ sprintf(
/* translators: %d: number of patterns. */
_n(
'%d pattern found for',
'%d patterns found for',
filteredBlockPatterns.length
),
filteredBlockPatterns.length
) }
{ ` "${ filterValue }"` }
</h2>
) }
</InserterListbox>
<InserterListbox>
{ ! hasItems && <InserterNoResults /> }
{ hasItems && (
<BlockPatternsList
shownPatterns={ currentShownPatterns }
blockPatterns={ filteredBlockPatterns }
onClickPattern={ onSelectBlockPattern }
isDraggable={ false }
/>
) }
</InserterListbox>
</>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { Flex, FlexItem, SelectControl, Button } from '@wordpress/components';
import { grid } from '@wordpress/icons';
import { fullscreen } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';

function PatternInserterPanel( {
Expand Down Expand Up @@ -70,7 +70,7 @@ function PatternInserterPanel( {
<FlexItem>
<Button
label={ __( 'Pattern explorer' ) }
icon={ grid }
icon={ fullscreen }
onClick={ onShowExplorer }
isSmall
/>
Expand Down

0 comments on commit cf7fe53

Please sign in to comment.