|
@ -1,13 +1,19 @@ |
|
|
import React, { useState, useEffect } from "react"; |
|
|
|
|
|
import { Container, Nav, Navbar } from "react-bootstrap"; |
|
|
|
|
|
import logo from "../assets/img/logo.svg"; |
|
|
|
|
|
import navIcon from "../assets/img/github.svg"; |
|
|
|
|
|
import linkedin from "../assets/img/linkedln.svg" |
|
|
|
|
|
|
|
|
// src/components/NavBar.js
|
|
|
|
|
|
import React, { useState, useEffect } from 'react'; |
|
|
|
|
|
import { Container, Nav, Navbar } from 'react-bootstrap'; |
|
|
|
|
|
import logo from '../assets/img/logo.svg'; |
|
|
|
|
|
import navIcon from '../assets/img/github.svg'; |
|
|
|
|
|
import linkedin from '../assets/img/linkedln.svg'; |
|
|
|
|
|
import ContactForm from './ContactForm'; |
|
|
|
|
|
|
|
|
const NavBar = () => { |
|
|
const NavBar = () => { |
|
|
const [activeLink, setActiveLink] = useState("home"); |
|
|
|
|
|
|
|
|
const [activeLink, setActiveLink] = useState('home'); |
|
|
const [scrolled, setScrolled] = useState(false); |
|
|
const [scrolled, setScrolled] = useState(false); |
|
|
|
|
|
const [showContactForm, setShowContactForm] = useState(false); |
|
|
|
|
|
|
|
|
|
|
|
const handleShowContactForm = () => setShowContactForm(true); |
|
|
|
|
|
const handleCloseContactForm = () => setShowContactForm(false); |
|
|
|
|
|
|
|
|
// Check for scrolling
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
const onScroll = () => { |
|
|
const onScroll = () => { |
|
|
if (window.scrollY > 50) { |
|
|
if (window.scrollY > 50) { |
|
@ -17,10 +23,9 @@ const NavBar = () => { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
window.addEventListener("scroll", onScroll); |
|
|
|
|
|
|
|
|
window.addEventListener('scroll', onScroll); |
|
|
|
|
|
|
|
|
// Remove event listener when component unmounts
|
|
|
|
|
|
return () => window.removeEventListener("scroll", onScroll); |
|
|
|
|
|
|
|
|
return () => window.removeEventListener('scroll', onScroll); |
|
|
}, []); |
|
|
}, []); |
|
|
|
|
|
|
|
|
const onUpdateLink = (value) => { |
|
|
const onUpdateLink = (value) => { |
|
@ -28,7 +33,7 @@ const NavBar = () => { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
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" /> |
|
@ -39,18 +44,18 @@ const NavBar = () => { |
|
|
<Nav.Link |
|
|
<Nav.Link |
|
|
href="#home" |
|
|
href="#home" |
|
|
className={ |
|
|
className={ |
|
|
activeLink === "home" ? "active navbar-link" : "navbar-link" |
|
|
|
|
|
|
|
|
activeLink === 'home' ? 'active navbar-link' : 'navbar-link' |
|
|
} |
|
|
} |
|
|
onClick={() => onUpdateLink("home")} |
|
|
|
|
|
|
|
|
onClick={() => onUpdateLink('home')} |
|
|
> |
|
|
> |
|
|
Home |
|
|
Home |
|
|
</Nav.Link> |
|
|
</Nav.Link> |
|
|
<Nav.Link |
|
|
<Nav.Link |
|
|
href="#projects" |
|
|
href="#projects" |
|
|
className={ |
|
|
className={ |
|
|
activeLink === "projects" ? "active navbar-link" : "navbar-link" |
|
|
|
|
|
|
|
|
activeLink === 'projects' ? 'active navbar-link' : 'navbar-link' |
|
|
} |
|
|
} |
|
|
onClick={() => onUpdateLink("projects")} |
|
|
|
|
|
|
|
|
onClick={() => onUpdateLink('projects')} |
|
|
> |
|
|
> |
|
|
Projects |
|
|
Projects |
|
|
</Nav.Link> |
|
|
</Nav.Link> |
|
@ -64,12 +69,13 @@ const NavBar = () => { |
|
|
<img src={linkedin} alt="linkedin Icon" /> |
|
|
<img src={linkedin} alt="linkedin Icon" /> |
|
|
</a> |
|
|
</a> |
|
|
</div> |
|
|
</div> |
|
|
<button className="vvd" onClick={() => console.log("connect")}> |
|
|
|
|
|
|
|
|
<button className="vvd" onClick={handleShowContactForm}> |
|
|
<span>Let's connect!</span> |
|
|
<span>Let's connect!</span> |
|
|
</button> |
|
|
</button> |
|
|
</span> |
|
|
</span> |
|
|
</Navbar.Collapse> |
|
|
</Navbar.Collapse> |
|
|
</Container> |
|
|
</Container> |
|
|
|
|
|
<ContactForm show={showContactForm} handleClose={handleCloseContactForm} /> |
|
|
</Navbar> |
|
|
</Navbar> |
|
|
); |
|
|
); |
|
|
}; |
|
|
}; |
|
|