From 8cb3a38beb98824534de88f4c0a268abc9a3775a Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Mon, 7 Oct 2024 12:57:15 -0400 Subject: [PATCH] on this page scroll to top button Took 11 minutes --- src/components/on-this-page.tsx | 67 ++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/src/components/on-this-page.tsx b/src/components/on-this-page.tsx index b503e46..6038087 100644 --- a/src/components/on-this-page.tsx +++ b/src/components/on-this-page.tsx @@ -10,7 +10,7 @@ import { cn } from "@/lib/utils"; import { truncateText } from "@/lib/string"; import { motion, useInView } from "framer-motion"; import { Separator } from "@/components/ui/separator"; -import Image from "next/image"; +import { Button } from "@/components/ui/button"; type Header = { id: string; @@ -137,25 +137,50 @@ const OnThisPage = ({ page }: { page: DocsContentMetadata }): ReactElement => { ); }; -const Footer = ({ page }: { page: DocsContentMetadata }): ReactElement => ( - -); +const Footer = ({ page }: { page: DocsContentMetadata }): ReactElement => { + const [hasScrolled, setHasScrolled] = useState(false); + + useEffect(() => { + const handleScroll = () => setHasScrolled(window.scrollY > 400); + window.addEventListener("scroll", handleScroll); + return () => window.removeEventListener("scroll", handleScroll); + }, []); + + return ( + + ); +}; export default OnThisPage;