import { useState, useEffect } from 'react'; import { ChevronUp } from 'lucide-react'; import { useAppSettings } from '../context/AppSettingsContext'; export default function ScrollToTopButton() { const { settings } = useAppSettings(); const [isVisible, setIsVisible] = useState(false); useEffect(() => { const toggleVisibility = () => { // Show button when scrolled past configured threshold if (window.scrollY > window.innerHeight * settings.scrollToTopThreshold) { setIsVisible(true); } else { setIsVisible(false); } }; window.addEventListener('scroll', toggleVisibility); return () => window.removeEventListener('scroll', toggleVisibility); }, [settings.scrollToTopThreshold]); const scrollToTop = () => { window.scrollTo({ top: 0, behavior: 'smooth', }); }; if (!isVisible) return null; return ( ); }