import { Story, Meta } from '@storybook/react' import { useCallback, useRef, useState } from 'react' import { Button } from '@lidofinance/button' import { PopupMenuProps, PopupMenuVariant } from './types' import { Eth, Steth, Solana } from '@lidofinance/icons' import PopupMenu from './PopupMenu' import PopupMenuItem from './PopupMenuItem' const getOptions = (enumObject: Record) => Object.values(enumObject).filter((value) => typeof value === 'string') export default { component: PopupMenu, title: 'Dialogs/PopupMenu', args: { variant: 'default', }, argTypes: { variant: { options: getOptions(PopupMenuVariant), control: 'inline-radio', }, }, } as Meta const usePopup = (props: PopupMenuProps) => { const { onClose } = props const [state, setState] = useState(false) const anchorRef = useRef(null) const handleOpen = useCallback(() => { setState(true) }, []) const handleClose = useCallback(() => { setState(false) onClose?.() }, [onClose]) return { state, anchorRef, handleOpen, handleClose, } } export const Basic: Story = (props) => { const { state, anchorRef, handleOpen, handleClose } = usePopup(props) return ( <> Ethereum (ETH) Lido (STETH) Solana (SOL) ) } export const Icons: Story = (props) => { const { state, anchorRef, handleOpen, handleClose } = usePopup(props) return ( <> }> Ethereum (ETH) }> Lido (STETH) }> Solana (SOL) ) } export const WithDisabled: Story = (props) => { const { state, anchorRef, handleOpen, handleClose } = usePopup(props) return ( <> Ethereum (ETH) Lido (STETH) Solana (SOL) ) }