-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathindex.tsx
More file actions
48 lines (42 loc) · 1.4 KB
/
index.tsx
File metadata and controls
48 lines (42 loc) · 1.4 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
'use client';
import { ArrowDownIcon } from '@heroicons/react/24/solid';
import { ChatInteractions } from '@orama/ui/components';
import { useScrollableContainer } from '@orama/ui/hooks/useScrollableContainer';
import { useTranslations } from 'next-intl';
import type { Interaction } from '@orama/core';
import { ChatMessage } from '../ChatMessage';
import styles from './index.module.css';
export const ChatInteractionsContainer = () => {
const t = useTranslations();
const {
containerRef,
scrollToBottom,
recalculateGoToBottomButton,
showGoToBottomButton,
} = useScrollableContainer();
return (
<>
<div ref={containerRef} className={styles.chatInteractionsContainer}>
<ChatInteractions.Wrapper
onScroll={recalculateGoToBottomButton}
onStreaming={recalculateGoToBottomButton}
onNewInteraction={() => scrollToBottom({ animated: true })}
className={styles.chatInteractionsWrapper}
>
{(interaction: Interaction) => (
<ChatMessage interaction={interaction} />
)}
</ChatInteractions.Wrapper>
</div>
{showGoToBottomButton && (
<button
onClick={() => scrollToBottom({ animated: true })}
className={styles.scrollDownButton}
aria-label={t('components.search.scrollToBottom')}
>
<ArrowDownIcon />
</button>
)}
</>
);
};