import { useEffect, useState } from 'react' import { Menu } from '@headlessui/react' import styled from '@emotion/styled' import { ChevronUpIcon, ChevronDownIcon, DuplicateIcon, LogoutIcon, } from '@heroicons/react/outline' import ConnectWalletButton from './ConnectWalletButton' import WalletIcon from './WalletIcon' import useWalletStore from '../stores/useWalletStore' const Code = styled.code` border: 1px solid hsla(0, 0%, 39.2%, 0.2); border-radius: 3px; background: hsla(0, 0%, 58.8%, 0.1); font-size: 13px; ` const WALLET_OPTIONS = [ { name: 'Copy address', icon: }, { name: 'Disconnect', icon: }, ] const TopBar = () => { const { connected, current: wallet } = useWalletStore((s) => s) const [isCopied, setIsCopied] = useState(false) useEffect(() => { if (isCopied) { const timer = setTimeout(() => { setIsCopied(false) }, 2000) return () => clearTimeout(timer) } }, [isCopied]) const handleWalletMenu = (option) => { if (option === 'Copy address') { const el = document.createElement('textarea') el.value = wallet.publicKey.toString() document.body.appendChild(el) el.select() document.execCommand('copy') document.body.removeChild(el) setIsCopied(true) } else { wallet.disconnect() } } return ( ) } export default TopBar