|
| 1 | +"use client"; |
| 2 | +import { Sparkles, Home, Menu, X, Shield, FileText, MessageSquare } from "lucide-react"; |
| 3 | +import { useState } from "react"; |
| 4 | +import { motion, AnimatePresence } from "framer-motion"; |
| 5 | +import { useRouter } from "next/navigation"; |
| 6 | + |
| 7 | +interface SidebarProps { |
| 8 | + onOpenAIClick?: () => void; |
| 9 | +} |
| 10 | + |
| 11 | +export default function Sidebar({ onOpenAIClick }: SidebarProps) { |
| 12 | + const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); |
| 13 | + const router = useRouter(); |
| 14 | + |
| 15 | + return ( |
| 16 | + <> |
| 17 | + {/* Mobile Menu Button */} |
| 18 | + <button |
| 19 | + onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)} |
| 20 | + className="md:hidden fixed top-5 left-4 z-50 w-12 h-12 bg-[#1c1e2b] rounded-xl flex items-center justify-center border border-zinc-700/50 shadow-lg hover:bg-[#252736] transition-colors" |
| 21 | + > |
| 22 | + {isMobileMenuOpen ? ( |
| 23 | + <X size={22} className="text-white" /> |
| 24 | + ) : ( |
| 25 | + <Menu size={22} className="text-white" /> |
| 26 | + )} |
| 27 | + </button> |
| 28 | + |
| 29 | + {/* Mobile Overlay */} |
| 30 | + <AnimatePresence> |
| 31 | + {isMobileMenuOpen && ( |
| 32 | + <motion.div |
| 33 | + initial={{ opacity: 0 }} |
| 34 | + animate={{ opacity: 1 }} |
| 35 | + exit={{ opacity: 0 }} |
| 36 | + className="md:hidden fixed inset-0 bg-black/50 z-40" |
| 37 | + onClick={() => setIsMobileMenuOpen(false)} |
| 38 | + /> |
| 39 | + )} |
| 40 | + </AnimatePresence> |
| 41 | + |
| 42 | + {/* Sidebar */} |
| 43 | + <motion.div |
| 44 | + initial={false} |
| 45 | + animate={{ |
| 46 | + x: isMobileMenuOpen ? 0 : -320, |
| 47 | + }} |
| 48 | + transition={{ type: "spring", damping: 25, stiffness: 200 }} |
| 49 | + className="fixed top-0 left-0 bottom-0 md:top-6 md:left-6 w-[280px] md:h-[calc(100vh-48px)] bg-[#1c1e2b] md:rounded-lg flex flex-col overflow-hidden shadow-2xl border-r md:border border-zinc-800/50 z-50 md:!transform-none" |
| 50 | + > |
| 51 | + <div className="flex-1 overflow-y-auto p-4 space-y-2"> |
| 52 | + {/* Home */} |
| 53 | + <div |
| 54 | + onClick={() => { |
| 55 | + window.location.reload(); |
| 56 | + setIsMobileMenuOpen(false); |
| 57 | + }} |
| 58 | + className="flex items-center gap-3 px-4 py-3 bg-zinc-700/30 hover:bg-zinc-700/50 rounded-xl cursor-pointer transition-all min-h-[52px] w-full" |
| 59 | + > |
| 60 | + <div className="w-8 h-8 flex items-center justify-center"> |
| 61 | + <Home size={20} className="text-zinc-300" /> |
| 62 | + </div> |
| 63 | + <span className="text-white font-medium text-base">Home!</span> |
| 64 | + </div> |
| 65 | + {/* AI */} |
| 66 | + <div |
| 67 | + onClick={() => { |
| 68 | + onOpenAIClick?.(); |
| 69 | + setIsMobileMenuOpen(false); |
| 70 | + }} |
| 71 | + className="flex items-center gap-3 px-4 py-3 bg-purple-500/20 hover:bg-purple-500/30 border border-purple-500/30 rounded-xl cursor-pointer transition-all min-h-[52px] w-full" |
| 72 | + > |
| 73 | + <div className="w-8 h-8 flex items-center justify-center"> |
| 74 | + <Sparkles size={20} className="text-purple-400" /> |
| 75 | + </div> |
| 76 | + <span className="text-white font-medium text-base">AI</span> |
| 77 | + </div> |
| 78 | + |
| 79 | + {/* Divider removed: legal/contact moved to bottom icon row */} |
| 80 | + </div> |
| 81 | + {/* Bottom icon row */} |
| 82 | + <div className="border-t border-zinc-800/50 p-3 bg-[#1c1e2b] flex items-center justify-around"> |
| 83 | + <button |
| 84 | + aria-label="Privacy Policy" |
| 85 | + title="Privacy Policy" |
| 86 | + onClick={() => { |
| 87 | + router.push("/privacy"); |
| 88 | + setIsMobileMenuOpen(false); |
| 89 | + }} |
| 90 | + className="w-11 h-11 rounded-lg flex items-center justify-center hover:bg-zinc-700/30 transition-colors" |
| 91 | + > |
| 92 | + <Shield size={20} className="text-zinc-300" /> |
| 93 | + </button> |
| 94 | + <button |
| 95 | + aria-label="Terms of Service" |
| 96 | + title="Terms of Service" |
| 97 | + onClick={() => { |
| 98 | + router.push("/terms"); |
| 99 | + setIsMobileMenuOpen(false); |
| 100 | + }} |
| 101 | + className="w-11 h-11 rounded-lg flex items-center justify-center hover:bg-zinc-700/30 transition-colors" |
| 102 | + > |
| 103 | + <FileText size={20} className="text-zinc-300" /> |
| 104 | + </button> |
| 105 | + <button |
| 106 | + aria-label="Contact Us" |
| 107 | + title="Contact Us" |
| 108 | + onClick={() => { |
| 109 | + router.push("/contact"); |
| 110 | + setIsMobileMenuOpen(false); |
| 111 | + }} |
| 112 | + className="w-11 h-11 rounded-lg flex items-center justify-center hover:bg-zinc-700/30 transition-colors" |
| 113 | + > |
| 114 | + <MessageSquare size={20} className="text-zinc-300" /> |
| 115 | + </button> |
| 116 | + </div> |
| 117 | + </motion.div> |
| 118 | + </> |
| 119 | + ); |
| 120 | +} |
0 commit comments