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;
|
|
|
|
tooltipContent: string;
|
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-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-02-22 07:54:59 +00:00
|
|
|
}) => (
|
|
|
|
<Tooltip2
|
|
|
|
disabled={disabled}
|
|
|
|
content={
|
2023-02-23 11:16:52 +00:00
|
|
|
<div
|
|
|
|
className={`flex flex-col justify-center items-start gap-1 max-w-[600px] text-xs rounded-md bg-white p-2 shadow-md capitalize text-left ${className}`}
|
|
|
|
>
|
2023-02-22 07:54:59 +00:00
|
|
|
{tooltipHeading ? (
|
|
|
|
<>
|
|
|
|
<h5 className="font-medium">{tooltipHeading}</h5>
|
2023-02-22 06:12:17 +00:00
|
|
|
<p className="text-gray-700">{tooltipContent}</p>
|
2023-02-22 07:54:59 +00:00
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<p className="text-gray-700">{tooltipContent}</p>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
position={position}
|
|
|
|
renderTarget={({ isOpen: isTooltipOpen, ref: eleRefernce, ...tooltipProps }) =>
|
|
|
|
React.cloneElement(children, { ref: eleRefernce, ...tooltipProps, ...children.props })
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|