diff --git a/src/components/ScrollToTop.tsx b/src/components/ScrollToTop.tsx new file mode 100644 index 0000000..c8b80e3 --- /dev/null +++ b/src/components/ScrollToTop.tsx @@ -0,0 +1,25 @@ +'use client' + +import { useEffect, useState } from 'react' + +export default function ScrollToTop() { + const [visible, setVisible] = useState(false) + + useEffect(() => { + const onScroll = () => setVisible(window.scrollY > 400) + window.addEventListener('scroll', onScroll) + return () => window.removeEventListener('scroll', onScroll) + }, []) + + if (!visible) return null + + return ( +