mango-ui-v3/components/TopBar.tsx

97 lines
3.3 KiB
TypeScript
Raw Normal View History

2021-07-23 07:07:05 -07:00
import { useCallback, useState } from 'react'
2021-09-01 07:30:34 -07:00
import Link from 'next/link'
2021-07-23 07:07:05 -07:00
import { abbreviateAddress } from '../utils/index'
import MenuItem from './MenuItem'
2021-04-12 06:32:01 -07:00
import ThemeSwitch from './ThemeSwitch'
2021-04-14 15:46:36 -07:00
import useMangoStore from '../stores/useMangoStore'
import ConnectWalletButton from './ConnectWalletButton'
import NavDropMenu from './NavDropMenu'
2021-07-23 07:07:05 -07:00
import AccountsModal from './AccountsModal'
2021-09-03 05:11:21 -07:00
import MobileMenu from './mobile/MobileMenu'
const TopBar = () => {
2021-07-23 07:07:05 -07:00
const mangoAccount = useMangoStore((s) => s.selectedMangoAccount.current)
const [showAccountsModal, setShowAccountsModal] = useState(false)
const handleCloseAccounts = useCallback(() => {
setShowAccountsModal(false)
}, [])
return (
<>
<nav className={`bg-th-bkg-2 border-b border-th-bkg-2`}>
<div className={`px-6 md:px-9`}>
<div className={`flex justify-between h-14`}>
<div className={`flex`}>
2021-09-01 07:30:34 -07:00
<Link href="/spot/BTC">
<div
className={`cursor-pointer flex-shrink-0 flex items-center`}
>
<img
className={`h-8 w-auto`}
src="/assets/icons/logo.svg"
alt="next"
/>
</div>
</Link>
<div
2021-07-06 21:34:21 -07:00
className={`hidden md:flex md:items-center md:space-x-6 md:ml-4`}
>
2021-07-18 07:17:52 -07:00
<MenuItem href="/spot/BTC">Trade</MenuItem>
2021-07-05 11:21:57 -07:00
<MenuItem href="/account">Account</MenuItem>
<MenuItem href="/borrow">Borrow</MenuItem>
2021-07-23 07:07:05 -07:00
<MenuItem href="/stats">Stats</MenuItem>
2021-08-16 11:20:19 -07:00
<MenuItem href="https://docs.mango.markets/" newWindow>
Learn
</MenuItem>
<NavDropMenu
menuTitle="More"
// linksArray: [name: string, href: string, isExternal: boolean]
linksArray={[
['Mango v1', 'https://usdt.mango.markets', true],
2021-08-31 10:47:03 -07:00
['Mango v2', 'https://v2.mango.markets', true],
]}
/>
</div>
</div>
2021-04-19 06:45:59 -07:00
<div className="flex items-center">
<div className={`pl-2`}>
2021-04-19 06:45:59 -07:00
<ThemeSwitch />
</div>
2021-07-23 07:07:05 -07:00
{mangoAccount ? (
<div className="pl-3">
2021-07-29 06:19:32 -07:00
<button
className="border border-th-bkg-4 py-1 px-2 rounded text-xs focus:outline-none hover:border-th-fgd-4"
2021-07-23 07:07:05 -07:00
onClick={() => setShowAccountsModal(true)}
>
<div className="font-normal text-th-primary tiny-text">
Account
</div>
{mangoAccount.name
? mangoAccount.name
: abbreviateAddress(mangoAccount.publicKey)}
2021-07-29 06:19:32 -07:00
</button>
2021-07-23 07:07:05 -07:00
</div>
) : null}
<div className="flex">
2021-07-23 07:07:05 -07:00
<div className="hidden md:block pl-3">
2021-08-20 08:05:05 -07:00
<ConnectWalletButton />
</div>
</div>
2021-09-01 07:30:34 -07:00
<MobileMenu />
2021-04-11 14:25:01 -07:00
</div>
</div>
</div>
</nav>
2021-07-23 07:07:05 -07:00
{showAccountsModal ? (
<AccountsModal
onClose={handleCloseAccounts}
isOpen={showAccountsModal}
/>
) : null}
</>
)
}
export default TopBar