Skip to content

Commit 4e7b46b

Browse files
committed
remove search provider
1 parent f462250 commit 4e7b46b

File tree

14 files changed

+57
-432
lines changed

14 files changed

+57
-432
lines changed

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

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

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

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

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,51 @@
11
'use client';
22

33
import SearchInput from '@node-core/ui-components/Common/Search/Input';
4+
import SearchResults from '@node-core/ui-components/Common/Search/Results';
45
import { useTranslations } from 'next-intl';
56
import type { ComponentProps, FC } from 'react';
67

78
import { DEFAULT_ORAMA_QUERY_PARAMS } from '#site/next.constants.mjs';
8-
import { useSearchbox } from '#site/providers/searchboxProvider';
99

1010
import { Footer } from '../Footer';
11-
import { SearchResultsWrapper } from '../SearchResults';
1211
import styles from './index.module.css';
12+
import type { Document } from '../DocumentLink';
13+
import { SearchItem } from '../SearchItem';
1314

14-
type SearchProps = ComponentProps<typeof SearchInput>;
15+
type SearchProps = {
16+
mode: 'search' | 'chat';
17+
onChat: () => void;
18+
} & ComponentProps<typeof SearchInput>;
1519

16-
export const Search: FC<SearchProps> = props => {
17-
const searchbox = useSearchbox();
20+
export const Search: FC<SearchProps> = ({ mode, onChat, ...props }) => {
1821
const t = useTranslations();
1922

2023
return (
2124
<div className={styles.searchContainer}>
2225
<SearchInput
2326
ariaLabel={t('components.search.searchPlaceholder')}
2427
placeholder={t('components.search.searchPlaceholder')}
25-
tabIndex={searchbox?.mode === 'search' ? 0 : -1}
26-
aria-hidden={searchbox?.mode === 'chat'}
28+
tabIndex={mode === 'search' ? 0 : -1}
29+
aria-hidden={mode === 'chat'}
2730
{...props}
2831
searchParams={DEFAULT_ORAMA_QUERY_PARAMS}
2932
/>
30-
31-
<SearchResultsWrapper />
33+
<SearchResults
34+
suggestions={[
35+
t('components.search.suggestionOne'),
36+
t('components.search.suggestionTwo'),
37+
t('components.search.suggestionThree'),
38+
]}
39+
suggestionsTitle={t('components.search.suggestions')}
40+
noResultsTitle={t('components.search.noResultsFoundFor')}
41+
searchParams={DEFAULT_ORAMA_QUERY_PARAMS}
42+
onChat={onChat}
43+
chatLabel={t('components.search.chatButtonLabel')}
44+
tabIndex={mode === 'search' ? 0 : -1}
45+
aria-hidden={mode === 'chat'}
46+
>
47+
{hit => <SearchItem document={hit.document as Document} mode={mode} />}
48+
</SearchResults>
3249
<Footer />
3350
</div>
3451
);

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

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

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@
22

33
import SearchModal from '@node-core/ui-components/Common/Search/Modal';
44
import { useTranslations } from 'next-intl';
5-
import type { FC } from 'react';
5+
import { useRef, useState, type FC } from 'react';
66

7-
import { SearchboxProvider } from '#site/providers/searchboxProvider';
8-
9-
import InnerModal from './InnerModal';
107
import { oramaClient } from './orama-client';
8+
import { Search } from './Search';
9+
import { SlidingChatPanel } from './SlidingChatPanel';
1110

1211
const Searchbox: FC = () => {
1312
const t = useTranslations();
13+
const searchInputRef = useRef<HTMLInputElement>(null);
14+
const [mode, setMode] = useState<'chat' | 'search'>('search');
1415

1516
return (
16-
<SearchboxProvider>
17-
<SearchModal
18-
client={oramaClient}
19-
placeholder={t('components.search.searchPlaceholder')}
20-
>
21-
<InnerModal />
22-
</SearchModal>
23-
</SearchboxProvider>
17+
<SearchModal
18+
client={oramaClient}
19+
placeholder={t('components.search.searchPlaceholder')}
20+
>
21+
<Search ref={searchInputRef} mode={mode} onChat={() => setMode('chat')} />
22+
<SlidingChatPanel
23+
open={mode === 'chat'}
24+
onClose={() => setMode('search')}
25+
/>
26+
</SearchModal>
2427
);
2528
};
2629

apps/site/providers/searchboxProvider.tsx

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

apps/site/reducers/searchboxReducer.ts

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

apps/site/types/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ export * from './download';
1616
export * from './userAgent';
1717
export * from './vulnerabilities';
1818
export * from './page';
19-
export * from './searchbox';

apps/site/types/searchbox.ts

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

packages/ui-components/src/Common/Search/Chat/Input/index.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@
6363
@apply mb-4
6464
flex
6565
items-center
66+
justify-center
6667
gap-2
6768
overflow-x-auto
6869
px-1
69-
text-sm
70-
lg:justify-center;
70+
text-sm;
7171

7272
&::-webkit-scrollbar {
7373
@apply hidden;

0 commit comments

Comments
 (0)