Skip to content

Commit f462250

Browse files
committed
fixup!
1 parent bfeaa56 commit f462250

File tree

6 files changed

+51
-59
lines changed

6 files changed

+51
-59
lines changed
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
'use client';
2-
31
import Input from '@node-core/ui-components/Common/Search/Chat/Input';
4-
import { useChat } from '@orama/ui/hooks';
52
import { useTranslations } from 'next-intl';
63
import type { FC } from 'react';
74

85
export const ChatInput: FC = () => {
96
const t = useTranslations();
10-
const {
11-
context: { interactions },
12-
} = useChat();
137

148
return (
159
<Input
@@ -18,10 +12,8 @@ export const ChatInput: FC = () => {
1812
t('components.search.suggestionTwo'),
1913
t('components.search.suggestionThree'),
2014
]}
21-
showSuggestions={!!interactions?.length}
2215
placeholder={t('components.search.chatPlaceholder')}
23-
>
24-
<small>{t('components.search.disclaimer')}</small>
25-
</Input>
16+
disclaimer={t('components.search.disclaimer')}
17+
/>
2618
);
2719
};

apps/site/components/Common/Searchbox/SearchResults/index.tsx renamed to apps/site/components/Common/Searchbox/SearchResults.tsx

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
'use client';
22

33
import SearchResultsComponent from '@node-core/ui-components/Common/Search/Results';
4-
import { SearchResults } from '@orama/ui/components/SearchResults';
54
import { useTranslations } from 'next-intl';
65
import { type FC } from 'react';
76

87
import { DEFAULT_ORAMA_QUERY_PARAMS } from '#site/next.constants.mjs';
98
import { useSearchbox } from '#site/providers/searchboxProvider';
109

11-
import styles from './index.module.css';
12-
import type { Document } from '../DocumentLink';
13-
import { SearchItem } from '../SearchItem';
10+
import type { Document } from './DocumentLink';
11+
import { SearchItem } from './SearchItem';
1412

1513
export const SearchResultsWrapper: FC = () => {
1614
const t = useTranslations();
@@ -32,18 +30,11 @@ export const SearchResultsWrapper: FC = () => {
3230
tabIndex={isSearchMode ? 0 : -1}
3331
aria-hidden={!isSearchMode}
3432
>
35-
{group => (
36-
<div key={group.name} className={styles.searchResultsGroup}>
37-
<h2 className={styles.searchResultsGroupTitle}>{group.name}</h2>
38-
<SearchResults.GroupList group={group}>
39-
{hit => (
40-
<SearchItem
41-
document={hit.document as Document}
42-
mode={searchbox?.mode}
43-
/>
44-
)}
45-
</SearchResults.GroupList>
46-
</div>
33+
{hit => (
34+
<SearchItem
35+
document={hit.document as Document}
36+
mode={searchbox?.mode}
37+
/>
4738
)}
4839
</SearchResultsComponent>
4940
);

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

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

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,29 @@
33
import { PaperAirplaneIcon } from '@heroicons/react/20/solid';
44
import { PauseCircleIcon } from '@heroicons/react/24/solid';
55
import { PromptTextArea, Suggestions } from '@orama/ui/components';
6+
import { useChat } from '@orama/ui/hooks';
67
import type { FC, PropsWithChildren } from 'react';
78
import { useEffect, useRef } from 'react';
89

910
import styles from './index.module.css';
1011

1112
type ChatInputProps = {
12-
showSuggestions: boolean;
1313
suggestions: Array<string>;
1414
placeholder: string;
15+
disclaimer: string;
1516
};
1617

1718
const ChatInput: FC<PropsWithChildren<ChatInputProps>> = ({
18-
showSuggestions,
1919
suggestions,
2020
placeholder,
21-
...props
21+
disclaimer,
2222
}) => {
2323
const textareaRef = useRef<HTMLTextAreaElement>(null);
2424

25+
const {
26+
context: { interactions },
27+
} = useChat();
28+
2529
useEffect(() => {
2630
const timeoutId = setTimeout(() => {
2731
textareaRef.current?.focus();
@@ -34,13 +38,10 @@ const ChatInput: FC<PropsWithChildren<ChatInputProps>> = ({
3438

3539
return (
3640
<>
37-
{showSuggestions && (
41+
{!!interactions?.length && (
3842
<Suggestions.Wrapper className={styles.suggestionsWrapper}>
3943
{suggestions.map(suggestion => (
40-
<Suggestions.Item
41-
className={styles.suggestionsItem}
42-
key={suggestion}
43-
>
44+
<Suggestions.Item className={styles.suggestionsItem}>
4445
{suggestion}
4546
</Suggestions.Item>
4647
))}
@@ -65,7 +66,9 @@ const ChatInput: FC<PropsWithChildren<ChatInputProps>> = ({
6566
<PaperAirplaneIcon />
6667
</PromptTextArea.Button>
6768
</PromptTextArea.Wrapper>
68-
<div className={styles.textareaFooter} {...props} />
69+
<div className={styles.textareaFooter}>
70+
<small>{disclaimer}</small>
71+
</div>
6972
</div>
7073
</>
7174
);

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,24 @@
7474
items-start
7575
overflow-y-auto;
7676
}
77+
78+
.searchResultsGroup {
79+
@apply mb-3
80+
border-t
81+
border-neutral-200
82+
dark:border-neutral-900;
83+
}
84+
85+
.searchResultsGroup:first-of-type {
86+
@apply border-0;
87+
}
88+
89+
.searchResultsGroupTitle {
90+
@apply mt-4
91+
mb-3
92+
pl-2
93+
text-sm
94+
font-semibold
95+
text-neutral-600
96+
dark:text-neutral-600;
97+
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type SearchResultsWrapperProps = {
1515
chatLabel: string;
1616
onChat: () => void;
1717
searchParams: Omit<ComponentProps<typeof Tabs>['searchParams'], 'term'>;
18-
children: ComponentProps<typeof SearchResults.GroupsWrapper>['children'];
18+
children: ComponentProps<typeof SearchResults.GroupList>['children'];
1919
} & ComponentProps<typeof SearchResultsEmpty>;
2020

2121
const SearchResultsWrapper: FC<SearchResultsWrapperProps> = ({
@@ -76,7 +76,14 @@ const SearchResultsWrapper: FC<SearchResultsWrapperProps> = ({
7676
className={styles.searchResultsGroupWrapper}
7777
groupBy="siteSection"
7878
>
79-
{children}
79+
{group => (
80+
<div key={group.name} className={styles.searchResultsGroup}>
81+
<h2 className={styles.searchResultsGroupTitle}>{group.name}</h2>
82+
<SearchResults.GroupList group={group}>
83+
{children}
84+
</SearchResults.GroupList>
85+
</div>
86+
)}
8087
</SearchResults.GroupsWrapper>
8188
</SearchResults.Wrapper>
8289
</div>

0 commit comments

Comments
 (0)