2021-12-20 03:12:12 +00:00
|
|
|
import clsx from 'clsx'
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
|
|
|
import { useUser } from '../hooks/use-user'
|
|
|
|
import { Row } from './layout/row'
|
|
|
|
import { firebaseLogin, User } from '../lib/firebase/users'
|
|
|
|
import { ManticLogo } from './mantic-logo'
|
|
|
|
import { ProfileMenu } from './profile-menu'
|
|
|
|
|
|
|
|
export function NavBar(props: {
|
|
|
|
darkBackground?: boolean
|
2021-12-20 04:37:11 +00:00
|
|
|
wide?: boolean
|
2021-12-20 03:12:12 +00:00
|
|
|
className?: string
|
|
|
|
children?: any
|
|
|
|
}) {
|
2021-12-20 04:37:11 +00:00
|
|
|
const { darkBackground, wide, className, children } = props
|
2021-12-20 03:12:12 +00:00
|
|
|
|
|
|
|
const user = useUser()
|
|
|
|
|
2021-12-20 04:06:30 +00:00
|
|
|
const hoverClasses =
|
|
|
|
'hover:underline hover:decoration-indigo-400 hover:decoration-2'
|
2021-12-20 03:12:12 +00:00
|
|
|
const themeClasses = clsx(darkBackground && 'text-white', hoverClasses)
|
|
|
|
|
|
|
|
return (
|
2021-12-31 19:31:41 +00:00
|
|
|
<nav className={clsx('w-full p-4 mb-4', className)} aria-label="Global">
|
2021-12-20 04:37:11 +00:00
|
|
|
<Row
|
|
|
|
className={clsx(
|
2021-12-20 05:15:18 +00:00
|
|
|
'justify-between items-center mx-auto sm:px-4',
|
2021-12-20 04:37:11 +00:00
|
|
|
wide ? 'max-w-7xl' : 'max-w-4xl'
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<ManticLogo darkBackground={darkBackground} />
|
2021-12-20 03:12:12 +00:00
|
|
|
|
2021-12-20 04:37:11 +00:00
|
|
|
<Row className="items-center gap-6 sm:gap-8 md:ml-16 lg:ml-40">
|
|
|
|
{children}
|
2021-12-20 03:12:12 +00:00
|
|
|
|
2021-12-20 04:37:11 +00:00
|
|
|
{user ? (
|
|
|
|
<SignedInHeaders user={user} themeClasses={themeClasses} />
|
|
|
|
) : (
|
|
|
|
<SignedOutHeaders themeClasses={themeClasses} />
|
|
|
|
)}
|
|
|
|
</Row>
|
2021-12-20 03:12:12 +00:00
|
|
|
</Row>
|
|
|
|
</nav>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function SignedInHeaders(props: { user: User; themeClasses?: string }) {
|
|
|
|
const { user, themeClasses } = props
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Link href="/about">
|
|
|
|
<a
|
|
|
|
className={clsx(
|
|
|
|
'text-base hidden md:block whitespace-nowrap',
|
|
|
|
themeClasses
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
About
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
<Link href="/create">
|
|
|
|
<a
|
|
|
|
className={clsx(
|
|
|
|
'text-base hidden md:block whitespace-nowrap',
|
|
|
|
themeClasses
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
Create a market
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
<ProfileMenu user={user} />
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function SignedOutHeaders(props: { themeClasses?: string }) {
|
|
|
|
const { themeClasses } = props
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div
|
|
|
|
className={clsx(
|
|
|
|
'text-base font-medium cursor-pointer whitespace-nowrap',
|
|
|
|
themeClasses
|
|
|
|
)}
|
|
|
|
onClick={firebaseLogin}
|
|
|
|
>
|
|
|
|
Sign in
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|