11import { Link } from "react-router-dom" ;
22import orbital_logo from "../assets/orbital_logo.png" ;
33import { NAVIGATION_LINKS } from "../utils/nav-links" ;
4+ import { useTheme } from "../contexts/ThemeContext" ;
45
56/**
67 * @brief Nav component displaying the navigation bar
@@ -9,39 +10,95 @@ import { NAVIGATION_LINKS } from "../utils/nav-links";
910function Nav ( ) {
1011 // TODO: create user auth that checks if the user is logged in
1112 const isLoggedIn = false ;
13+ const { theme, toggleTheme } = useTheme ( ) ;
1214
1315 return (
14- < nav className = "m-7 " >
16+ < nav className = "fixed top-0 left-0 right-0 h-16 px-8 flex items-center justify-between bg-background/80 backdrop-blur-sm border-b border-border z-50 " >
1517 { /* Logo */ }
16- < div className = "fixed left-8" >
17- < Link to = "/" className = "hover:opacity-80 transition-opacity" >
18- < img src = { orbital_logo } alt = "orbital logo" className = "h-12 w-auto" />
19- </ Link >
20- </ div >
18+ < Link to = "/" className = "hover:opacity-80 transition-opacity" >
19+ < img src = { orbital_logo } alt = "orbital logo" className = "h-10 w-auto" />
20+ </ Link >
2121
2222 { /* Navigation Links */ }
23- < div className = "fixed left-1/2 transform -translate-x-1/2 mt-3 flex space-x-7" >
23+ < div className = "flex space-x-7" >
2424 { NAVIGATION_LINKS . map ( ( link ) => (
25- < Link key = { link . url } to = { link . url } className = "hover:underline" >
25+ < Link
26+ key = { link . url }
27+ to = { link . url }
28+ className = "hover:underline transition-colors"
29+ >
2630 { link . text }
2731 </ Link >
2832 ) ) }
2933 </ div >
3034
31- { /* Profile or Login page, depending on authentication state */ }
32- { isLoggedIn ? (
33- < div className = "fixed right-8 mt-2 border-1 border-white rounded-xl p-1 px-2 hover:bg-white hover:text-black" >
34- < Link to = "/profile" className = "" >
35+
36+ < div className = "flex items-center gap-4" >
37+
38+ < button
39+ onClick = { toggleTheme }
40+ className = "w-10 h-10 flex items-center justify-center rounded-full border border-foreground/20 hover:bg-accent transition-colors"
41+ aria-label = "Toggle theme"
42+ title = { `Switch to ${ theme === "light" ? "dark" : "light" } mode` }
43+ >
44+ { theme === "light" ? (
45+
46+ < svg
47+ xmlns = "http://www.w3.org/2000/svg"
48+ width = "18"
49+ height = "18"
50+ viewBox = "0 0 24 24"
51+ fill = "none"
52+ stroke = "currentColor"
53+ strokeWidth = "2"
54+ strokeLinecap = "round"
55+ strokeLinejoin = "round"
56+ >
57+ < path d = "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
58+ </ svg >
59+ ) : (
60+
61+ < svg
62+ xmlns = "http://www.w3.org/2000/svg"
63+ width = "18"
64+ height = "18"
65+ viewBox = "0 0 24 24"
66+ fill = "none"
67+ stroke = "currentColor"
68+ strokeWidth = "2"
69+ strokeLinecap = "round"
70+ strokeLinejoin = "round"
71+ >
72+ < circle cx = "12" cy = "12" r = "4" />
73+ < path d = "M12 2v2" />
74+ < path d = "M12 20v2" />
75+ < path d = "m4.93 4.93 1.41 1.41" />
76+ < path d = "m17.66 17.66 1.41 1.41" />
77+ < path d = "M2 12h2" />
78+ < path d = "M20 12h2" />
79+ < path d = "m6.34 17.66-1.41 1.41" />
80+ < path d = "m19.07 4.93-1.41 1.41" />
81+ </ svg >
82+ ) }
83+ </ button >
84+
85+
86+ { isLoggedIn ? (
87+ < Link
88+ to = "/profile"
89+ className = "border border-foreground/20 rounded-xl px-4 py-2 hover:bg-accent transition-colors"
90+ >
3591 Profile
3692 </ Link >
37- </ div >
38- ) : (
39- < div className = "fixed right-8 mt-2 border-1 border-white rounded-xl p-1 px-2 hover:bg-white hover:text-black" >
40- < Link to = "/login" className = "" >
93+ ) : (
94+ < Link
95+ to = "/login"
96+ className = "border border-foreground/20 rounded-xl px-4 py-2 hover:bg-accent transition-colors"
97+ >
4198 Login
4299 </ Link >
43- </ div >
44- ) }
100+ ) }
101+ </ div >
45102 </ nav >
46103 ) ;
47104}
0 commit comments