forked from Weaverse/pilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tooltip.tsx
49 lines (46 loc) · 1.21 KB
/
tooltip.tsx
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
44
45
46
47
48
49
import type {
TooltipContentProps,
TooltipProps,
TooltipTriggerProps,
} from "@radix-ui/react-tooltip";
import {
Arrow,
Content,
Provider,
Root,
Trigger,
} from "@radix-ui/react-tooltip";
import { forwardRef } from "react";
import { cn } from "~/lib/cn";
export let TooltipProvider = Provider;
export let Tooltip = ({ delayDuration = 100, ...rest }: TooltipProps) => (
<Root delayDuration={delayDuration} {...rest} />
);
export let TooltipTrigger = ({
asChild = true,
...rest
}: TooltipTriggerProps) => <Trigger asChild={asChild} {...rest} />;
export let TooltipContent = forwardRef<HTMLDivElement, TooltipContentProps>(
({ children, className, sideOffset = 4, ...rest }, ref) => {
return (
<Content
ref={ref}
className={cn(
"animate-slide-down-and-fade",
"z-50 px-4 rounded py-1 shadow-sm text-background bg-body opacity-0",
className,
)}
align="center"
side="top"
sideOffset={sideOffset}
collisionPadding={8}
{...rest}
>
<Arrow asChild>
<span className="border-x-6 border-t-6 border-x-transparent border-t-body" />
</Arrow>
{children}
</Content>
);
},
);