From e2b03f31e91ff6a9d4a09b5657ab9380b2b5d775 Mon Sep 17 00:00:00 2001 From: Sinclair Chen Date: Wed, 18 May 2022 15:45:08 -0400 Subject: [PATCH] Style current page on mobile nav bar --- web/components/nav/nav-bar.tsx | 85 ++++++++++++++++++++-------------- web/components/nav/sidebar.tsx | 2 +- 2 files changed, 50 insertions(+), 37 deletions(-) diff --git a/web/components/nav/nav-bar.tsx b/web/components/nav/nav-bar.tsx index 987e3142..fcf45d4f 100644 --- a/web/components/nav/nav-bar.tsx +++ b/web/components/nav/nav-bar.tsx @@ -10,54 +10,49 @@ import { } from '@heroicons/react/outline' import { Transition, Dialog } from '@headlessui/react' import { useState, Fragment } from 'react' -import Sidebar from './sidebar' +import Sidebar, { Item } from './sidebar' import { useUser } from 'web/hooks/use-user' import { formatMoney } from 'common/util/format' import { Avatar } from '../avatar' +import clsx from 'clsx' +import { useRouter } from 'next/router' + +function getNavigation(username: String) { + return [ + { name: 'Home', href: '/home', icon: HomeIcon }, + { name: 'Activity', href: '/activity', icon: ChatAltIcon }, + { + name: 'Portfolio', + href: `/${username}/bets`, + icon: PresentationChartLineIcon, + }, + ] +} + +const signedOutNavigation = [ + { name: 'Home', href: '/', icon: HomeIcon }, + { name: 'Explore', href: '/markets', icon: SearchIcon }, +] // From https://codepen.io/chris__sev/pen/QWGvYbL export function BottomNavBar() { const [sidebarOpen, setSidebarOpen] = useState(false) + const router = useRouter() + const currentPage = router.pathname + const user = useUser() + const navigationOptions = + user === null + ? signedOutNavigation + : getNavigation(user?.username || 'error') + return (