-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nav.js
36 lines (31 loc) · 928 Bytes
/
Nav.js
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
import React from "react";
import "./Nav.css";
import { useState, useEffect } from "react";
function Nav() {
const [show, handleShow] = useState(false);
useEffect(() => {
window.addEventListener("scroll", () => {
if (window.scrollY > 100) {
handleShow(true);
} else handleShow(false);
});
return () => {
window.removeEventListener("scroll");
};
}, []);
return (
<div className={`nav ${show && "nav__black"}`}>
<img
className="nav__logo"
src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/08/Netflix_2015_logo.svg/1597px-Netflix_2015_logo.svg.png"
alt="Netflix Logo"
/>
<img
className="nav__avatar"
src="https://mir-s3-cdn-cf.behance.net/project_modules/disp/366be133850498.56ba69ac36858.png"
alt="Netflix Logo"
/>
</div>
);
}
export default Nav;