import React, { useRef } from 'react'; import { motion, useScroll, useTransform, Variants, useInView } from 'framer-motion'; import { WarpOverlay, SandOverlay } from './VisualEffects'; export type TransitionType = | 'warp' | 'wipe-right' | 'shutters' | 'paint-ripple' | 'sand' | 'slide' | 'gradient'; interface Props { children: React.ReactNode; id: string; className?: string; transparent?: boolean; transitionEffect?: TransitionType; fitScreen?: boolean; } const SectionWrapper: React.FC = ({ children, id, className = "", transparent = false, transitionEffect = 'slide', fitScreen = true }) => { const ref = useRef(null); const isInView = useInView(ref, { amount: 0.2 }); // Parallax Logic const { scrollYProgress } = useScroll({ target: ref, offset: ["start end", "end start"] }); const y = useTransform(scrollYProgress, [0, 1], ["5%", "-5%"]); const smoothEase: [number, number, number, number] = [0.645, 0.045, 0.355, 1.000]; // --- RENDER OVERLAYS BASED ON TYPE --- const renderOverlay = () => { switch (transitionEffect) { case 'warp': return ( {/* Only render WarpOverlay when in view to restart the animation/canvas clock */} {isInView && } ); case 'wipe-right': return ( <> ); case 'shutters': return (
{[0, 1, 2, 3].map((i) => ( ))}
); case 'paint-ripple': return ( <> {/* The Drop */} {/* The Ripple */} ); case 'gradient': return ( ); case 'sand': return ( ) case 'slide': return ( ); default: return null; } }; // --- CONTENT VARIANTS --- const getContentVariants = (): Variants | undefined => { if (transitionEffect === 'sand') { return { hidden: { opacity: 0, scale: 0.95, filter: "blur(10px)" }, visible: { opacity: 1, scale: 1, filter: "blur(0px)", transition: { duration: 1.2, ease: "easeOut" } } }; } return undefined; }; return (
{renderOverlay()} {children}
); }; export default SectionWrapper;