diff --git a/src/App.jsx b/src/App.jsx index 05bd8ce..1c3ce88 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState } from "react"; import { BrowserRouter } from "react-router-dom"; import { About, @@ -16,12 +16,14 @@ import Footer from "./components/Footer"; // App const App = () => { + const [hide, setHide] = useState(true); + return ( - +
- +
diff --git a/src/components/Banner.jsx b/src/components/Banner.jsx index cb13b82..a880bee 100644 --- a/src/components/Banner.jsx +++ b/src/components/Banner.jsx @@ -1,11 +1,9 @@ -import React, { useEffect, useState } from "react"; +import React, { useEffect } from "react"; import { Link } from "react-router-dom"; import { close, bulb } from "../assets"; -const Banner = () => { - const [hide, setHide] = useState(true); - +const Banner = ({ hide, setHide }) => { useEffect(() => { const bannerTimer = setTimeout(() => { setHide(false); diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index ee00262..093449a 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { Link } from "react-router-dom"; import { styles } from "../styles"; @@ -7,16 +7,33 @@ import { logo, menu, close } from "../assets"; import { cn } from "../utils/lib"; // Navbar -const Navbar = () => { +const Navbar = ({ hide }) => { // state variables const [active, setActive] = useState(""); const [toggle, setToggle] = useState(false); + const [isAtBottom, setIsAtBottom] = useState(false); + + useEffect(() => { + const handleScroll = () => { + console.log(window.scrollY); + if (window.scrollY > 10) { + setIsAtBottom(true); + } else { + setIsAtBottom(false); + } + }; + + window.addEventListener("scroll", handleScroll); + + return () => window.removeEventListener("scroll", handleScroll); + }, []); return (