diff --git a/apps/trading/components/navbar/navbar.tsx b/apps/trading/components/navbar/navbar.tsx index 28665a8bb..c8a7a6478 100644 --- a/apps/trading/components/navbar/navbar.tsx +++ b/apps/trading/components/navbar/navbar.tsx @@ -1,12 +1,13 @@ import classNames from 'classnames'; import { useRouter } from 'next/router'; import Link from 'next/link'; -import { NetworkSwitcher } from '@vegaprotocol/environment'; +import { NetworkSwitcher, useEnvironment } from '@vegaprotocol/environment'; import { t } from '@vegaprotocol/react-helpers'; import { useGlobalStore } from '../../stores/global'; import { VegaWalletConnectButton } from '../vega-wallet-connect-button'; import { ThemeSwitcher } from '@vegaprotocol/ui-toolkit'; import { Vega } from '../icons/vega'; +import type { HTMLAttributeAnchorTarget } from 'react'; import { useEffect, useState } from 'react'; interface NavbarProps { @@ -15,18 +16,21 @@ interface NavbarProps { } export const Navbar = ({ theme, toggleTheme }: NavbarProps) => { + const { VEGA_TOKEN_URL } = useEnvironment(); const { marketId } = useGlobalStore((store) => ({ marketId: store.marketId, })); const [tradingPath, setTradingPath] = useState('/markets'); + useEffect(() => { if (marketId) { setTradingPath(`/markets/${marketId}`); } }, [marketId]); + return (
-
+
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} @@ -35,13 +39,19 @@ export const Navbar = ({ theme, toggleTheme }: NavbarProps) => {
-
); @@ -51,23 +61,33 @@ interface NavLinkProps { name: string; path: string; testId?: string; + alignRight?: boolean; + target?: HTMLAttributeAnchorTarget; } -const NavLink = ({ name, path, testId = name }: NavLinkProps) => { +const NavLink = ({ + name, + path, + alignRight, + target, + testId = name, +}: NavLinkProps) => { const router = useRouter(); - const [isActive, setIsActive] = useState(false); - useEffect( - () => setIsActive(router.asPath.includes(path)), - [path, router.asPath] - ); - const linkClasses = classNames('mx-2 py-2 self-end border-b-4', { - 'border-vega-yellow text-white cursor-default': isActive, - 'border-transparent text-neutral-400 hover:text-neutral-300': !isActive, + const isActive = router.asPath?.includes(path); + const linkClasses = classNames('mx-2 py-3 self-end relative', { + 'text-white cursor-default': isActive, + 'text-neutral-400 hover:text-neutral-300': !isActive, + 'ml-auto': alignRight, }); return ( {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} - {name} + + {name} + {isActive && ( + + )} + ); };