forked from LAION-AI/Open-Assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExplain.tsx
37 lines (35 loc) · 878 Bytes
/
Explain.tsx
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
import {
IconButton,
Popover,
PopoverArrow,
PopoverBody,
PopoverCloseButton,
PopoverContent,
PopoverTrigger,
Text,
} from "@chakra-ui/react";
import { Info } from "lucide-react";
import { ReactElement } from "react";
interface ExplainProps {
explanation: ReactElement[] | string[];
}
export const Explain = ({ explanation }: ExplainProps) => {
return (
<Popover>
<PopoverTrigger>
<IconButton aria-label="explanation" variant="link" size="xs" icon={<Info size="16" />}></IconButton>
</PopoverTrigger>
<PopoverContent>
<PopoverArrow />
<PopoverCloseButton />
<PopoverBody>
{explanation.map((paragraph, idx) => (
<Text key={idx} mt={idx === 0 ? 0 : 3}>
{paragraph}
</Text>
))}
</PopoverBody>
</PopoverContent>
</Popover>
);
};