@@ -2,8 +2,9 @@ import { useState, useEffect, useRef } from 'react';
2
2
import { useRouter } from 'next/router' ;
3
3
import Link from 'next/link' ;
4
4
import Container from '@/components/containers/Container/Container' ;
5
- import styles from '@/styles/Nav.module.scss' ;
5
+ // import styles from '@/styles/Nav.module.scss';
6
6
import { linksNav } from '@/utils/links' ;
7
+ import S from './styles' ;
7
8
8
9
export default function Nav ( ) {
9
10
const router = useRouter ( ) ;
@@ -17,10 +18,8 @@ export default function Nav() {
17
18
( [ entry ] ) => {
18
19
if ( ! containerRef . current ) return ;
19
20
if ( ! entry . isIntersecting ) {
20
- containerRef . current . classList . add ( styles . sticky ) ;
21
21
setIsSticky ( true ) ;
22
22
} else {
23
- containerRef . current . classList . remove ( styles . sticky ) ;
24
23
setIsSticky ( false ) ;
25
24
}
26
25
} ,
@@ -54,62 +53,59 @@ export default function Nav() {
54
53
} , [ ] ) ;
55
54
56
55
return (
57
- < header className = { styles . header } ref = { headerRef } >
56
+ < S . Header ref = { headerRef } >
58
57
< Container >
59
- < div ref = { containerRef } >
60
- < nav className = { styles . nav } >
58
+ < S . NavWrapper ref = { containerRef } $isSticky = { isSticky } >
59
+ < S . Nav $isSticky = { isSticky } >
61
60
< Link href = '/' >
62
- < img
63
- className = { styles . nav__logo }
61
+ < S . Logo
62
+ $isSticky = { isSticky }
64
63
src = '/images/svg/logo.svg'
65
64
alt = 'Logo'
66
65
title = 'Go to the Homepage'
67
66
/>
68
67
</ Link >
69
- < ul
70
- className = { `${ styles . nav__links } ${ active ? styles . active : '' } ` }
68
+ < S . Links
69
+ className = { `${ active ? 'active' : '' } ` }
70
+ $isSticky = { isSticky }
71
71
>
72
72
{ linksNav . map ( ( { text, href, id } ) => {
73
73
return (
74
- < li className = { styles . nav__item } key = { id } >
75
- < a
74
+ < S . Item key = { id } >
75
+ < S . Link
76
76
href = { href }
77
- className = { `${ styles . nav__link } ${
78
- router . pathname == href ? `${ styles . current } ` : ''
79
- } `}
77
+ $isSticky = { isSticky }
78
+ className = { `${ router . pathname == href ? `current` : '' } ` }
80
79
title = { text }
81
80
>
82
81
{ text }
83
- </ a >
84
- </ li >
82
+ </ S . Link >
83
+ </ S . Item >
85
84
) ;
86
85
} ) }
87
- < li className = { styles . nav__item } >
88
- < a
86
+ < S . Item >
87
+ < S . Button
88
+ $isSticky = { isSticky }
89
89
href = 'mailto:[email protected] ?subject=Project collaborator application'
90
- className = { `${ styles . nav__button } ${
91
- active ? styles . active : ''
92
- } `}
90
+ className = { `${ active ? `active` : '' } ` }
93
91
title = 'Join us'
94
92
>
95
93
Join us
96
- </ a >
97
- </ li >
98
- </ ul >
99
- < button
100
- className = { `${ styles . nav__hamburger } ${
101
- active ? styles . active : ''
102
- } `}
94
+ </ S . Button >
95
+ </ S . Item >
96
+ </ S . Links >
97
+ < S . Hamburger
98
+ className = { `${ active ? `active` : '' } ` }
103
99
onClick = { ( ) => setActive ( active => ! active ) }
104
100
aria-label = 'toggle navigation'
105
101
>
106
- < span className = { styles . nav__hamburger__bar } > </ span >
107
- < span className = { styles . nav__hamburger__bar } > </ span >
108
- < span className = { styles . nav__hamburger__bar } > </ span >
109
- </ button >
110
- </ nav >
111
- </ div >
102
+ < S . HamburgerBar $isSticky = { isSticky } > </ S . HamburgerBar >
103
+ < S . HamburgerBar $isSticky = { isSticky } > </ S . HamburgerBar >
104
+ < S . HamburgerBar $isSticky = { isSticky } > </ S . HamburgerBar >
105
+ </ S . Hamburger >
106
+ </ S . Nav >
107
+ </ S . NavWrapper >
112
108
</ Container >
113
- </ header >
109
+ </ S . Header >
114
110
) ;
115
111
}
0 commit comments