2023-02-22 06:12:17 +00:00
|
|
|
import React from "react";
|
2023-02-22 07:54:59 +00:00
|
|
|
|
2023-02-22 06:12:17 +00:00
|
|
|
import { Tooltip2 } from "@blueprintjs/popover2";
|
2023-02-10 12:32:18 +00:00
|
|
|
|
2023-02-22 07:54:59 +00:00
|
|
|
type Props = {
|
2023-02-22 06:12:17 +00:00
|
|
|
tooltipHeading?: string;
|
2023-05-17 07:28:01 +00:00
|
|
|
tooltipContent: string | JSX.Element;
|
|
|
|
triangle?: boolean;
|
2023-02-23 11:16:52 +00:00
|
|
|
position?:
|
|
|
|
| "top"
|
|
|
|
| "right"
|
|
|
|
| "bottom"
|
|
|
|
| "left"
|
|
|
|
| "auto"
|
|
|
|
| "auto-end"
|
|
|
|
| "auto-start"
|
|
|
|
| "bottom-left"
|
|
|
|
| "bottom-right"
|
|
|
|
| "left-bottom"
|
|
|
|
| "left-top"
|
|
|
|
| "right-bottom"
|
|
|
|
| "right-top"
|
|
|
|
| "top-left"
|
|
|
|
| "top-right";
|
2023-02-22 06:12:17 +00:00
|
|
|
children: JSX.Element;
|
2023-02-10 12:32:18 +00:00
|
|
|
disabled?: boolean;
|
2023-02-23 11:16:52 +00:00
|
|
|
className?: string;
|
2023-03-01 08:41:27 +00:00
|
|
|
theme?: "light" | "dark";
|
2023-02-10 12:32:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const Tooltip: React.FC<Props> = ({
|
2023-02-22 06:12:17 +00:00
|
|
|
tooltipHeading,
|
|
|
|
tooltipContent,
|
|
|
|
position = "top",
|
2023-02-10 12:32:18 +00:00
|
|
|
children,
|
|
|
|
disabled = false,
|
2023-02-23 11:16:52 +00:00
|
|
|
className = "",
|
2023-03-01 08:41:27 +00:00
|
|
|
theme = "light",
|
2023-05-17 07:28:01 +00:00
|
|
|
triangle,
|
2023-02-22 07:54:59 +00:00
|
|
|
}) => (
|
|
|
|
<Tooltip2
|
|
|
|
disabled={disabled}
|
|
|
|
content={
|
2023-02-23 11:16:52 +00:00
|
|
|
<div
|
2023-06-23 11:50:05 +00:00
|
|
|
className={`${className} relative z-50 flex max-w-[600px] flex-col items-start justify-center gap-1 rounded-md p-2 text-left text-xs shadow-md ${
|
2023-07-10 07:17:00 +00:00
|
|
|
theme === "light" ? "text-custom-text-200 bg-custom-background-80" : "bg-black text-white"
|
2023-03-01 08:41:27 +00:00
|
|
|
}`}
|
2023-02-23 11:16:52 +00:00
|
|
|
>
|
2023-03-01 08:41:27 +00:00
|
|
|
{tooltipHeading && <h5 className="font-medium">{tooltipHeading}</h5>}
|
2023-05-17 07:28:01 +00:00
|
|
|
{tooltipContent}
|
2023-02-22 07:54:59 +00:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
position={position}
|
2023-03-14 06:48:14 +00:00
|
|
|
renderTarget={({ isOpen: isTooltipOpen, ref: eleReference, ...tooltipProps }) =>
|
|
|
|
React.cloneElement(children, { ref: eleReference, ...tooltipProps, ...children.props })
|
2023-02-22 07:54:59 +00:00
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|