2021-08-07 12:02:01 +00:00
|
|
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
2021-09-22 19:52:38 +00:00
|
|
|
import React from "react";
|
2021-08-07 12:02:01 +00:00
|
|
|
|
2022-07-14 11:32:28 +00:00
|
|
|
import classNames from "@calcom/lib/classNames";
|
|
|
|
|
2021-08-07 12:02:01 +00:00
|
|
|
export function Tooltip({
|
|
|
|
children,
|
2022-07-14 11:32:28 +00:00
|
|
|
side,
|
2021-08-07 12:02:01 +00:00
|
|
|
content,
|
|
|
|
open,
|
|
|
|
defaultOpen,
|
|
|
|
onOpenChange,
|
|
|
|
...props
|
|
|
|
}: {
|
|
|
|
children: React.ReactNode;
|
|
|
|
content: React.ReactNode;
|
2021-09-24 15:03:28 +00:00
|
|
|
open?: boolean;
|
2022-07-14 11:32:28 +00:00
|
|
|
side?: "top" | "right" | "bottom" | "left" | undefined;
|
2021-09-24 15:03:28 +00:00
|
|
|
defaultOpen?: boolean;
|
|
|
|
onOpenChange?: (open: boolean) => void;
|
2021-08-07 12:02:01 +00:00
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<TooltipPrimitive.Root
|
2022-04-29 17:17:34 +00:00
|
|
|
delayDuration={50}
|
2021-08-07 12:02:01 +00:00
|
|
|
open={open}
|
|
|
|
defaultOpen={defaultOpen}
|
|
|
|
onOpenChange={onOpenChange}>
|
2021-09-14 08:20:24 +00:00
|
|
|
<TooltipPrimitive.Trigger asChild>{children}</TooltipPrimitive.Trigger>
|
2021-08-07 12:02:01 +00:00
|
|
|
<TooltipPrimitive.Content
|
2022-07-14 11:32:28 +00:00
|
|
|
className={classNames(
|
|
|
|
side === "top" && "-mt-2",
|
|
|
|
side === "right" && "ml-2",
|
|
|
|
"rounded-sm bg-black px-1 py-0.5 text-xs text-white shadow-lg"
|
|
|
|
)}
|
|
|
|
side={side}
|
2021-08-07 12:02:01 +00:00
|
|
|
align="center"
|
|
|
|
{...props}>
|
|
|
|
{content}
|
|
|
|
</TooltipPrimitive.Content>
|
|
|
|
</TooltipPrimitive.Root>
|
|
|
|
);
|
|
|
|
}
|
2022-05-06 21:59:15 +00:00
|
|
|
|
|
|
|
export default Tooltip;
|