import {flip, offset, shift, useFloating} from '@floating-ui/react'
import {Popover, PopoverButton, PopoverPanel} from '@headlessui/react'
import {EllipsisHorizontalIcon} from '@heroicons/react/24/solid'
import clsx from 'clsx'
import {ReactNode} from 'react'
import {AnimationOrNothing} from 'web/components/comments/dropdown-menu'
import {Col} from 'web/components/layout/col'
export default function DropdownMenu(props: {
items: ReactNode[]
icon?: ReactNode
menuWidth?: string
buttonClass?: string
className?: string
menuItemsClass?: string
buttonDisabled?: boolean
withinOverflowContainer?: boolean
buttonContent?: (open: boolean) => ReactNode
}) {
const {
items,
menuItemsClass,
menuWidth,
buttonClass,
className,
buttonDisabled,
withinOverflowContainer,
buttonContent,
} = props
const {refs, floatingStyles} = useFloating({
strategy: withinOverflowContainer ? 'fixed' : 'absolute',
middleware: [offset(8), flip(), shift({padding: 8})],
})
const icon = props.icon ??
return (
{({open}) => (
<>
) => e.stopPropagation()}
disabled={buttonDisabled}
>
Open options
{buttonContent ? buttonContent(open) : icon}
{items}
>
)}
)
}