|
@ -1,17 +1,15 @@ |
|
|
import Container from 'react-bootstrap/Container'; |
|
|
|
|
|
import Nav from 'react-bootstrap/Nav'; |
|
|
|
|
|
import Navbar from 'react-bootstrap/Navbar'; |
|
|
|
|
|
import { useState, useEffect} from "react"; |
|
|
|
|
|
import logo from '../assets/img/logo.svg'; |
|
|
|
|
|
import navIcon1 from '../assets/img/nav-icon1.svg'; |
|
|
|
|
|
import navIcon3 from '../assets/img/nav-icon2.svg'; |
|
|
|
|
|
import navIcon2 from '../assets/img/nav-icon3.svg'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import React, { useState, useEffect } from "react"; |
|
|
|
|
|
import { Container, Nav, Navbar } from "react-bootstrap"; |
|
|
|
|
|
import logo from "../assets/img/logo.svg"; |
|
|
|
|
|
import navIcon1 from "../assets/img/nav-icon1.svg"; |
|
|
|
|
|
import navIcon2 from "../assets/img/nav-icon2.svg"; |
|
|
|
|
|
import navIcon3 from "../assets/img/nav-icon3.svg"; |
|
|
|
|
|
|
|
|
const NavBar = () => { |
|
|
const NavBar = () => { |
|
|
const [activeLink, setActiveLink] = useState('home'); |
|
|
|
|
|
|
|
|
const [activeLink, setActiveLink] = useState("home"); |
|
|
const [scrolled, setScrolled] = useState(false); |
|
|
const [scrolled, setScrolled] = useState(false); |
|
|
//check for scrolling
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check for scrolling
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
const onScroll = () => { |
|
|
const onScroll = () => { |
|
|
if (window.scrollY > 50) { |
|
|
if (window.scrollY > 50) { |
|
@ -19,43 +17,75 @@ const NavBar = () => { |
|
|
} else { |
|
|
} else { |
|
|
setScrolled(false); |
|
|
setScrolled(false); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
window.addEventListener("scroll", onScroll); |
|
|
window.addEventListener("scroll", onScroll); |
|
|
// remove event listener when components unmounts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Remove event listener when component unmounts
|
|
|
return () => window.removeEventListener("scroll", onScroll); |
|
|
return () => window.removeEventListener("scroll", onScroll); |
|
|
}, []) |
|
|
|
|
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
const onUpdateLink = (value) => { |
|
|
const onUpdateLink = (value) => { |
|
|
setActiveLink(value) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
setActiveLink(value); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<Navbar expand="lg" className= {scrolled ? "scrolled": ""}> |
|
|
|
|
|
|
|
|
<Navbar expand="lg" className={scrolled ? "scrolled" : ""}> |
|
|
<Container> |
|
|
<Container> |
|
|
<Navbar.Brand href="#home"> |
|
|
<Navbar.Brand href="#home"> |
|
|
<img src={logo} alt="logo" /> |
|
|
|
|
|
|
|
|
<img src={logo} alt="Logo" /> |
|
|
</Navbar.Brand> |
|
|
</Navbar.Brand> |
|
|
<Navbar.Toggle/> |
|
|
|
|
|
|
|
|
<Navbar.Toggle /> |
|
|
<Navbar.Collapse id="basic-navbar-nav"> |
|
|
<Navbar.Collapse id="basic-navbar-nav"> |
|
|
<Nav className="me-auto"> |
|
|
<Nav className="me-auto"> |
|
|
<Nav.Link href="#home" className={activeLink === 'home' ? 'active navbar-link': 'navbar-link'} onClick={() => onUpdateLink('home')}>Home</Nav.Link> |
|
|
|
|
|
<Nav.Link href="#skills" className={activeLink === 'home' ? 'active navbar-link': 'navbar-link'} onClick={() => onUpdateLink('skills')}>skills</Nav.Link> |
|
|
|
|
|
<Nav.Link href="#projects" className={activeLink === 'home' ? 'active navbar-link': 'navbar-link'} onClick={() => onUpdateLink('projects')}>Projects</Nav.Link> |
|
|
|
|
|
|
|
|
<Nav.Link |
|
|
|
|
|
href="#home" |
|
|
|
|
|
className={ |
|
|
|
|
|
activeLink === "home" ? "active navbar-link" : "navbar-link" |
|
|
|
|
|
} |
|
|
|
|
|
onClick={() => onUpdateLink("home")} |
|
|
|
|
|
> |
|
|
|
|
|
Home |
|
|
|
|
|
</Nav.Link> |
|
|
|
|
|
<Nav.Link |
|
|
|
|
|
href="#skills" |
|
|
|
|
|
className={ |
|
|
|
|
|
activeLink === "skills" ? "active navbar-link" : "navbar-link" |
|
|
|
|
|
} |
|
|
|
|
|
onClick={() => onUpdateLink("skills")} |
|
|
|
|
|
> |
|
|
|
|
|
Skills |
|
|
|
|
|
</Nav.Link> |
|
|
|
|
|
<Nav.Link |
|
|
|
|
|
href="#projects" |
|
|
|
|
|
className={ |
|
|
|
|
|
activeLink === "projects" ? "active navbar-link" : "navbar-link" |
|
|
|
|
|
} |
|
|
|
|
|
onClick={() => onUpdateLink("projects")} |
|
|
|
|
|
> |
|
|
|
|
|
Projects |
|
|
|
|
|
</Nav.Link> |
|
|
</Nav> |
|
|
</Nav> |
|
|
<span className="navbar-text"> |
|
|
<span className="navbar-text"> |
|
|
<div className="social-icon"> |
|
|
|
|
|
<a href="#"><img src={navIcon1} alt="nav-icon1" /></a> |
|
|
|
|
|
<a href="#"><img src={navIcon2} alt="nav-icon2" /></a> |
|
|
|
|
|
<a href="#"><img src={navIcon3} alt="nav-icon3" /></a> |
|
|
|
|
|
</div> |
|
|
|
|
|
<button className="vvd" onClick={() => console.log('connect')}> |
|
|
|
|
|
<span>Let's connect!</span> |
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
|
<div className="social-icon"> |
|
|
|
|
|
<a href="#"> |
|
|
|
|
|
<img src={navIcon1} alt="Social Icon 1" /> |
|
|
|
|
|
</a> |
|
|
|
|
|
<a href="#"> |
|
|
|
|
|
<img src={navIcon2} alt="Social Icon 2" /> |
|
|
|
|
|
</a> |
|
|
|
|
|
<a href="#"> |
|
|
|
|
|
<img src={navIcon3} alt="Social Icon 3" /> |
|
|
|
|
|
</a> |
|
|
|
|
|
</div> |
|
|
|
|
|
<button className="vvd" onClick={() => console.log("connect")}> |
|
|
|
|
|
<span>Let's connect!</span> |
|
|
|
|
|
</button> |
|
|
</span> |
|
|
</span> |
|
|
</Navbar.Collapse> |
|
|
</Navbar.Collapse> |
|
|
</Container> |
|
|
</Container> |
|
|
</Navbar> |
|
|
</Navbar> |
|
|
); |
|
|
); |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
export default NavBar; |
|
|
|
|
|
|
|
|
export default NavBar; |