Write on the margins of the internet. Powered by the AT Protocol. margin.at
extension web atproto comments
at main 1.7 kB view raw
1import { Link, useLocation } from "react-router-dom"; 2import { useAuth } from "../context/AuthContext"; 3import { Home, Search, Folder, User, PenSquare } from "lucide-react"; 4 5export default function MobileNav() { 6 const { user, isAuthenticated } = useAuth(); 7 const location = useLocation(); 8 9 const isActive = (path) => { 10 if (path === "/") return location.pathname === "/"; 11 return location.pathname.startsWith(path); 12 }; 13 14 return ( 15 <nav className="mobile-nav"> 16 <div className="mobile-nav-inner"> 17 <Link 18 to="/" 19 className={`mobile-nav-item ${isActive("/") ? "active" : ""}`} 20 > 21 <Home /> 22 <span>Home</span> 23 </Link> 24 25 <Link 26 to="/url" 27 className={`mobile-nav-item ${isActive("/url") ? "active" : ""}`} 28 > 29 <Search /> 30 <span>Browse</span> 31 </Link> 32 33 {isAuthenticated ? ( 34 <Link to="/new" className="mobile-nav-item mobile-nav-new"> 35 <PenSquare /> 36 </Link> 37 ) : ( 38 <Link to="/login" className="mobile-nav-item mobile-nav-new"> 39 <User /> 40 </Link> 41 )} 42 43 <Link 44 to="/collections" 45 className={`mobile-nav-item ${isActive("/collections") ? "active" : ""}`} 46 > 47 <Folder /> 48 <span>Library</span> 49 </Link> 50 51 <Link 52 to={isAuthenticated && user?.did ? `/profile/${user.did}` : "/login"} 53 className={`mobile-nav-item ${isActive("/profile") ? "active" : ""}`} 54 > 55 <User /> 56 <span>Profile</span> 57 </Link> 58 </div> 59 </nav> 60 ); 61}