|
1 | 1 | "use client"; |
2 | 2 |
|
3 | | -import { useState } from "react"; |
4 | 3 | import { usePathname } from "next/navigation"; |
5 | 4 | import Link from "next/link"; |
6 | | -import { ArrowUpRight, Pin, UploadIcon, ChevronDown } from "lucide-react"; |
| 5 | +import { useState } from "react"; |
| 6 | +import { |
| 7 | + ArrowUpRight, |
| 8 | + ChevronDown, |
| 9 | + Pin, |
| 10 | + UploadIcon, |
| 11 | +} from "lucide-react"; |
7 | 12 | import ModeToggle from "./toggle-theme"; |
8 | 13 |
|
| 14 | +import { |
| 15 | + DropdownMenu, |
| 16 | + DropdownMenuTrigger, |
| 17 | + DropdownMenuContent, |
| 18 | + DropdownMenuItem, |
| 19 | +} from "@/components/ui/dropdown-menu"; |
| 20 | + |
9 | 21 | interface Props { |
10 | 22 | onNavigate: () => void; |
11 | 23 | } |
12 | 24 |
|
13 | 25 | export default function FloatingNavbar({ onNavigate }: Props) { |
14 | 26 | const pathname = usePathname(); |
15 | | - const [isOpen, setIsOpen] = useState(false); |
| 27 | + const [dropdownOpen, setDropdownOpen] = useState(false); |
16 | 28 |
|
17 | 29 | return ( |
18 | | - <div className="fixed right-6 top-0 z-50 flex flex-col items-end h-full pointer-events-none"> |
19 | | - {} |
20 | | - <button |
21 | | - className="mt-[1.25rem] flex h-10 w-10 items-center justify-center rounded-full bg-[#4B22D1] text-white shadow-lg transition-transform duration-200 hover:scale-105 active:scale-95 pointer-events-auto" |
22 | | - onClick={() => setIsOpen(prev => !prev)} |
23 | | - aria-label={isOpen ? "Close menu" : "Open menu"} |
24 | | - > |
25 | | - <ChevronDown |
26 | | - className={`h-5 w-5 transition-transform duration-200 ${isOpen ? "rotate-180" : ""}`} |
27 | | - /> |
28 | | - </button> |
29 | | - |
30 | | - {} |
31 | | - {isOpen && ( |
32 | | - <div className="mt-2 flex flex-col items-center gap-4 rounded-3xl bg-[#110F18] px-6 py-6 shadow-xl ring-1 ring-white/5 pointer-events-auto"> |
33 | | - <Link |
34 | | - href={pathname === "/upload" ? "/" : "/upload"} |
35 | | - onClick={() => { |
36 | | - setIsOpen(false); |
37 | | - onNavigate(); |
38 | | - }} |
| 30 | + <div className="flex flex-col items-end h-full space-y-4 pointer-events-none"> |
| 31 | + <DropdownMenu open={dropdownOpen} onOpenChange={setDropdownOpen}> |
| 32 | + <DropdownMenuTrigger asChild> |
| 33 | + <button |
| 34 | + className="flex h-10 w-10 items-center justify-center rounded-full bg-[#4B22D1] text-white shadow-lg transition-transform duration-200 hover:scale-105 active:scale-95 pointer-events-auto" |
| 35 | + aria-label="Toggle dropdown" |
39 | 36 | > |
40 | | - <div className="flex items-center gap-2 rounded-full border border-[#3A3745] px-4 py-2 text-sm font-semibold text-white transition hover:bg-[#1A1823]"> |
| 37 | + <ChevronDown |
| 38 | + className={`h-5 w-5 transition-transform duration-200 ${dropdownOpen ? "rotate-180" : ""}`} |
| 39 | + /> |
| 40 | + </button> |
| 41 | + </DropdownMenuTrigger> |
| 42 | + |
| 43 | + <DropdownMenuContent |
| 44 | + className="xl:hidden mt-2 w-72 space-y-1 rounded-3xl border border-white/10 bg-[#110F18] px-4 py-4 text-white shadow-xl backdrop-blur-sm pointer-events-auto" |
| 45 | + align="end" |
| 46 | + > |
| 47 | + <DropdownMenuItem asChild> |
| 48 | + <Link |
| 49 | + href={pathname === "/upload" ? "/" : "/upload"} |
| 50 | + onClick={() => onNavigate()} |
| 51 | + className="flex w-full items-center gap-3 rounded-lg px-3 py-3 hover:bg-[#1A1823] transition" |
| 52 | + > |
41 | 53 | <UploadIcon className="h-4 w-4" /> |
42 | | - <span>{pathname === "/upload" ? "Search Papers" : "Upload Papers"}</span> |
43 | | - </div> |
44 | | - </Link> |
| 54 | + <span className="text-sm font-medium"> |
| 55 | + {pathname === "/upload" ? "Search Papers" : "Upload Papers"} |
| 56 | + </span> |
| 57 | + </Link> |
| 58 | + </DropdownMenuItem> |
45 | 59 |
|
46 | | - <Link href="/pinned" onClick={() => { setIsOpen(false); onNavigate(); }}> |
47 | | - <div className="flex items-center gap-2 rounded-full border border-[#3A3745] px-4 py-2 text-sm font-semibold text-white transition hover:bg-[#1A1823]"> |
| 60 | + <DropdownMenuItem asChild> |
| 61 | + <Link |
| 62 | + href="/pinned" |
| 63 | + onClick={() => onNavigate()} |
| 64 | + className="flex w-full items-center gap-3 rounded-lg px-3 py-3 hover:bg-[#1A1823] transition" |
| 65 | + > |
48 | 66 | <Pin className="h-4 w-4" /> |
49 | | - <span>Pinned Subjects</span> |
50 | | - </div> |
51 | | - </Link> |
| 67 | + <span className="text-sm font-medium">Pinned Subjects</span> |
| 68 | + </Link> |
| 69 | + </DropdownMenuItem> |
52 | 70 |
|
53 | | - <Link href="/request" onClick={() => { setIsOpen(false); onNavigate(); }}> |
54 | | - <div className="flex items-center gap-2 rounded-full border border-[#3A3745] px-4 py-2 text-sm font-semibold text-white transition hover:bg-[#1A1823] w-full justify-center"> |
| 71 | + <DropdownMenuItem asChild> |
| 72 | + <Link |
| 73 | + href="/request" |
| 74 | + onClick={() => onNavigate()} |
| 75 | + className="flex w-full items-center gap-3 rounded-lg px-3 py-3 hover:bg-[#1A1823] transition" |
| 76 | + > |
55 | 77 | <ArrowUpRight className="h-4 w-4" /> |
56 | | - <span>Paper Request</span> |
57 | | - </div> |
58 | | - </Link> |
| 78 | + <span className="text-sm font-medium">Paper Request</span> |
| 79 | + </Link> |
| 80 | + </DropdownMenuItem> |
59 | 81 |
|
60 | | - <div className="rounded-full border border-[#3A3745] p-1"> |
61 | | - <ModeToggle /> |
| 82 | + <div className="pt-2 border-t border-[#3A3745] mt-2"> |
| 83 | + <div className="flex justify-center pt-2"> |
| 84 | + <div className="rounded-full border border-[#3A3745] p-1"> |
| 85 | + <ModeToggle /> |
| 86 | + </div> |
| 87 | + </div> |
62 | 88 | </div> |
63 | | - </div> |
64 | | - )} |
| 89 | + </DropdownMenuContent> |
| 90 | + </DropdownMenu> |
65 | 91 | </div> |
66 | 92 | ); |
67 | 93 | } |
0 commit comments