1- import React from 'react' ;
1+ import React , { useEffect , useState } from 'react' ;
22import Link from 'next/link' ;
33import Logo from '../Logo/Logo' ;
44
55import { ABOUT , CONTACT , EVENTS , HOME } from '../../util/routeConstants' ;
66import LinkButton from '../LinkButton/LinkButton' ;
7+ import DropdownMenu from './DropdownMenu' ;
78
89export default function Navbar ( ) {
10+ const [ screenWidth , setScreenWidth ] = useState < number | null > ( null ) ;
11+
12+ const breakpoint = 768 ;
13+
14+ useEffect ( ( ) => {
15+ setScreenWidth ( window . innerWidth ) ;
16+
17+ const handleResize = ( ) => setScreenWidth ( window . innerWidth ) ;
18+
19+ window . addEventListener ( 'resize' , handleResize ) ;
20+
21+ return ( ) => window . removeEventListener ( 'resize' , handleResize ) ;
22+ } , [ ] ) ;
23+
24+ if ( ! screenWidth ) return null ;
925 return (
10- < >
11- < header className = "lg:pl-[49px] w-full fixed top-0 bg-black bg-opacity-50 z-10 " >
12- < nav className = "nav py-4 pl-5 flex flex-col md:flex-row justify-around items-center " >
13- < div >
14- < Link href = { HOME } >
15- < a >
16- < Logo size = { 60 } / >
17- </ a >
18- </ Link >
19- </ div >
26+ < header className = "lg:pl-[49px] fixed top-0 backdrop-blur-md w-full bg-black text-white justify-between bg-opacity-50 z-10" >
27+ < nav className = "nav py-2 md:py-4 md:pl-5 flex flex-row justify-between md:justify-around px-4 items-center " >
28+ < div className = "" >
29+ < Link href = { HOME } >
30+ < a >
31+ < Logo size = { 60 } / >
32+ </ a >
33+ </ Link >
34+ </ div >
35+ { screenWidth > breakpoint && (
2036 < div className = "" >
2137 < ul className = "font-montserrat text-base text-white flex flex-row justify-between items-center md:space-x-[30px]" >
2238 < a href = { ABOUT } >
@@ -30,6 +46,8 @@ export default function Navbar() {
3046 </ a >
3147 </ ul >
3248 </ div >
49+ ) }
50+ { screenWidth > breakpoint && (
3351 < div >
3452 < LinkButton
3553 className = "flex justify-center items-center bg-[#EC0505] w-[203px] h-[46px] rounded-md text-base text-white font-montserrat font-bold"
@@ -40,8 +58,9 @@ export default function Navbar() {
4058 Join Community
4159 </ LinkButton >
4260 </ div >
43- </ nav >
44- </ header >
45- </ >
61+ ) }
62+ { screenWidth <= breakpoint && < DropdownMenu /> }
63+ </ nav >
64+ </ header >
4665 ) ;
4766}
0 commit comments