@@ -3,7 +3,7 @@ import React, { useState } from "react";
33import PrimaryButtom from "../ui/custom-button" ;
44import { motion , useScroll , useMotionValueEvent } from "framer-motion" ;
55import Image from "next/image" ;
6- import { Terminal , Github } from "lucide-react" ;
6+ import { Terminal , Github , Menu , X } from "lucide-react" ;
77import Link from "next/link" ;
88import { usePathname } from "next/navigation" ;
99import { cn } from "@/lib/utils" ;
@@ -13,6 +13,19 @@ const Navbar = () => {
1313 const pathname = usePathname ( ) ;
1414 const isPricingPage = pathname === "/pricing" ;
1515 const [ showNavbar , setShowNavbar ] = useState ( isPricingPage ? true : false ) ;
16+ const [ isOpen , setIsOpen ] = useState ( false ) ;
17+
18+ React . useEffect ( ( ) => {
19+ const handleEscape = ( e : KeyboardEvent ) => {
20+ if ( e . key === "Escape" && isOpen ) {
21+ setIsOpen ( false ) ;
22+ ( document . activeElement as HTMLElement ) ?. blur ( ) ;
23+ }
24+ } ;
25+
26+ document . addEventListener ( "keydown" , handleEscape ) ;
27+ return ( ) => document . removeEventListener ( "keydown" , handleEscape ) ;
28+ } , [ isOpen ] ) ;
1629
1730 useMotionValueEvent ( scrollYProgress , "change" , ( latest ) => {
1831 if ( ! isPricingPage ) {
@@ -27,6 +40,7 @@ const Navbar = () => {
2740 { name : "How it works" , href : "/#HIW" } ,
2841 { name : "Stats" , href : "/#Stats" } ,
2942 { name : "Contact" , href : "/#Contact" } ,
43+ { name : "FAQ" , href : "/#faq" } ,
3044 ] ;
3145
3246 return (
@@ -41,6 +55,14 @@ const Navbar = () => {
4155 : "fixed rounded-3xl top-4 border w-[94%] md:w-[80%] mx-auto left-1/2 -translate-x-1/2"
4256 ) }
4357 >
58+ < button
59+ className = "md:hidden text-white"
60+ onClick = { ( ) => setIsOpen ( ! isOpen ) }
61+ aria-label = "Toggle navigation menu"
62+ aria-expanded = { isOpen }
63+ >
64+ { isOpen ? < X size = { 28 } /> : < Menu size = { 28 } /> }
65+ </ button >
4466 < div className = "text-2xl font-medium tracking-tighter flex items-center gap-2" >
4567 < div className = "w-10 aspect-square overflow-hidden relative" >
4668 < Image
@@ -69,7 +91,7 @@ const Navbar = () => {
6991 ) ;
7092 } ) }
7193 </ div >
72- < div className = "flex items-center gap-3" >
94+ < div className = "hidden md: flex items-center gap-3" >
7395 < Link
7496 href = "https://github.com/apsinghdev/opensox"
7597 target = "_blank"
@@ -86,6 +108,45 @@ const Navbar = () => {
86108 </ PrimaryButtom >
87109 </ Link >
88110 </ div >
111+ { isOpen && (
112+ < motion . div
113+ initial = { { opacity : 0 , y : - 10 } }
114+ animate = { { opacity : 1 , y : 0 } }
115+ transition = { { duration : 0.25 } }
116+ className = "absolute top-full mt-2 left-0 w-full bg-neutral-900/90 backdrop-blur-xl border border-white/10 md:hidden flex flex-col items-center py-5 space-y-4 z-50 rounded-3xl"
117+ >
118+ { links . map ( ( link , index ) => (
119+ < Link
120+ key = { index }
121+ href = { link . href }
122+ onClick = { ( ) => setIsOpen ( false ) }
123+ className = "text-white hover:text-gray-300 text-lg"
124+ >
125+ { link . name }
126+ </ Link >
127+ ) ) }
128+ < Link
129+ href = "https://github.com/apsinghdev/opensox"
130+ target = "_blank"
131+ rel = "noopener noreferrer"
132+ onClick = { ( ) => setIsOpen ( false ) }
133+ className = "flex items-center gap-2 px-4 py-2 bg-[#0d1117] hover:bg-[#161b22] rounded-lg border border-[#30363d] text-white transition-colors"
134+ >
135+ < Github className = "w-5 h-5" />
136+ < span className = "text-sm font-medium" > Contribute</ span >
137+ </ Link >
138+ < Link
139+ href = "/dashboard/home"
140+ onClick = { ( ) => setIsOpen ( false ) }
141+ className = "cursor-pointer z-30"
142+ >
143+ < PrimaryButtom >
144+ < Terminal />
145+ Get Started
146+ </ PrimaryButtom >
147+ </ Link >
148+ </ motion . div >
149+ ) }
89150 </ motion . nav >
90151 ) ;
91152} ;
0 commit comments