import { chakra } from '@chakra-ui/react'; import { Icon } from '@iconify/react/offline'; import upOutlined from '@iconify-icons/ant-design/up-outlined'; import { t } from '@/i18n'; import useScrolledPast from '@/hooks/useScrolledPast'; import { backToTopThreshold } from '@/lib/backToTopThreshold'; // Buiten het component, zodat de functie stabiel is voor useScrolledPast const threshold = () => backToTopThreshold(window.innerHeight); // Afstand tot de rand zoals in het design. Op hele brede schermen lijnt de // knop uit met de rand van de content in plaats van de hoek van het scherm. const EDGE = 'clamp(1rem, 3vw, 2rem)'; // Vaste knop rechtsonder om terug naar boven te gaan (FR-06, BR-TOP-*) export default function BackToTop() { const visible = useScrolledPast(threshold); const scrollToTop = () => { const reduced = window.matchMedia( '(prefers-reduced-motion: reduce)', ).matches; window.scrollTo({ top: 0, behavior: reduced ? 'instant' : 'smooth' }); // De knop verdwijnt bovenaan; de focus gaat naar de inhoud document.getElementById('main')?.focus({ preventScroll: true }); }; return ( ); }