import { cn } from "@/lib/utils"; import { ReactNode, useEffect, useState } from "react"; type Props = { threshold?: number; behavior?: ScrollBehavior; children: ReactNode; classes?: { onVisibleClasses?: string; onHiddenClasses?: string; generalClasses?: string; }; }; export default function GoToTopBase(props: Props) { const { threshold = 300, behavior = "smooth", children, classes } = props; const [visible, setVisible] = useState(false); useEffect(() => { const handleScroll = () => { setVisible(window.scrollY > threshold); }; window.addEventListener("scroll", handleScroll); return () => { window.removeEventListener("scroll", handleScroll); }; }, [threshold]); const scrollToTop = () => { window.scrollTo({ top: 0, behavior, }); }; return ( ); }