import { useEffect, useRef } from "react" import gsap from "gsap" import { ScrollTrigger } from "gsap/ScrollTrigger" gsap.registerPlugin(ScrollTrigger) import { hexToRgb, lighten, toRGBA } from "./planHelpers" export function GradientMesh({ color }: { color?: string | null }) { const meshRef = useRef(null) const base = hexToRgb(color) const soft = lighten(base, 20) const pop = lighten(base, -20) useEffect(() => { if (!meshRef.current) return const blobs = meshRef.current.querySelectorAll('.blob') blobs.forEach((el, i) => { gsap.to(el, { x: gsap.utils.random(-30, 30), y: gsap.utils.random(-20, 20), rotate: gsap.utils.random(-6, 6), duration: gsap.utils.random(6, 10), ease: 'sine.inOut', yoyo: true, repeat: -1, delay: i * 0.2, }) }) return () => gsap.killTweensOf(blobs) }, [color]) return (
) }