forked from github/plane
8a95a41100
Co-authored-by: Bavisetti Narayan <72156168+NarayanBavisetti@users.noreply.github.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: Bavisetti Narayan <narayan@Bavisettis-MacBook-Pro.local> Co-authored-by: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Co-authored-by: M. Palanikannan <73993394+Palanikannan1437@users.noreply.github.com> Co-authored-by: Lakhan Baheti <94619783+1akhanBaheti@users.noreply.github.com> Co-authored-by: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Co-authored-by: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com>
72 lines
1.7 KiB
TypeScript
72 lines
1.7 KiB
TypeScript
import React from "react";
|
|
|
|
// next-themes
|
|
import { useTheme } from "next-themes";
|
|
// tooltip2
|
|
import { Tooltip2 } from "@blueprintjs/popover2";
|
|
|
|
type Props = {
|
|
tooltipHeading?: string;
|
|
tooltipContent: string | React.ReactNode;
|
|
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";
|
|
children: JSX.Element;
|
|
disabled?: boolean;
|
|
className?: string;
|
|
openDelay?: number;
|
|
closeDelay?: number;
|
|
};
|
|
|
|
export const Tooltip: React.FC<Props> = ({
|
|
tooltipHeading,
|
|
tooltipContent,
|
|
position = "top",
|
|
children,
|
|
disabled = false,
|
|
className = "",
|
|
openDelay = 200,
|
|
closeDelay,
|
|
}) => {
|
|
const { theme } = useTheme();
|
|
|
|
return (
|
|
<Tooltip2
|
|
disabled={disabled}
|
|
hoverOpenDelay={openDelay}
|
|
hoverCloseDelay={closeDelay}
|
|
content={
|
|
<div
|
|
className={`relative z-50 max-w-xs gap-1 rounded-md p-2 text-xs shadow-md border border-custom-border-200 ${
|
|
theme === "custom" ? "bg-custom-background-100 text-custom-text-200" : "bg-black text-gray-400"
|
|
} break-words overflow-hidden ${className}`}
|
|
>
|
|
{tooltipHeading && (
|
|
<h5 className={`font-medium ${theme === "custom" ? "text-custom-text-100" : "text-white"}`}>
|
|
{tooltipHeading}
|
|
</h5>
|
|
)}
|
|
{tooltipContent}
|
|
</div>
|
|
}
|
|
position={position}
|
|
renderTarget={({ isOpen: isTooltipOpen, ref: eleReference, ...tooltipProps }) =>
|
|
React.cloneElement(children, { ref: eleReference, ...tooltipProps, ...children.props })
|
|
}
|
|
/>
|
|
);
|
|
};
|