"use client"; import GenericButton from "@/components/GenericButton"; import { ArrowLongLeftIcon, ArrowSmallUpIcon } from "@heroicons/react/24/solid"; import Link from "next/link"; import { ReactNode, useEffect, useState } from "react"; interface Props { children: ReactNode; } const ArticlesLayout = ({ children }: Props) => { const [isTopOfPage, setIsTopOfPage] = useState(true); useEffect(() => { const handleScroll = () => { if (window.scrollY <= 500) { setIsTopOfPage(true); } else { setIsTopOfPage(false); } }; window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, []); return (
{" "} View all Articles {children} {" "} View all Articles {/* For some reason if I use a here it doesn't scroll all the way to the top of the page. */} {isTopOfPage ? ( <> ) : (
To Top
)}
); }; export default ArticlesLayout;