import { Tooltip, Button, Spacer } from '@geist-ui/core' import ChevronUp from '@geist-ui/icons/chevronUpCircleFill' import { useEffect, useState } from 'react' 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 onClick = (e: React.MouseEvent) => { // blur the button e.currentTarget.blur() window.scrollTo({ top: 0, behavior: 'smooth' }) } return (
) } export default ScrollToTop