Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MainMenuItem issue #369

Open
bxlkm opened this issue Dec 28, 2022 · 1 comment
Open

MainMenuItem issue #369

bxlkm opened this issue Dec 28, 2022 · 1 comment

Comments

@bxlkm
Copy link

bxlkm commented Dec 28, 2022

please help me!!!
How to do the navigation menu ?
MainMenuItem is none。
//
// <MainMenuItem
// icon={}
//>
// Stake
//
// <MainMenuItem
// active
// icon={}
// >
// Wrap
//
// <MainMenuItem
// icon={}
// >
// Wallet
//
//

@DiRaiks
Copy link
Contributor

DiRaiks commented Dec 28, 2022

@bxlkm Hello!
You can wrap MainMenuItem by MainMenu
And use React router to check the current path with useRouter hook in next.js (or useLocation in React.js).
You can find a simple example here - https://github.com/lidofinance/ui/blob/main/packages/main-menu/MainMenu.stories.tsx
Docs for next useRouter - https://nextjs.org/docs/api-reference/next/router
Docs for react useLocation - https://v5.reactrouter.com/web/api/Hooks/uselocation

This should be enough. If you have any questions - please let me know =)

const Component = () => {
  const router = useRouter();
  
  return (
    <MainMenu>
        <MainMenuItem active={router.pathname === '/stake'} icon={<Stake />}>
          Stake
        </MainMenuItem>
        <MainMenuItem active={router.pathname === '/wrap'} icon={<Wrap />}>
          Wrap
        </MainMenuItem>
        <MainMenuItem active={router.pathname === '/wallet'} icon={<Wallet />}>
          Wallet
        </MainMenuItem>
    </MainMenu>
  )
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants