mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-17 05:02:23 +08:00
'Show X more results' instead of 'Show all X results'.
This commit is contained in:
parent
d7d67476a8
commit
c55f14b3b0
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ export interface ClearType {
|
||||
export interface ExpandType {
|
||||
showAll: () => void;
|
||||
totalCount: number;
|
||||
moreCount: number;
|
||||
}
|
||||
|
||||
export type SearchItem = Item & { refId: string; path: string[] };
|
||||
|
Loading…
x
Reference in New Issue
Block a user