import './nav.css'; import classNames from 'classnames'; import debounce from 'lodash/debounce'; import React from 'react'; import * as Dialog from '@radix-ui/react-dialog'; import { useTranslation } from 'react-i18next'; import { Link, NavLink } from 'react-router-dom'; import { Flags } from '../../config'; import { AppStateActionType, useAppState, } from '../../contexts/app-state/app-state-context'; import vegaWhite from '../../images/vega_white.png'; import { Routes } from '../../routes/router-config'; import { EthWallet } from '../eth-wallet'; import { VegaWallet } from '../vega-wallet'; export const Nav = () => { const [windowWidth, setWindowWidth] = React.useState(window.innerWidth); const isDesktop = windowWidth > 959; const inverted = Flags.FAIRGROUND; React.useEffect(() => { const handleResizeDebounced = debounce(() => { setWindowWidth(window.innerWidth); }, 300); window.addEventListener('resize', handleResizeDebounced); return () => { window.removeEventListener('resize', handleResizeDebounced); }; }, []); return (
{isDesktop && }
{!isDesktop && }
{isDesktop ? ( ) : ( )}
); }; const NavHeader = ({ fairground }: { fairground: boolean }) => { const { t } = useTranslation(); return (
{fairground ? ( ) : ( Vega )}

{fairground ? t('fairgroundTitle') : t('title')}

); }; const DrawerSection = ({ children }: { children: React.ReactNode }) => (
{children}
); const IconLine = ({ inverted }: { inverted: boolean }) => ( ); const NavDrawer = ({ inverted }: { inverted: boolean }) => { const { appState, appDispatch } = useAppState(); const drawerContentClasses = classNames( 'drawer-content', // needed for css animation // Positions the modal in the center of screen 'fixed w-[80vw] max-w-[420px] top-0 right-0', 'flex flex-col flex-nowrap justify-between h-full bg-banner overflow-y-scroll border-l border-white', 'bg-black text-white-95' ); return ( <> appDispatch({ type: AppStateActionType.SET_DRAWER, isOpen, }) } >
); }; const NavLinks = ({ isDesktop }: { isDesktop: boolean }) => { const { appDispatch } = useAppState(); const { t } = useTranslation(); const linkProps = { onClick: () => appDispatch({ type: AppStateActionType.SET_DRAWER, isOpen: false }), }; const routes = [ { route: Routes.HOME, text: t('Home') }, { route: Routes.VESTING, text: t('Vesting') }, { route: Routes.STAKING, text: t('Staking') }, { route: Routes.REWARDS, text: t('Rewards') }, { route: Routes.WITHDRAW, text: t('Withdraw') }, { route: Routes.GOVERNANCE, text: t('Governance') }, ]; const navClasses = classNames('flex', { 'flex-row gap-8 mt-8 uppercase': isDesktop, 'flex-col': !isDesktop, }); return ( ); };