"use client" import Button from "@components/button" import Tooltip from "@components/tooltip" import { useEffect, useState } from "react" import { ChevronUp } from "react-feather" import styles from "./scroll.module.css" const ScrollToTop = () => { const [shouldShow, setShouldShow] = useState(false) useEffect(() => { // if user is scrolled, set visible const handleScroll = () => { setShouldShow(window.scrollY > 100) } window.addEventListener("scroll", handleScroll) return () => window.removeEventListener("scroll", handleScroll) }, []) const isReducedMotion = typeof window !== "undefined" ? window.matchMedia("(prefers-reduced-motion: reduce)").matches : false const onClick = async (e: React.MouseEvent) => { e.currentTarget.blur() window.scrollTo({ top: 0, behavior: isReducedMotion ? "auto" : "smooth" }) } return (
) } export default ScrollToTop