|
1 | 1 | import React, { useState, useEffect } from 'react';
|
2 |
| -import './Navbar.css' |
3 |
| -import fullogo from '../full-logo.png' |
| 2 | +import './Navbar.css'; |
| 3 | +import fullogo from '../full-logo.png'; |
| 4 | +import { Link } from 'react-scroll'; |
4 | 5 | const Navbar = () => {
|
5 | 6 | const [sticky, setSticky] = useState(false);
|
| 7 | + |
6 | 8 | useEffect(() => {
|
7 |
| - window.addEventListener('scroll', () => { |
| 9 | + const handleScroll = () => { |
8 | 10 | window.scrollY > 50 ? setSticky(true) : setSticky(false);
|
9 |
| - }) |
| 11 | + }; |
| 12 | + |
| 13 | + window.addEventListener('scroll', handleScroll); |
| 14 | + |
| 15 | + // Cleanup the event listener on component unmount |
| 16 | + return () => { |
| 17 | + window.removeEventListener('scroll', handleScroll); |
| 18 | + }; |
10 | 19 | }, []);
|
| 20 | + |
11 | 21 | return (
|
12 |
| - <nav className={`container ${sticky? 'dark-nav': ''}`}> |
13 |
| - <img src={fullogo} alt="" className="logo" /> |
| 22 | + <nav className={`container ${sticky ? 'dark-nav' : ''}`}> |
| 23 | + <img src={fullogo} alt="NepTech Tribe Logo" className="logo" /> |
14 | 24 | {/* <h1 className='logo'>NepTech Tribe</h1> */}
|
15 | 25 | <ul className="hide-mobile-menu">
|
16 |
| - <li><a>Home</a></li> |
17 |
| - <li><a>Gallery</a></li> |
18 |
| - <li><a>About us</a></li> |
19 |
| - <li><a>Upcoming Events</a></li> |
20 |
| - |
21 |
| - <li><a className="btn">Contact us</a></li> |
| 26 | + <li><Link to="hero" smooth="true" offset={0} duration={500}>Home</Link></li> |
| 27 | + <li><Link to="album" smooth="true" offset={0} duration={500}>Gallery</Link></li> |
| 28 | + <li><Link to="about" smooth="true" offset={0} duration={500}>About us</Link></li> |
| 29 | + <li><Link to="events" smooth="true" offset={0} duration={500}>Upcoming Events</Link></li> |
| 30 | + <li><Link to="contact" className="btn" smooth="true" offset={0} duration={500}>Contact us</Link></li> |
22 | 31 | </ul>
|
23 | 32 | </nav>
|
24 |
| - ) |
25 |
| -} |
| 33 | + ); |
| 34 | +}; |
26 | 35 |
|
27 |
| -export default Navbar |
| 36 | +export default Navbar; |
0 commit comments