2021-09-01 07:30:34 -07:00
|
|
|
import { useState } from 'react'
|
2021-09-01 22:04:09 -07:00
|
|
|
import { Transition } from '@headlessui/react'
|
2021-09-01 07:30:34 -07:00
|
|
|
import { MenuIcon, XIcon } from '@heroicons/react/outline'
|
2021-09-03 05:11:21 -07:00
|
|
|
import MenuItem from '../MenuItem'
|
|
|
|
import ConnectWalletButton from '../ConnectWalletButton'
|
|
|
|
import { IconButton } from '../Button'
|
2021-10-20 05:42:40 -07:00
|
|
|
import { useTranslation } from 'next-i18next'
|
2021-09-01 07:30:34 -07:00
|
|
|
|
|
|
|
const MobileMenu = () => {
|
2021-10-20 05:42:40 -07:00
|
|
|
const { t } = useTranslation('common')
|
2021-09-01 07:30:34 -07:00
|
|
|
const [showMenu, setShowMenu] = useState(false)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<IconButton
|
|
|
|
aria-controls="mobile-menu"
|
|
|
|
aria-expanded="false"
|
|
|
|
className="md:hidden ml-2"
|
|
|
|
onClick={() => setShowMenu((showMenu) => !showMenu)}
|
|
|
|
>
|
|
|
|
<span className="sr-only">Open main menu</span>
|
|
|
|
<MenuIcon className="h-5 w-5" />
|
|
|
|
</IconButton>
|
2021-09-01 22:04:09 -07:00
|
|
|
<Transition
|
|
|
|
appear={true}
|
|
|
|
show={showMenu}
|
|
|
|
enter="transition ease-in-out duration-500 transform"
|
|
|
|
enterFrom="translate-x-full"
|
|
|
|
enterTo="translate-x-0"
|
|
|
|
leave="transition ease-in-out duration-500 transform"
|
|
|
|
leaveFrom="translate-x-0"
|
|
|
|
leaveTo="translate-x-full"
|
|
|
|
className={`md:hidden fixed h-full right-0 top-0 w-[96%] bg-th-bkg-2 space-y-1 z-20`}
|
|
|
|
>
|
|
|
|
<div className="bg-th-bkg-3 flex h-14 items-center justify-between px-4">
|
|
|
|
<IconButton className="block" onClick={() => setShowMenu(false)}>
|
|
|
|
<XIcon className="h-5 w-5" />
|
|
|
|
</IconButton>
|
|
|
|
<ConnectWalletButton />
|
|
|
|
</div>
|
|
|
|
<div className="p-6">
|
2021-11-14 10:37:02 -08:00
|
|
|
<MenuItem href="/market?name=BTC/USDC">{t('trade')}</MenuItem>
|
2021-10-20 05:42:40 -07:00
|
|
|
<MenuItem href="/account">{t('account')}</MenuItem>
|
|
|
|
<MenuItem href="/borrow">{t('borrow')}</MenuItem>
|
|
|
|
<MenuItem href="/stats">{t('stats')}</MenuItem>
|
2022-01-03 16:20:45 -08:00
|
|
|
<MenuItem href="/risk-calculator">{t('calculator')}</MenuItem>
|
2021-10-20 05:42:40 -07:00
|
|
|
<MenuItem href="https://docs.mango.markets/">{t('learn')}</MenuItem>
|
2021-09-01 07:30:34 -07:00
|
|
|
</div>
|
2021-09-01 22:04:09 -07:00
|
|
|
</Transition>
|
2021-09-01 07:30:34 -07:00
|
|
|
<div
|
|
|
|
className={`${
|
|
|
|
showMenu ? `visible` : `hidden`
|
|
|
|
} md:hidden fixed right-0 top-0 h-full w-full bg-[rgba(0,0,0,0.4)] p-6 z-10`}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MobileMenu
|