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

fix(fe): add hamburger button #1553

Merged
merged 7 commits into from
Mar 13, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 90 additions & 4 deletions apps/frontend/components/auth/HeaderAuthPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuTrigger,
DropdownMenuItem
DropdownMenuItem,
DropdownMenuSeparator
} from '@/components/ui/dropdown-menu'
import { cn } from '@/lib/utils'
import useAuthModalStore from '@/stores/authModal'
Expand Down Expand Up @@ -36,12 +37,11 @@ export default function HeaderAuthPanel({
(state) => state
)
const { setModalPage } = useSignUpModalStore((state) => state)

return (
<div className="ml-2 flex items-center gap-2">
{session ? (
<DropdownMenu>
<DropdownMenuTrigger className="flex gap-2 px-4 py-1">
<DropdownMenuTrigger className="hidden gap-2 px-4 py-1 md:flex">
<p
className={
group === 'editor'
Expand Down Expand Up @@ -110,7 +110,93 @@ export default function HeaderAuthPanel({
</DialogContent>
</Dialog>
)}
<RxHamburgerMenu size="30" className="md:hidden" />
{session ? (
<DropdownMenu>
<DropdownMenuTrigger className="flex gap-2 px-4 py-1 md:hidden">
<RxHamburgerMenu size="30" className="md:hidden" />
jihorobert marked this conversation as resolved.
Show resolved Hide resolved
</DropdownMenuTrigger>
<DropdownMenuContent>
{session?.user.role !== 'User' && (
<Link href="/admin">
<DropdownMenuItem className="flex cursor-pointer items-center gap-1 font-semibold">
<UserRoundCog className="size-4" /> Management
</DropdownMenuItem>
</Link>
)}
<DropdownMenuItem
className="text-primary flex cursor-pointer items-center gap-1 font-semibold"
onClick={() => {
signOut()
}}
>
{session?.user.username}
</DropdownMenuItem>
<DropdownMenuSeparator className="bg-gray-300" />
<Link href="/notice">
<DropdownMenuItem className="flex cursor-pointer items-center gap-1 font-semibold">
Notice
</DropdownMenuItem>
</Link>
<Link href="/contest">
<DropdownMenuItem className="flex cursor-pointer items-center gap-1 font-semibold">
Contest
</DropdownMenuItem>
</Link>
<Link href="/problem">
<DropdownMenuItem className="flex cursor-pointer items-center gap-1 font-semibold">
Problem
</DropdownMenuItem>
</Link>
<DropdownMenuSeparator className="bg-gray-300" />
<DropdownMenuItem
className="flex cursor-pointer items-center gap-1 font-semibold"
onClick={() => {
signOut()
}}
>
<LogOut className="size-4" /> Log Out
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
) : (
<Dialog open={currentModal !== ''} onOpenChange={hideModal}>
<DialogTrigger asChild>
<Button
onClick={() => showSignIn()}
variant={variants[group]}
className={cn(
'flex border-none px-3 py-1 text-base md:hidden ',
group === 'editor' ? 'font-medium' : 'font-semibold'
)}
>
Log In
</Button>
</DialogTrigger>
<DialogTrigger asChild>
<Button
onClick={() => {
showSignUp()
setModalPage(0)
}}
variant={variants[group]}
className={cn(
'flex border-none px-3 py-1 text-base md:hidden ',
group === 'editor' ? 'font-medium' : 'font-bold'
)}
>
Sign Up
</Button>
</DialogTrigger>
<DialogContent
onOpenAutoFocus={(e) => {
e.preventDefault()
}}
className="min-h-[30rem] max-w-[20.5rem]"
>
<AuthModal />
</DialogContent>
</Dialog>
)}
</div>
)
}
Loading