-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathindex.tsx
More file actions
71 lines (62 loc) · 2.08 KB
/
index.tsx
File metadata and controls
71 lines (62 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import {
ArrowDownIcon,
ArrowTurnDownLeftIcon,
ArrowUpIcon,
} from '@heroicons/react/24/solid';
import SearchModal from '#ui/Common/Search/Modal';
import SearchResults from '#ui/Common/Search/Results';
import SearchHit from '#ui/Common/Search/Results/Hit';
import type { OramaCloud } from '@orama/core';
import styles from './index.module.css';
type SearchBoxProps = {
client: OramaCloud;
closeShortcutLabel?: string;
navigateShortcutLabel?: string;
noResultsTitle?: string;
onWarmup?: () => Promise<void> | void;
placeholder?: string;
selectShortcutLabel?: string;
};
const SearchBox: React.FC<SearchBoxProps> = ({
client,
placeholder = 'Start typing...',
noResultsTitle = 'No results found for',
closeShortcutLabel = 'to close',
navigateShortcutLabel = 'to navigate',
onWarmup,
selectShortcutLabel = 'to select',
}) => (
<SearchModal client={client} placeholder={placeholder} onWarmup={onWarmup}>
<div className={styles.searchResultsContainer}>
<SearchResults
noResultsTitle={noResultsTitle}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onHit={hit => <SearchHit document={hit.document as any} />}
/>
</div>
<div className={styles.footer}>
<div className={styles.shortcutWrapper}>
<div className={styles.shortcutItem}>
<kbd className={styles.shortcutKey}>
<ArrowTurnDownLeftIcon />
</kbd>
<span className={styles.shortcutLabel}>{selectShortcutLabel}</span>
</div>
<div className={styles.shortcutItem}>
<kbd className={styles.shortcutKey}>
<ArrowDownIcon />
</kbd>
<kbd className={styles.shortcutKey}>
<ArrowUpIcon />
</kbd>
<span className={styles.shortcutLabel}>{navigateShortcutLabel}</span>
</div>
<div className={styles.shortcutItem}>
<kbd className={styles.shortcutKey}>esc</kbd>
<span className={styles.shortcutLabel}>{closeShortcutLabel}</span>
</div>
</div>
</div>
</SearchModal>
);
export default SearchBox;