From 52b274853a61615de2159cb09241d5d2275bdb76 Mon Sep 17 00:00:00 2001 From: Nusab Taha Date: Sat, 31 Aug 2024 04:22:43 +0600 Subject: [PATCH] no cache --- components/Navbar.jsx | 22 +++++++++-- components/ProfileBody.jsx | 74 +++++++++++++++++++++-------------- components/ProfilePage.jsx | 4 +- components/Table.jsx | 4 +- helpers/getLeaderboardData.js | 20 +++------- helpers/makeRequest.js | 2 +- 6 files changed, 73 insertions(+), 53 deletions(-) diff --git a/components/Navbar.jsx b/components/Navbar.jsx index ce67d63..5951a3d 100644 --- a/components/Navbar.jsx +++ b/components/Navbar.jsx @@ -6,8 +6,23 @@ import Image from "next/image"; const Navbar = () => { const [theme, setTheme] = useState(null); + const [extraClass, setExtraClass] = useState(""); + const [scrollY, setScrollY] = useState(0); + // Hide Navbar on Scroll + useEffect(() => { + const handleScroll = () => { + setScrollY(window.scrollY); + if (scrollY > window.scrollY) { + setExtraClass(""); + } else { + setExtraClass("-translate-y-full"); + } + }; + window.addEventListener("scroll", handleScroll); + return () => window.removeEventListener("scroll", handleScroll); + }, [scrollY]); - // Do NOT even think about touching this useEffect hook. It's a mess. + // Do NOT even think about touching this useEffect hook. It's a mess. useEffect(() => { function changeTheme(newTheme) { const bodyTheme = document.documentElement.classList; @@ -42,9 +57,10 @@ const Navbar = () => { localStorage.setItem("theme", theme); }, [theme]); - return ( -