Skip to content

Commit 773f990

Browse files
wip: fix popover
1 parent 3e6fbe0 commit 773f990

File tree

1 file changed

+26
-44
lines changed

1 file changed

+26
-44
lines changed

crowdsec-docs/src/ui/popover.tsx

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,29 @@
33
import * as React from "react"
44
import * as PopoverPrimitive from "@radix-ui/react-popover"
55

6-
import { cn } from "@site/src/utils"
7-
8-
function Popover({
9-
...props
10-
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
11-
return <PopoverPrimitive.Root data-slot="popover" {...props} />
12-
}
13-
14-
function PopoverTrigger({
15-
...props
16-
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
17-
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
18-
}
19-
20-
function PopoverContent({
21-
className,
22-
align = "center",
23-
sideOffset = 4,
24-
...props
25-
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
26-
return (
27-
<PopoverPrimitive.Portal>
28-
<PopoverPrimitive.Content
29-
data-slot="popover-content"
30-
align={align}
31-
sideOffset={sideOffset}
32-
className={cn(
33-
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
34-
className
35-
)}
36-
{...props}
37-
/>
38-
</PopoverPrimitive.Portal>
39-
)
40-
}
41-
42-
function PopoverAnchor({
43-
...props
44-
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
45-
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
46-
}
47-
48-
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
49-
6+
import { cn } from "@site/src/utils/index"
7+
8+
const Popover = PopoverPrimitive.Root
9+
10+
const PopoverTrigger = PopoverPrimitive.Trigger
11+
12+
const PopoverContent = React.forwardRef<
13+
React.ElementRef<typeof PopoverPrimitive.Content>,
14+
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
15+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
16+
<PopoverPrimitive.Portal>
17+
<PopoverPrimitive.Content
18+
ref={ref}
19+
align={align}
20+
sideOffset={sideOffset}
21+
className={cn(
22+
"tw-z-50 tw-w-72 tw-rounded-md tw-border tw-border-neutral-200 tw-bg-white tw-p-4 tw-text-neutral-950 tw-shadow-md tw-outline-none data-[state=open]:tw-animate-in data-[state=closed]:tw-animate-out data-[state=closed]:tw-fade-out-0 data-[state=open]:tw-fade-in-0 data-[state=closed]:tw-zoom-out-95 data-[state=open]:tw-zoom-in-95 data-[side=bottom]:tw-slide-in-from-top-2 data-[side=left]:tw-slide-in-from-right-2 data-[side=right]:tw-slide-in-from-left-2 data-[side=top]:tw-slide-in-from-bottom-2 tw-origin-[--radix-popover-content-transform-origin] dark:tw-border-neutral-800 dark:tw-bg-neutral-950 dark:tw-text-neutral-50",
23+
className
24+
)}
25+
{...props}
26+
/>
27+
</PopoverPrimitive.Portal>
28+
))
29+
PopoverContent.displayName = PopoverPrimitive.Content.displayName
30+
31+
export { Popover, PopoverTrigger, PopoverContent }

0 commit comments

Comments
 (0)