| 1 | import { Popover as Primitive } from "radix-ui"; |
| 2 | import type { ComponentProps } from "react"; |
| 3 | |
| 4 | import { cn } from "../../lib/cn"; |
| 5 | |
| 6 | // shadcn/ui's popover, styled with g1t's tokens. |
| 7 | |
| 8 | export const Popover = Primitive.Root; |
| 9 | export const PopoverTrigger = Primitive.Trigger; |
| 10 | export const PopoverAnchor = Primitive.Anchor; |
| 11 | export const PopoverClose = Primitive.Close; |
| 12 | |
| 13 | export function PopoverContent({ |
| 14 | className, |
| 15 | align = "center", |
| 16 | sideOffset = 6, |
| 17 | ...props |
| 18 | }: ComponentProps<typeof Primitive.Content>) { |
| 19 | return ( |
| 20 | <Primitive.Portal> |
| 21 | <Primitive.Content |
| 22 | align={align} |
| 23 | sideOffset={sideOffset} |
| 24 | className={cn( |
| 25 | "z-50 w-72 max-w-[calc(100vw-2rem)] rounded-lg border border-line-strong bg-raised p-4 text-sm text-fg shadow-xl shadow-black/40 outline-none", |
| 26 | "origin-(--radix-popover-content-transform-origin) data-[state=open]:animate-pop-in data-[state=closed]:animate-pop-out motion-reduce:animate-none", |
| 27 | className, |
| 28 | )} |
| 29 | {...props} |
| 30 | /> |
| 31 | </Primitive.Portal> |
| 32 | ); |
| 33 | } |