import { styled } from 'stitches.config' import React, { ComponentPropsWithoutRef, ElementRef, forwardRef, ReactNode, useState, } from 'react' import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu' import { AnimatePresence, motion } from 'framer-motion' const DropdownMenuContent = styled(DropdownMenuPrimitive.DropdownMenuContent, { mx: '$4', p: '$2', borderRadius: 8, zIndex: 5, background: '$dropdownBg', $$borderColor: '$colors$gray7', boxShadow: '0 0 0 1px $$borderColor', }) const AnimatedDropdownMenuContent = forwardRef< ElementRef, ComponentPropsWithoutRef >(({ children, ...props }, forwardedRef) => ( {children} )) const DropdownMenuItem = styled(DropdownMenuPrimitive.DropdownMenuItem, { fontSize: 16, fontFamily: '$body', color: '$gray12', px: '$2', py: '$4', borderRadius: 8, outline: 'none', cursor: 'pointer', '&:hover': { backgroundColor: '$gray5', }, '&:focus': { backgroundColor: '$gray5', }, }) type Props = { trigger: ReactNode contentProps?: DropdownMenuPrimitive.DropdownMenuContentProps } const Dropdown = forwardRef< ElementRef, ComponentPropsWithoutRef & Props >(({ children, trigger, contentProps, ...props }, forwardedRef) => { const [open, setOpen] = useState(false) return ( {trigger} {open && ( {children} )} ) }) export { Dropdown, DropdownMenuContent, DropdownMenuItem }