MCPcopy Create free account
hub / github.com/pacexy/flow / SearchView

Function SearchView

apps/reader/src/components/viewlets/SearchView.tsx:37–82  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

35}
36
37export const SearchView: React.FC<PaneViewProps> = (props) => {
38 const [action] = useAction()
39 const { focusedBookTab } = useReaderSnapshot()
40 const t = useTranslation()
41
42 const [keyword, setKeyword] = useIntermediateKeyword()
43
44 const results = focusedBookTab?.results
45 const expanded = results?.some((r) => r.expanded)
46
47 return (
48 <PaneView
49 actions={[
50 {
51 id: expanded ? 'collapse-all' : 'expand-all',
52 title: t(expanded ? 'action.collapse_all' : 'action.expand_all'),
53 Icon: expanded ? VscCollapseAll : VscExpandAll,
54 handle() {
55 reader.focusedBookTab?.results?.forEach(
56 (r) => (r.expanded = !expanded),
57 )
58 },
59 },
60 ]}
61 {...props}
62 >
63 <div className="scroll-parent">
64 <div className="px-5 py-px">
65 <TextField
66 as="input"
67 name="keyword"
68 autoFocus={action === 'search'}
69 hideLabel
70 value={keyword}
71 placeholder={t('search.title')}
72 onChange={(e) => setKeyword(e.target.value)}
73 onClear={() => setKeyword('')}
74 />
75 </div>
76 {keyword && results && (
77 <ResultList results={results as IMatch[]} keyword={keyword} />
78 )}
79 </div>
80 </PaneView>
81 )
82}
83
84interface ResultListProps {
85 results: IMatch[]

Callers

nothing calls this directly

Calls 4

useActionFunction · 0.90
useReaderSnapshotFunction · 0.90
useTranslationFunction · 0.90
useIntermediateKeywordFunction · 0.85

Tested by

no test coverage detected