@@ -5,9 +5,10 @@ import { EllipsisVerticalIcon } from "@heroicons/react/24/solid";
55import * as PopoverPrimitive from "@radix-ui/react-popover" ;
66import * as React from "react" ;
77import { DropdownIcon } from "~/assets/icons/DropdownIcon" ;
8+ import { Link } from "@remix-run/react" ;
89import * as useShortcutKeys from "~/hooks/useShortcutKeys" ;
910import { cn } from "~/utils/cn" ;
10- import { type ButtonContentPropsType , Button , LinkButton } from "./Buttons" ;
11+ import { type ButtonContentPropsType , Button , ButtonContent } from "./Buttons" ;
1112import { Paragraph , type ParagraphVariant } from "./Paragraph" ;
1213import { ShortcutKey } from "./ShortcutKey" ;
1314import { type RenderIcon } from "./Icon" ;
@@ -52,55 +53,78 @@ function PopoverSectionHeader({
5253 ) ;
5354}
5455
55- function PopoverMenuItem ( {
56- to,
57- icon,
58- title,
59- isSelected,
60- variant = { variant : "small-menu-item" } ,
61- leadingIconClassName,
62- className,
63- onClick,
64- disabled,
65- } : {
66- to ?: string ;
67- icon ?: RenderIcon ;
68- title : React . ReactNode ;
69- isSelected ?: boolean ;
70- variant ?: ButtonContentPropsType ;
71- leadingIconClassName ?: string ;
72- className ?: string ;
73- onClick ?: React . MouseEventHandler ;
74- disabled ?: boolean ;
75- } ) {
76- const commonProps = {
77- variant : variant . variant ,
78- LeadingIcon : icon ,
79- leadingIconClassName,
80- fullWidth : true ,
81- textAlignLeft : true ,
82- TrailingIcon : isSelected ? CheckIcon : undefined ,
83- className : cn (
84- "group-hover:bg-charcoal-700" ,
85- isSelected ? "bg-charcoal-750 group-hover:bg-charcoal-600/50" : undefined ,
86- className
87- ) ,
88- } as const ;
56+ const PopoverMenuItem = React . forwardRef <
57+ HTMLButtonElement | HTMLAnchorElement ,
58+ {
59+ to ?: string ;
60+ icon ?: RenderIcon ;
61+ title : React . ReactNode ;
62+ isSelected ?: boolean ;
63+ variant ?: ButtonContentPropsType ;
64+ leadingIconClassName ?: string ;
65+ className ?: string ;
66+ onClick ?: React . MouseEventHandler ;
67+ disabled ?: boolean ;
68+ }
69+ > (
70+ (
71+ {
72+ to,
73+ icon,
74+ title,
75+ isSelected,
76+ variant = { variant : "small-menu-item" } ,
77+ leadingIconClassName,
78+ className,
79+ onClick,
80+ disabled,
81+ } ,
82+ ref
83+ ) => {
84+ const contentProps = {
85+ variant : variant . variant ,
86+ LeadingIcon : icon ,
87+ leadingIconClassName,
88+ fullWidth : true ,
89+ textAlignLeft : true ,
90+ TrailingIcon : isSelected ? CheckIcon : undefined ,
91+ className : cn (
92+ "group-hover:bg-charcoal-700" ,
93+ isSelected ? "bg-charcoal-750 group-hover:bg-charcoal-600/50" : undefined ,
94+ className
95+ ) ,
96+ } as const ;
97+
98+ if ( to ) {
99+ return (
100+ < Link
101+ to = { to }
102+ ref = { ref as React . Ref < HTMLAnchorElement > }
103+ className = { cn ( "group/button focus-custom" , contentProps . fullWidth ? "w-full" : "" ) }
104+ onClick = { onClick as any }
105+ >
106+ < ButtonContent { ...contentProps } > { title } </ ButtonContent >
107+ </ Link >
108+ ) ;
109+ }
89110
90- if ( to ) {
91111 return (
92- < LinkButton to = { to } { ...commonProps } onClick = { onClick } >
93- { title }
94- </ LinkButton >
112+ < button
113+ type = "button"
114+ ref = { ref as React . Ref < HTMLButtonElement > }
115+ onClick = { onClick }
116+ disabled = { disabled }
117+ className = { cn (
118+ "group/button outline-none focus-custom" ,
119+ contentProps . fullWidth ? "w-full" : ""
120+ ) }
121+ >
122+ < ButtonContent { ...contentProps } > { title } </ ButtonContent >
123+ </ button >
95124 ) ;
96125 }
97-
98- return (
99- < Button { ...commonProps } onClick = { onClick } disabled = { disabled } type = "button" >
100- { title }
101- </ Button >
102- ) ;
103- }
126+ ) ;
127+ PopoverMenuItem . displayName = "PopoverMenuItem" ;
104128
105129function PopoverCustomTrigger ( {
106130 isOpen,
0 commit comments