-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathindex.jsx
More file actions
62 lines (55 loc) · 1.91 KB
/
index.jsx
File metadata and controls
62 lines (55 loc) · 1.91 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
import {
ArrowDownIcon,
ArrowTurnDownLeftIcon,
ArrowUpIcon,
} from '@heroicons/react/24/solid';
import SearchModal from '@node-core/ui-components/Common/Search/Modal';
import SearchResults from '@node-core/ui-components/Common/Search/Results';
import SearchHit from '@node-core/ui-components/Common/Search/Results/Hit';
import styles from './index.module.css';
import useOrama from '../../hooks/useOrama.mjs';
import { relativeOrAbsolute } from '../../utils/relativeOrAbsolute.mjs';
const SearchBox = ({ pathname }) => {
const client = useOrama(pathname);
return (
<SearchModal client={client} placeholder="Start typing...">
<div className={styles.searchResultsContainer}>
<SearchResults
noResultsTitle="No results found for"
onHit={hit => (
<SearchHit
document={{
...hit.document,
href: relativeOrAbsolute(hit.document.href, pathname),
}}
/>
)}
/>
</div>
<div className={styles.footer}>
<div className={styles.shortcutWrapper}>
<div className={styles.shortcutItem}>
<kbd className={styles.shortcutKey}>
<ArrowTurnDownLeftIcon />
</kbd>
<span className={styles.shortcutLabel}>to select</span>
</div>
<div className={styles.shortcutItem}>
<kbd className={styles.shortcutKey}>
<ArrowDownIcon />
</kbd>
<kbd className={styles.shortcutKey}>
<ArrowUpIcon />
</kbd>
<span className={styles.shortcutLabel}>to navigate</span>
</div>
<div className={styles.shortcutItem}>
<kbd className={styles.shortcutKey}>esc</kbd>
<span className={styles.shortcutLabel}>to close</span>
</div>
</div>
</div>
</SearchModal>
);
};
export default SearchBox;