import { useWebHaptics } from '@/hooks/use-web-haptics'; import { cn } from '@/lib/utils'; import { router } from '@inertiajs/react'; import { ArrowLeft } from 'lucide-react'; import { useEffect, useState } from 'react'; interface Props { href: string; className?: string; } export function MobileBackButton({ href, className }: Props) { const [isScrolled, setIsScrolled] = useState(false); const { trigger } = useWebHaptics(); useEffect(() => { function handleScroll() { setIsScrolled(window.scrollY > 40); } window.addEventListener('scroll', handleScroll, { passive: true }); handleScroll(); return () => window.removeEventListener('scroll', handleScroll); }, []); function handleBack() { trigger('light'); router.visit(href); } return ( <> {/* Floating button — visible when scrolled, top-right */}