"use client"; /** * ProfileSidebar — the navigation rail for /u/me. * * • Desktop (md+): permanent left column, ~240px wide, sticky below the * SiteHeader so it stays in view while content scrolls. * • Mobile: a hamburger button reveals the same nav as a left drawer. * * Items are intentionally just three (Profile / Collections / Bookmarks) to * keep the surface focused; "Log out" sits as a footer action separated by * a divider. */ import { useState } from "react"; import Link from "next/link"; import Image from "next/image"; import { usePathname, useRouter } from "next/navigation"; import { User as UserIcon, FolderOpen, Bookmark, LogOut, Menu } from "lucide-react"; import { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle, DrawerTrigger, } from "@/components/ui/drawer"; import { useAuth } from "@/components/auth/auth-provider"; import type { User } from "@/lib/auth"; import { cn } from "@/lib/utils"; type NavItem = { href: string; label: string; icon: typeof UserIcon; /** Match only when pathname === href; otherwise startsWith is used. */ exact?: boolean; }; const ITEMS: NavItem[] = [ { href: "/u/me", label: "Profile", icon: UserIcon, exact: true }, { href: "/u/me/collections", label: "Collections", icon: FolderOpen }, { href: "/u/me/bookmarks", label: "Bookmarks", icon: Bookmark }, ]; export function ProfileSidebar({ user }: { user: User }) { return ( <> {/* Desktop rail — always visible on md+ */} {/* Mobile trigger + drawer */} ); } function MobileSidebar({ user }: { user: User }) { const [open, setOpen] = useState(false); return (
Library menu Your library Switch between profile, collections, and bookmarks.
setOpen(false)} />
); } function SidebarHeader({ user }: { user: User }) { return (

{user.name}

@{user.handle}

); } function SidebarNav({ onItemClick }: { onItemClick: () => void }) { const pathname = usePathname(); return ( ); } function SidebarFooter() { const { logOut } = useAuth(); const router = useRouter(); async function onLogOut() { await logOut(); router.push("/"); router.refresh(); } return (
); } function Avatar({ src, name }: { src: string | null; name: string }) { if (src) { return ( {name} ); } const initials = name .split(/\s+/) .map((p) => p[0]) .slice(0, 2) .join("") .toUpperCase() || "?"; return (
{initials}
); }