-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathComment.tsx
More file actions
69 lines (61 loc) · 1.65 KB
/
Comment.tsx
File metadata and controls
69 lines (61 loc) · 1.65 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { useRef } from 'react';
import { Stack, Typography } from '@mui/material';
import { buildCommentContainerDataCy } from '@/config/selectors';
import ChatbotAvatar from './ChatbotAvatar';
import CommentBody from './CommentBody';
import CustomAvatar from './CustomAvatar';
type Props = {
id: string;
body: string;
name: string;
avatar?: Blob;
};
export function Comment({ id, body, name }: Readonly<Props>): JSX.Element {
const commentRef = useRef<HTMLDivElement>(null);
return (
<Stack data-cy={buildCommentContainerDataCy(id)} ref={commentRef}>
<Stack
direction="row-reverse"
alignItems="end"
justifyContent="end"
gap={1}
pl={10}
>
<Stack>
<CustomAvatar username={name} />
</Stack>
<Stack sx={{ py: 0 }} alignItems="end" gap={1}>
<Typography variant="subtitle2">{name}</Typography>
<CommentBody background={'#ddd'}>{body}</CommentBody>
</Stack>
</Stack>
</Stack>
);
}
export function BotComment({
id,
body,
name,
avatar,
}: Readonly<Props>): JSX.Element {
const commentRef = useRef<HTMLDivElement>(null);
return (
<Stack data-cy={buildCommentContainerDataCy(id)} ref={commentRef}>
<Stack
direction="row"
alignItems="end"
justifyContent="start"
gap={1}
pr={10}
>
<Stack>
<ChatbotAvatar size="small" avatar={avatar} />
</Stack>
<Stack sx={{ py: 0 }} alignItems="start" gap={1}>
<Typography variant="subtitle2">{name}</Typography>
<CommentBody>{body}</CommentBody>
</Stack>
</Stack>
</Stack>
);
}