'Show X more results' instead of 'Show all X results'.

This commit is contained in:
Gert Hengeveld 2020-10-07 10:51:09 +02:00
parent d7d67476a8
commit c55f14b3b0
3 changed files with 6 additions and 4 deletions

View File

@ -21,7 +21,7 @@ import {
} from './types';
import { searchItem } from './utils';
const MAX_SEARCH_RESULTS = 50;
const DEFAULT_MAX_SEARCH_RESULTS = 50;
const options = {
shouldSort: true,
@ -196,11 +196,12 @@ export const Search: FunctionComponent<{
);
if (componentResults.length) {
results = componentResults.slice(0, allComponents ? 1000 : MAX_SEARCH_RESULTS);
if (componentResults.length > MAX_SEARCH_RESULTS && !allComponents) {
results = componentResults.slice(0, allComponents ? 1000 : DEFAULT_MAX_SEARCH_RESULTS);
if (componentResults.length > DEFAULT_MAX_SEARCH_RESULTS && !allComponents) {
results.push({
showAll: () => showAllComponents(true),
totalCount: componentResults.length,
moreCount: componentResults.length - DEFAULT_MAX_SEARCH_RESULTS,
});
}
}

View File

@ -155,7 +155,7 @@ export const SearchResults: FunctionComponent<{
isHighlighted={highlightedIndex === index}
>
<ActionIcon icon="plus" />
<ActionLabel>Show all ({result.totalCount} results)</ActionLabel>
<ActionLabel>Show {result.moreCount} more results</ActionLabel>
</ActionRow>
);
}

View File

@ -42,6 +42,7 @@ export interface ClearType {
export interface ExpandType {
showAll: () => void;
totalCount: number;
moreCount: number;
}
export type SearchItem = Item & { refId: string; path: string[] };