Skip to content

Commit

Permalink
#26 updating window functionality to deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
samgildea committed Apr 2, 2021
1 parent 61d334e commit 2847689
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/components/header/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ import {

export const Header = () => {
const [open, setOpen] = useState(false)
const [colorChange, setColorchange] = useState(false)
const changeNavbarColor = () => {
if (typeof window !== "undefined" && window.scrollY >= 80) {
setColorchange(true)
} else {
setColorchange(false)
}
}
window.addEventListener("scroll", changeNavbarColor)
const [colorChange, setColorchange] = useState(false);
const changeNavbarColor = () =>{
if(typeof window !== "undefined" && window.scrollY >= 80){
setColorchange(true);
}
else{
setColorchange(false);
}
};
window.addEventListener('scroll', changeNavbarColor);


return (
<NavContainer className={colorChange ? "navbar colorChange" : "navbar"}>
<NavContainer className={colorChange ? 'navbar colorChange' : 'navbar'}>
<Logo>PowerHouse</Logo>

<MobileIcon onClick={() => setOpen(!open)} className={open ? "open" : ""}>
Expand Down

0 comments on commit 2847689

Please sign in to comment.