"use client"; import { useState, useRef, useCallback } from "react"; interface MagicRevealProps { avantLabel: string; apresLabel: string; avantColor?: string; apresColor?: string; height?: string; } export default function MagicReveal({ avantLabel, apresLabel, avantColor = "bg-red-50", apresColor = "bg-green-50", height = "h-64", }: MagicRevealProps) { const [position, setPosition] = useState(50); const containerRef = useRef(null); const dragging = useRef(false); const updatePosition = useCallback((clientX: number) => { if (!containerRef.current) return; const rect = containerRef.current.getBoundingClientRect(); const x = clientX - rect.left; const percent = Math.max(0, Math.min(100, (x / rect.width) * 100)); setPosition(percent); }, []); const handlePointerDown = useCallback((e: React.PointerEvent) => { dragging.current = true; (e.target as HTMLElement).setPointerCapture(e.pointerId); updatePosition(e.clientX); }, [updatePosition]); const handlePointerMove = useCallback((e: React.PointerEvent) => { if (!dragging.current) return; updatePosition(e.clientX); }, [updatePosition]); const handlePointerUp = useCallback(() => { dragging.current = false; }, []); return (
{/* Apr\u00e8s (fond complet) */}

Apr\u00e8s

{apresLabel}

{/* Avant (clip\u00e9 \u00e0 gauche) */}

Avant

{avantLabel}

{/* Barre de s\u00e9paration */}
{/* Labels gauche/droite */}
AVANT
APR\u00c8S
); }