flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/apps/web/app/components/ui/tooltip.tsx

45 lines1,413 bytesCodeBlame
1import { Tooltip as Primitive } from "radix-ui";
2import type { ComponentProps } from "react";
3
4import { cn } from "../../lib/cn";
5
6// shadcn/ui's tooltip, styled with g1t's tokens. Each tooltip carries its
7// own provider, so one can be dropped in anywhere without setup.
8
9export function TooltipProvider({ delayDuration = 200, ...props }: ComponentProps<typeof Primitive.Provider>) {
10 return <Primitive.Provider delayDuration={delayDuration} {...props} />;
11}
12
13export function Tooltip(props: ComponentProps<typeof Primitive.Root>) {
14 return (
15 <TooltipProvider>
16 <Primitive.Root {...props} />
17 </TooltipProvider>
18 );
19}
20
21export const TooltipTrigger = Primitive.Trigger;
22
23export function TooltipContent({
24 className,
25 sideOffset = 6,
26 children,
27 ...props
28}: ComponentProps<typeof Primitive.Content>) {
29 return (
30 <Primitive.Portal>
31 <Primitive.Content
32 sideOffset={sideOffset}
33 className={cn(
34 "z-50 max-w-xs rounded-md border border-line-strong bg-raised px-2.5 py-1.5 text-xs text-fg shadow-lg shadow-black/40",
35 "origin-(--radix-tooltip-content-transform-origin) animate-pop-in data-[state=closed]:animate-pop-out motion-reduce:animate-none",
36 className,
37 )}
38 {...props}
39 >
40 {children}
41 <Primitive.Arrow className="fill-raised" width={10} height={5} />
42 </Primitive.Content>
43 </Primitive.Portal>
44 );
45}