-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavbar.jsx
89 lines (75 loc) · 2.67 KB
/
Navbar.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import React, {useEffect, useState} from 'react'
import {Link} from 'react-router-dom';
import {styles} from '../styles';
import {navLinks} from '../constants';
import {logo,menu, close} from '../assets';
const Navbar = () => {
const [active, setActive] = useState('');
const [toggle, setToggle] = useState(false);
return (
<nav
className={`${styles.paddingX} w-full flex items-center py-5 fixed top-0 z-20 bg-primary`}
>
<div className="w-full flex justify-between items-center max-w-7x1 mx-auto">
<Link
to="/"
className='flex items-center gap-2'
onClick={() => {
setActive("");
window.scrollTo(0,0);
}}
>
<img src={logo} alt='logo' className="w-9 h-9 object-contain" />
<p className="text-white text-[18px] font-bold cursor-pointer flex">
Raizan
<span className="sm:block hidden">| Software Developer</span>
</p>
</Link>
<ul className='list-none hidden sm:flex flex-row gap-10'>
{navLinks.map((link) => (
<li
key={link.id}
className={`${
active === link.title
? "text-white"
: "text-secondary"
} hover:text-white text=[18px] font-medium cursor-pointer`}
onClick={() => setActive(link.title)}
>
<a href={`#${link.id}`}>{link.title}</a>
</li>
))}
</ul>
<div className="sm:hidden flex flex-1 justify-end items-center">
<img
src={toggle ? close : menu}
alt = "menu"
className="w-[28px] h-[28px] object-contain cursor-pointer"
onClick={() => setToggle(!toggle)}
/>
<div className={`${!toggle ? 'hidden' : 'flex'} p-6 black-gradient absolute top-20 right-0 mx-4 my-2 min-w-[140px] z-10 rounded-xl`}>
<ul className='list-none flex sm:flex justify-end items-start flex-col gap--4'>
{navLinks.map((link) => (
<li
key={link.id}
className={`${
active === link.title
? "text-white"
: "text-secondary"
} font-poppins font-medium cursor-pointer text-[16px]`}
onClick={() => {
setToggle(!toggle);
setActive(link.title);
}}
>
<a href={`#${link.id}`}>{link.title}</a>
</li>
))}
</ul>
</div>
</div>
</div>
</nav>
)
}
export default Navbar