forked from algolia/docsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResultsScreen.tsx
More file actions
68 lines (61 loc) · 2.14 KB
/
ResultsScreen.tsx
File metadata and controls
68 lines (61 loc) · 2.14 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
import React, { type JSX } from 'react';
import { SelectIcon, SourceIcon } from './icons';
import { Results } from './Results';
import type { ScreenStateProps } from './ScreenState';
import type { InternalDocSearchHit } from './types';
import { removeHighlightTags } from './utils';
type ResultsScreenProps = Omit<ScreenStateProps<InternalDocSearchHit>, 'translations'>;
export function ResultsScreen(props: ResultsScreenProps): JSX.Element {
return (
<div className="DocSearch-Dropdown-Container">
{props.state.collections.map((collection) => {
if (collection.items.length === 0) {
return null;
}
const title = removeHighlightTags(collection.items[0]);
return (
<Results
{...props}
key={collection.source.sourceId}
title={title}
collection={collection}
renderIcon={({ item, index }) => (
<>
{item.__docsearch_parent && (
<svg className="DocSearch-Hit-Tree" viewBox="0 0 24 54">
<g
stroke="currentColor"
fill="none"
fillRule="evenodd"
strokeLinecap="round"
strokeLinejoin="round"
>
{item.__docsearch_parent !== collection.items[index + 1]?.__docsearch_parent ? (
<path d="M8 6v21M20 27H8.3" />
) : (
<path d="M8 6v42M20 27H8.3" />
)}
</g>
</svg>
)}
<div className="DocSearch-Hit-icon">
<SourceIcon type={item.type} />
</div>
</>
)}
renderAction={() => (
<div className="DocSearch-Hit-action">
<SelectIcon />
</div>
)}
/>
);
})}
{props.resultsFooterComponent && (
<section className="DocSearch-HitsFooter">
<props.resultsFooterComponent state={props.state} />
</section>
)}
</div>
);
}