Spaces:
Runtime error
Runtime error
File size: 1,359 Bytes
cd6f98e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import React from "react";
import type { toolTipProperties } from "../types";
interface TooltipProps {
child: React.ReactNode;
toolTipProperties?: toolTipProperties;
style?: { [key: string]: string };
sideOffset: number;
}
const Tooltip = ({
child,
toolTipProperties = { message: "", disabled: true },
style = { container: "" },
sideOffset,
}: TooltipProps) => {
const { message, disabled } = toolTipProperties;
return (
<div className={style?.container}>
<TooltipPrimitive.Provider>
<TooltipPrimitive.Root delayDuration={0}>
<TooltipPrimitive.Trigger asChild>{child}</TooltipPrimitive.Trigger>
{disabled ? null : (
<TooltipPrimitive.Portal>
<TooltipPrimitive.Content
className="will-change animation-transform user-select-none z-40 w-3/5 rounded-sm bg-black px-3.5 py-2.5 text-white shadow-lg "
sideOffset={sideOffset}
>
<span className="whitespace-pre-line">{message}</span>
<TooltipPrimitive.Arrow className="fill-black" />
</TooltipPrimitive.Content>
</TooltipPrimitive.Portal>
)}
</TooltipPrimitive.Root>
</TooltipPrimitive.Provider>
</div>
);
};
export default Tooltip;
|