@@ -3,14 +3,15 @@ import { useRouter } from 'next/router';
33import Link from 'next/link' ;
44import Container from '@/components/containers/Container' ;
55import { linksNav } from '@/utils/links' ;
6- import S from './styles ' ;
6+ import styles from './Nav.module.scss ' ;
77
88export default function Nav ( ) {
99 const router = useRouter ( ) ;
1010 const [ active , setActive ] = useState ( false ) ;
1111 const [ isSticky , setIsSticky ] = useState ( false ) ;
1212 const headerRef = useRef ( ) ;
1313 const containerRef = useRef ( ) ;
14+ const DESKTOP_BREAKPOINT = 1024 ;
1415
1516 useEffect ( ( ) => {
1617 const observer = new IntersectionObserver (
@@ -25,7 +26,7 @@ export default function Nav() {
2526 {
2627 threshold : 0 ,
2728 rootMargin : '300px' ,
28- }
29+ } ,
2930 ) ;
3031
3132 if ( headerRef . current ) {
@@ -51,59 +52,91 @@ export default function Nav() {
5152 } ;
5253 } , [ ] ) ;
5354
55+ useEffect ( ( ) => {
56+ const handleResize = ( ) => {
57+ if ( window . innerWidth > DESKTOP_BREAKPOINT ) {
58+ setActive ( false ) ;
59+ }
60+ } ;
61+
62+ window . addEventListener ( 'resize' , handleResize ) ;
63+ return ( ) => {
64+ window . removeEventListener ( 'resize' , handleResize ) ;
65+ } ;
66+ } , [ ] ) ;
67+
5468 return (
55- < S . Header ref = { headerRef } >
69+ < header className = { styles . header } ref = { headerRef } >
5670 < Container >
57- < S . NavWrapper ref = { containerRef } $isSticky = { isSticky } >
58- < S . Nav $isSticky = { isSticky } >
71+ < div
72+ ref = { containerRef }
73+ className = { isSticky ? styles . navWrapperSticky : '' }
74+ >
75+ < nav className = { isSticky ? styles . navSticky : styles . nav } >
5976 < Link href = '/' >
60- < S . Logo
61- $isSticky = { isSticky }
77+ < img
78+ className = { isSticky ? styles . logoSticky : styles . logo }
6279 src = '/images/svg/logo.svg'
6380 alt = 'Logo'
6481 title = 'Go to the Homepage'
6582 />
6683 </ Link >
67- < S . Links
68- className = { `${ active ? 'active' : '' } ` }
69- $isSticky = { isSticky }
84+ < ul
85+ className = { `
86+ ${ active ? styles . active : '' }
87+ ${ isSticky ? styles . linksSticky : styles . links }
88+ ` }
7089 >
7190 { linksNav . map ( ( { text, href, id } ) => {
7291 return (
73- < S . Item key = { id } >
74- < S . Link
92+ < li className = { styles . item } key = { id } >
93+ < a
7594 href = { href }
76- className = { `${ router . pathname == href ? ` current` : '' } ` }
95+ className = { `${ styles . link } ${ router . pathname === href ? styles . current : '' } ` }
7796 title = { text }
7897 >
7998 { text }
80- </ S . Link >
81- </ S . Item >
99+ </ a >
100+ </ li >
82101 ) ;
83102 } ) }
84- < S . Item >
85- < S . Button
86- $isSticky = { isSticky }
103+ < li className = { styles . item } >
104+ < a
87105 href = 'mailto:hello@webdevpath.co?subject=Project collaborator application'
88- className = { `${ active ? `active` : '' } ` }
106+ className = { `
107+ ${ active ? styles . active : '' }
108+ ${ isSticky ? styles . buttonSticky : styles . button }
109+ ` }
89110 title = 'Join us'
90111 >
91112 Join us
92- </ S . Button >
93- </ S . Item >
94- </ S . Links >
95- < S . Hamburger
96- className = { `${ active ? ` active` : '' } ` }
113+ </ a >
114+ </ li >
115+ </ ul >
116+ < button
117+ className = { `${ styles . hamburger } ${ active ? styles . active : '' } ` }
97118 onClick = { ( ) => setActive ( active => ! active ) }
98119 aria-label = 'toggle navigation'
99120 >
100- < S . HamburgerBar $isSticky = { isSticky } > </ S . HamburgerBar >
101- < S . HamburgerBar $isSticky = { isSticky } > </ S . HamburgerBar >
102- < S . HamburgerBar $isSticky = { isSticky } > </ S . HamburgerBar >
103- </ S . Hamburger >
104- </ S . Nav >
105- </ S . NavWrapper >
121+ < span
122+ className = {
123+ isSticky ? styles . hamburgerBarSticky : styles . hamburgerBar
124+ }
125+ > </ span >
126+ < span
127+ className = {
128+ isSticky ? styles . hamburgerBarSticky : styles . hamburgerBar
129+ }
130+ > </ span >
131+ < span
132+ className = {
133+ isSticky ? styles . hamburgerBarSticky : styles . hamburgerBar
134+ }
135+ > </ span >
136+ </ button >
137+ </ nav >
138+ </ div >
106139 </ Container >
107- </ S . Header >
140+ </ header >
108141 ) ;
109142}
0 commit comments