Tidy up some dead code and markup in sidebar (#842)
This commit is contained in:
parent
b1bb6fab5b
commit
a429a98a29
|
@ -1,27 +1,13 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import clsx from 'clsx'
|
|
||||||
|
|
||||||
import { User } from 'web/lib/firebase/users'
|
|
||||||
import { Button } from './button'
|
import { Button } from './button'
|
||||||
|
|
||||||
export const CreateQuestionButton = (props: {
|
export const CreateQuestionButton = () => {
|
||||||
user: User | null | undefined
|
|
||||||
overrideText?: string
|
|
||||||
className?: string
|
|
||||||
query?: string
|
|
||||||
}) => {
|
|
||||||
const { user, overrideText, className, query } = props
|
|
||||||
|
|
||||||
if (!user || user?.isBannedFromPosting) return <></>
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx('flex justify-center', className)}>
|
<Link href="/create" passHref>
|
||||||
<Link href={`/create${query ? query : ''}`} passHref>
|
|
||||||
<Button color="gradient" size="xl" className="mt-4">
|
<Button color="gradient" size="xl" className="mt-4">
|
||||||
{overrideText ?? 'Create a market'}
|
Create a market
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,10 @@ export function MenuButton(props: {
|
||||||
as="div"
|
as="div"
|
||||||
className={clsx(className ? className : 'relative z-40 flex-shrink-0')}
|
className={clsx(className ? className : 'relative z-40 flex-shrink-0')}
|
||||||
>
|
>
|
||||||
<div>
|
|
||||||
<Menu.Button className="w-full rounded-full">
|
<Menu.Button className="w-full rounded-full">
|
||||||
<span className="sr-only">Open user menu</span>
|
<span className="sr-only">Open user menu</span>
|
||||||
{buttonContent}
|
{buttonContent}
|
||||||
</Menu.Button>
|
</Menu.Button>
|
||||||
</div>
|
|
||||||
<Transition
|
<Transition
|
||||||
as={Fragment}
|
as={Fragment}
|
||||||
enter="transition ease-out duration-100"
|
enter="transition ease-out duration-100"
|
||||||
|
|
|
@ -11,7 +11,7 @@ export function ProfileSummary(props: { user: User }) {
|
||||||
<Link href={`/${user.username}?tab=bets`}>
|
<Link href={`/${user.username}?tab=bets`}>
|
||||||
<a
|
<a
|
||||||
onClick={trackCallback('sidebar: profile')}
|
onClick={trackCallback('sidebar: profile')}
|
||||||
className="group flex flex-row items-center gap-4 rounded-md py-3 text-gray-500 hover:bg-gray-100 hover:text-gray-700"
|
className="group mb-3 flex flex-row items-center gap-4 truncate rounded-md py-3 text-gray-500 hover:bg-gray-100 hover:text-gray-700"
|
||||||
>
|
>
|
||||||
<Avatar avatarUrl={user.avatarUrl} username={user.username} noLink />
|
<Avatar avatarUrl={user.avatarUrl} username={user.username} noLink />
|
||||||
|
|
||||||
|
|
|
@ -234,11 +234,7 @@ export default function Sidebar(props: { className?: string }) {
|
||||||
|
|
||||||
{!user && <SignInButton className="mb-4" />}
|
{!user && <SignInButton className="mb-4" />}
|
||||||
|
|
||||||
{user && (
|
{user && <ProfileSummary user={user} />}
|
||||||
<div className="min-h-[80px] w-full">
|
|
||||||
<ProfileSummary user={user} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Mobile navigation */}
|
{/* Mobile navigation */}
|
||||||
<div className="flex min-h-0 shrink flex-col gap-1 lg:hidden">
|
<div className="flex min-h-0 shrink flex-col gap-1 lg:hidden">
|
||||||
|
@ -255,7 +251,7 @@ export default function Sidebar(props: { className?: string }) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Desktop navigation */}
|
{/* Desktop navigation */}
|
||||||
<div className="hidden min-h-0 shrink flex-col gap-1 lg:flex">
|
<div className="hidden min-h-0 shrink flex-col items-stretch gap-1 lg:flex ">
|
||||||
{navigationOptions.map((item) => (
|
{navigationOptions.map((item) => (
|
||||||
<SidebarItem key={item.href} item={item} currentPage={currentPage} />
|
<SidebarItem key={item.href} item={item} currentPage={currentPage} />
|
||||||
))}
|
))}
|
||||||
|
@ -264,7 +260,7 @@ export default function Sidebar(props: { className?: string }) {
|
||||||
buttonContent={<MoreButton />}
|
buttonContent={<MoreButton />}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{user && <CreateQuestionButton user={user} />}
|
{user && !user.isBannedFromPosting && <CreateQuestionButton />}
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,11 +12,9 @@ export default function NotificationsIcon(props: { className?: string }) {
|
||||||
const privateUser = usePrivateUser()
|
const privateUser = usePrivateUser()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row className={clsx('justify-center')}>
|
<Row className="relative justify-center">
|
||||||
<div className={'relative'}>
|
|
||||||
{privateUser && <UnseenNotificationsBubble privateUser={privateUser} />}
|
{privateUser && <UnseenNotificationsBubble privateUser={privateUser} />}
|
||||||
<BellIcon className={clsx(props.className)} />
|
<BellIcon className={clsx(props.className)} />
|
||||||
</div>
|
|
||||||
</Row>
|
</Row>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -32,11 +30,11 @@ function UnseenNotificationsBubble(props: { privateUser: PrivateUser }) {
|
||||||
|
|
||||||
const notifications = useUnseenGroupedNotification(privateUser)
|
const notifications = useUnseenGroupedNotification(privateUser)
|
||||||
if (!notifications || notifications.length === 0 || seen) {
|
if (!notifications || notifications.length === 0 || seen) {
|
||||||
return <div />
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="-mt-0.75 absolute ml-3.5 min-w-[15px] rounded-full bg-indigo-500 p-[2px] text-center text-[10px] leading-3 text-white lg:-mt-1 lg:ml-2">
|
<div className="-mt-0.75 absolute ml-3.5 min-w-[15px] rounded-full bg-indigo-500 p-[2px] text-center text-[10px] leading-3 text-white lg:left-0 lg:-mt-1 lg:ml-2">
|
||||||
{notifications.length > NOTIFICATIONS_PER_PAGE
|
{notifications.length > NOTIFICATIONS_PER_PAGE
|
||||||
? `${NOTIFICATIONS_PER_PAGE}+`
|
? `${NOTIFICATIONS_PER_PAGE}+`
|
||||||
: notifications.length}
|
: notifications.length}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user