Skip to content

Commit fb64698

Browse files
committed
fixup!
1 parent 4e7b46b commit fb64698

File tree

5 files changed

+59
-112
lines changed

5 files changed

+59
-112
lines changed

apps/site/components/Common/Searchbox/Search/index.module.css

Lines changed: 0 additions & 47 deletions
This file was deleted.

apps/site/components/Common/Searchbox/Search/index.tsx

Lines changed: 0 additions & 52 deletions
This file was deleted.

apps/site/components/Common/Searchbox/index.tsx

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,51 @@
11
'use client';
22

3+
import Search from '@node-core/ui-components/Common/Search';
34
import SearchModal from '@node-core/ui-components/Common/Search/Modal';
45
import { useTranslations } from 'next-intl';
5-
import { useRef, useState, type FC } from 'react';
6+
import { useState, type FC } from 'react';
67

8+
import { DEFAULT_ORAMA_QUERY_PARAMS } from '#site/next.constants.mjs';
9+
10+
import type { Document } from './DocumentLink';
11+
import { Footer } from './Footer';
712
import { oramaClient } from './orama-client';
8-
import { Search } from './Search';
13+
import { SearchItem } from './SearchItem';
914
import { SlidingChatPanel } from './SlidingChatPanel';
1015

1116
const Searchbox: FC = () => {
1217
const t = useTranslations();
13-
const searchInputRef = useRef<HTMLInputElement>(null);
1418
const [mode, setMode] = useState<'chat' | 'search'>('search');
1519

1620
return (
1721
<SearchModal
1822
client={oramaClient}
1923
placeholder={t('components.search.searchPlaceholder')}
2024
>
21-
<Search ref={searchInputRef} mode={mode} onChat={() => setMode('chat')} />
25+
<Search
26+
input={{
27+
placeholder: t('components.search.searchPlaceholder'),
28+
ariaLabel: t('components.search.searchPlaceholder'),
29+
}}
30+
results={{
31+
suggestions: [
32+
t('components.search.suggestionOne'),
33+
t('components.search.suggestionTwo'),
34+
t('components.search.suggestionThree'),
35+
],
36+
suggestionsTitle: t('components.search.suggestions'),
37+
noResultsTitle: t('components.search.noResultsFoundFor'),
38+
chatLabel: t('components.search.chatButtonLabel'),
39+
onChat: () => setMode('chat'),
40+
onHit: hit => (
41+
<SearchItem document={hit.document as Document} mode={mode} />
42+
),
43+
}}
44+
tabIndex={mode === 'search' ? 0 : -1}
45+
aria-hidden={mode === 'chat'}
46+
searchParams={DEFAULT_ORAMA_QUERY_PARAMS}
47+
/>
48+
<Footer />
2249
<SlidingChatPanel
2350
open={mode === 'chat'}
2451
onClose={() => setMode('search')}

packages/ui-components/src/Common/Search/Results/index.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ import SearchResultsSkeleton from './Skeleton';
1212
import Tabs from './Tabs';
1313

1414
type SearchResultsWrapperProps = {
15-
chatLabel: string;
15+
chatLabel?: string;
1616
onChat: () => void;
1717
searchParams: Omit<ComponentProps<typeof Tabs>['searchParams'], 'term'>;
18-
children: ComponentProps<typeof SearchResults.GroupList>['children'];
18+
onHit: ComponentProps<typeof SearchResults.GroupList>['children'];
1919
} & ComponentProps<typeof SearchResultsEmpty>;
2020

2121
const SearchResultsWrapper: FC<SearchResultsWrapperProps> = ({
2222
onChat,
2323
chatLabel,
2424
searchParams,
25-
children,
25+
onHit,
2626
suggestionsTitle,
2727
suggestions,
2828
noResultsTitle,
@@ -41,9 +41,9 @@ const SearchResultsWrapper: FC<SearchResultsWrapperProps> = ({
4141
className={classNames(styles.chatButton, {
4242
[styles.chatButtonWithSearch]: searchTerm,
4343
})}
44-
{...props}
4544
initialPrompt={searchTerm || undefined}
4645
data-focus-on-arrow-nav
46+
{...props}
4747
>
4848
<SparklesIcon />
4949
<span>
@@ -58,10 +58,7 @@ const SearchResultsWrapper: FC<SearchResultsWrapperProps> = ({
5858
<SearchResults.Wrapper>
5959
<Tabs
6060
{...props}
61-
searchParams={{
62-
...searchParams,
63-
term: searchTerm ?? '',
64-
}}
61+
searchParams={{ ...searchParams, term: searchTerm ?? '' }}
6562
selectedFacet={selectedFacet}
6663
/>
6764
<SearchResultsSkeleton />
@@ -80,7 +77,7 @@ const SearchResultsWrapper: FC<SearchResultsWrapperProps> = ({
8077
<div key={group.name} className={styles.searchResultsGroup}>
8178
<h2 className={styles.searchResultsGroupTitle}>{group.name}</h2>
8279
<SearchResults.GroupList group={group}>
83-
{children}
80+
{onHit}
8481
</SearchResults.GroupList>
8582
</div>
8683
)}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { ComponentProps, FC } from 'react';
2+
3+
import SearchInput from '@node-core/ui-components/Common/Search/Input';
4+
import SearchResults from '@node-core/ui-components/Common/Search/Results';
5+
6+
type SearchProps = {
7+
input: Partial<ComponentProps<typeof SearchInput>>;
8+
results: Partial<ComponentProps<typeof SearchResults>>;
9+
} & Omit<Partial<ComponentProps<typeof SearchInput>>, 'results'> &
10+
Omit<Partial<ComponentProps<typeof SearchResults>>, 'results'>;
11+
12+
const Search: FC<SearchProps> = ({ input, results, ...props }) => (
13+
<>
14+
<SearchInput {...input} {...props} />
15+
<SearchResults
16+
{...(results as ComponentProps<typeof SearchResults>)}
17+
{...props}
18+
/>
19+
</>
20+
);
21+
22+
export default Search;

0 commit comments

Comments
 (0)