-
Notifications
You must be signed in to change notification settings - Fork 0
hamburger nav bar for participant #208
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
Merged
+151
−10
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
21a3de7
hamburger nav bar for participant
4dfde0b
nav links to pages, and participant fixes
7499da7
now role based hamburger menu for judge and participant, admin still …
cfd0a11
prettier fix for stagging
68de19f
fixed nav, made it user based, added nav to header component so nav s…
ffc5a43
okay, fixed all the stuff for user based nav. made the nav look bette…
af1d93e
is this what you mean? for the user.username stuff?
1acfb30
fix
burtonjong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use client"; | ||
|
||
export default function RoleBasedLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
// For Admin layouts we might want to show a SideNavBar/TopNavBar | ||
// You can use the same hook or control it separately if needed. | ||
// Here we assume non-admin users only need the nav rendered by UserBasedNav. | ||
|
||
// This example uses the UserBasedNav component in the layout: | ||
return ( | ||
<div className="flex w-full flex-col bg-fuzzy-peach"> | ||
<main className="">{children}</main> | ||
</div> | ||
); | ||
} |
anthonyych4n marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
"use client"; | ||
|
||
import Link from "next/link"; | ||
import { useState } from "react"; | ||
|
||
import { useUser } from "@/components/contexts/UserContext"; | ||
|
||
interface NavItem { | ||
name: string; | ||
route: string; | ||
} | ||
|
||
const navigationMap: Record<string, NavItem[]> = { | ||
Admin: [ | ||
{ name: "Dashboard", route: "/admin" }, | ||
{ name: "View All Participants", route: "/admin/users" }, | ||
{ name: "View All Teams", route: "/admin/teams" }, | ||
{ name: "Scan Food Tickets", route: "/admin/scan-food-tickets" }, | ||
{ name: "Create Food Event", route: "/admin/create-food-event" }, | ||
{ name: "Judging Schedule", route: "/admin/schedule" }, | ||
], | ||
Judge: [ | ||
{ name: "Dashboard", route: "/judging" }, | ||
{ name: "Schedule", route: "/judging/schedule" }, | ||
{ name: "Assigned Teams", route: "/judging/assigned-teams" }, | ||
{ name: "Rubric", route: "/judging/rubric" }, | ||
], | ||
Participant: [ | ||
{ name: "Dashboard", route: "/participant" }, | ||
{ name: "Food Ticket", route: "/participant/profile/food-ticket" }, | ||
{ name: "Important Information", route: "/participant/important-info" }, | ||
{ name: "Teams Judging Information", route: "/participant/judging-info" }, | ||
], | ||
}; | ||
|
||
function GenericNav({ navItems }: { navItems: NavItem[] }) { | ||
const [isMenuOpen, setIsMenuOpen] = useState(false); | ||
|
||
const toggleMenu = () => setIsMenuOpen(!isMenuOpen); | ||
|
||
return ( | ||
<> | ||
{!isMenuOpen && ( | ||
<button | ||
onClick={toggleMenu} | ||
className="absolute left-8 top-12 z-50 p-2 text-awesomer-purple" | ||
aria-label="Toggle menu" | ||
> | ||
<div className="relative flex size-8 flex-col justify-center space-y-1.5"> | ||
<span className="block h-[2.5px] w-8 bg-current"></span> | ||
<span className="block h-[2.5px] w-8 bg-current"></span> | ||
<span className="block h-[2.5px] w-8 bg-current"></span> | ||
</div> | ||
</button> | ||
)} | ||
|
||
{isMenuOpen && ( | ||
<div className="fixed inset-0 z-40 bg-black/50" onClick={toggleMenu} /> | ||
)} | ||
|
||
<div | ||
className={`fixed left-0 top-0 z-40 h-full w-64 bg-white shadow-lg transition-transform duration-300 ease-in-out ${ | ||
isMenuOpen ? "translate-x-0" : "-translate-x-full" | ||
}`} | ||
> | ||
<button | ||
onClick={toggleMenu} | ||
className="absolute left-4 top-4 z-50 p-2 text-awesomer-purple" | ||
aria-label="Close menu" | ||
> | ||
<div className="relative size-6"> | ||
<span className="absolute left-0 top-1/2 h-0.5 w-6 -translate-y-1/2 rotate-45 bg-current"></span> | ||
<span className="absolute left-0 top-1/2 h-0.5 w-6 -translate-y-1/2 -rotate-45 bg-current"></span> | ||
</div> | ||
</button> | ||
<div className="flex flex-col px-4 pt-20"> | ||
{navItems.map((item) => ( | ||
<Link | ||
key={item.name} | ||
href={item.route} | ||
className="rounded px-2 py-3 text-xl text-awesomer-purple hover:bg-gray-100" | ||
onClick={() => setIsMenuOpen(false)} | ||
> | ||
{item.name} | ||
</Link> | ||
))} | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default function UserBasedNav() { | ||
const { currentUser } = useUser(); | ||
|
||
if (!currentUser) { | ||
return <div className="p-4 text-center">Loading...</div>; | ||
} | ||
|
||
const role = currentUser?.role || "Participant"; | ||
const navItems = navigationMap[role] || navigationMap.Participant; | ||
|
||
return <GenericNav navItems={navItems} />; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.