File size: 624 Bytes
f0ea27c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 (
    <>
      <a data-tooltip-id={id} tabIndex={0}>
        {props.children}
      </a>
      <ReactTooltip id={id} className="tooltip" place="top-end">
        {props.doc.map?.(
          (section: any, i: number) =>
            section.kind === "text" && <Markdown key={i}>{section.value}</Markdown>,
        ) ?? <Markdown>{props.doc}</Markdown>}
      </ReactTooltip>
    </>
  );
}