'use client'; import { useEffect, useRef, useState } from 'react'; function cx(...args) { return args.filter(Boolean).join(' '); } export default function Reveal({ children, className, delay }) { const ref = useRef(null); const [visible, setVisible] = useState(false); useEffect(() => { const node = ref.current; if (!node) return undefined; let reduced = false; try { reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches; } catch (e) { // matchMedia unavailable - fall back to animating } if (reduced) { setVisible(true); return undefined; } const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { setVisible(true); observer.disconnect(); } }); }, { threshold: 0.15 } ); observer.observe(node); return () => observer.disconnect(); }, []); return (
{children}
); }