Skip to content

Commit 1c2d574

Browse files
committed
updated nav bar
1 parent 48f8802 commit 1c2d574

File tree

1 file changed

+50
-46
lines changed

1 file changed

+50
-46
lines changed

src/shared/components/Navigation/MainNavigation.tsx

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,74 +5,78 @@ import { Link, NavLink, useLocation } from "react-router-dom";
55
import { useAuth } from "../../../context/AuthContext.tsx";
66

77
export default function MainNavigation() {
8-
98
const { auth } = useAuth();
10-
119
const location = useLocation().pathname;
10+
1211
const routes = auth.isAuthenticated
1312
? [
14-
{ name: "Jobs", href: "/jobs", current: true },
15-
{ name: "Create", href: "/create", current: false },
16-
{ name: "Staff", href: "/staff", current: false },
17-
{ name: "Profile", href: "/profile", current: false },
18-
{ name: "Sign Out", href: "/signout", current: false },
19-
]
13+
{ name: "Jobs", href: "/jobs", current: location === "/jobs" },
14+
{ name: "Create", href: "/create", current: location === "/create" },
15+
{ name: "Staff", href: "/staff", current: location === "/staff" },
16+
{ name: "Profile", href: "/profile", current: location === "/profile" },
17+
{ name: "Sign Out", href: "/signout", current: false },
18+
]
2019
: [{ name: "Sign In", href: "/signin", current: false }];
2120

2221
return (
23-
<Disclosure as="nav" className="bg-slate-100">
22+
<Disclosure as="nav" className="bg-white shadow-md sticky top-0 z-50">
2423
{({ open }) => (
2524
<>
26-
<div className="mainnav sm:px-6 lg:px-8">
27-
<div className="mainnav-header">
28-
<div className="mainnav-desc sm:hidden">
29-
{/* Mobile menu button*/}
30-
<Disclosure.Button className="btn-disclosure hover:bg-gray-700 hover:text-white focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white">
31-
<span className="absolute -inset-0.5" />
25+
<div className="container mx-auto px-4 sm:px-6 lg:px-8">
26+
<div className="flex justify-between items-center h-16">
27+
{/* Logo */}
28+
<div className="flex-shrink-0">
29+
<Link to="/" className="text-2xl font-bold text-blue-600 hover:text-blue-800 transition-all duration-200">
30+
LabConnect
31+
</Link>
32+
</div>
33+
34+
{/* Desktop Navigation */}
35+
<div className="hidden sm:flex sm:items-center">
36+
<div className="flex space-x-8">
37+
{routes.map((item) => (
38+
<NavLink
39+
key={item.name}
40+
to={item.href}
41+
className={({ isActive }) =>
42+
location === item.href
43+
? "text-blue-600 font-semibold border-b-2 border-blue-600"
44+
: "text-gray-600 hover:text-blue-600 transition-all duration-200"
45+
}
46+
>
47+
{item.name}
48+
</NavLink>
49+
))}
50+
</div>
51+
</div>
52+
53+
{/* Mobile Menu Button */}
54+
<div className="flex sm:hidden">
55+
<Disclosure.Button className="inline-flex items-center justify-center p-2 rounded-md text-gray-600 hover:text-white hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-500 transition-all duration-200">
3256
<span className="sr-only">Open main menu</span>
3357
{open ? (
34-
<XMarkIcon className="blck66" aria-hidden="true" />
58+
<XMarkIcon className="block h-6 w-6" aria-hidden="true" />
3559
) : (
36-
<Bars3Icon className="blck66" aria-hidden="true" />
60+
<Bars3Icon className="block h-6 w-6" aria-hidden="true" />
3761
)}
3862
</Disclosure.Button>
3963
</div>
40-
<div className="mainnav-desc2 sm:items-stretch sm:justify-start">
41-
<div className="mainnav-title-link">
42-
<Link to="/" className="blue-link hover:text-blue-900 focus:text-blue-900">
43-
LabConnect
44-
</Link>
45-
</div>
46-
<div className="hidden sm:ml-6 sm:block">
47-
<div className="flex space-x-4 ">
48-
{routes.map((item) => (
49-
<NavLink
50-
key={item.name}
51-
to={item.href}
52-
className={`${location === item.href
53-
? "text-black"
54-
: "text-gray-600"
55-
} hover:text-gray-800 hover:bg-gray-200 mainnav-link`}
56-
aria-current={item.current}
57-
>
58-
{item.name}
59-
</NavLink>
60-
))}
61-
</div>
62-
</div>
63-
</div>
6464
</div>
6565
</div>
6666

67+
{/* Mobile Navigation */}
6768
<Disclosure.Panel className="sm:hidden">
68-
<div className="space-y-1 px-2 pb-3 pt-2">
69+
<div className="space-y-1 px-4 pt-2 pb-3">
6970
{routes.map((item) => (
7071
<Disclosure.Button
7172
key={item.name}
72-
as="a"
73-
href={item.href}
74-
className="btn-disclosure2 hover:bg-gray-200"
75-
aria-current={item.current ? "page" : undefined}
73+
as={Link}
74+
to={item.href}
75+
className={`${
76+
location === item.href
77+
? "block text-blue-600 font-semibold py-2 border-l-4 border-blue-600 pl-4 transition-all duration-200"
78+
: "block text-gray-600 hover:text-blue-600 py-2 pl-4 transition-all duration-200"
79+
}`}
7680
>
7781
{item.name}
7882
</Disclosure.Button>

0 commit comments

Comments
 (0)