Spaces:
Running
Running
File size: 636 Bytes
d7943fc da1f2d0 d7943fc da1f2d0 502f722 d7943fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import { useId } from "react";
import Markdown from "react-markdown";
import { Tooltip as ReactTooltip } from "react-tooltip";
export default function Tooltip(props: any) {
const id = useId();
if (!props.doc) return null;
return (
<>
<span data-tooltip-id={id} tabIndex={0}>
{props.children}
</span>
<ReactTooltip id={id} className="tooltip prose" place="top-end">
{props.doc.map?.(
(section: any, i: number) =>
section.kind === "text" && <Markdown key={i}>{section.value}</Markdown>,
) ?? <Markdown>{props.doc}</Markdown>}
</ReactTooltip>
</>
);
}
|