diff --git a/src/components/sections/hero/HeroVideoExpand.tsx b/src/components/sections/hero/HeroVideoExpand.tsx index e0e7f08..9e47478 100644 --- a/src/components/sections/hero/HeroVideoExpand.tsx +++ b/src/components/sections/hero/HeroVideoExpand.tsx @@ -1,146 +1,75 @@ -import { useEffect, useRef, useState } from "react"; -import { AnimatePresence, motion, useScroll, useTransform } from "motion/react"; -import ImageOrVideo from "@/components/ui/ImageOrVideo"; -import AutoFillText from "@/components/ui/AutoFillText"; -import { useButtonClick } from "@/hooks/useButtonClick"; +import { useState, useEffect, useRef } from 'react'; +import { motion, AnimatePresence } from 'framer-motion'; +import { X } from 'lucide-react'; -const StaggerText = ({ text }: { text: string }) => ( - - {[...text].map((char, index) => ( - - {char} - - ))} - -); - -type HeroVideoExpandProps = { +interface HeroVideoExpandProps { title: string; - primaryButton: { text: string; href: string }; - secondaryButton: { text: string; href: string }; + description: string; + videoSrc: string; + thumbnailSrc: string; onComplete?: () => void; -} & ({ imageSrc: string; videoSrc?: never } | { videoSrc: string; imageSrc?: never }); +} -const HeroVideoExpand = ({ - title, - videoSrc, - imageSrc, - primaryButton, - secondaryButton, - onComplete, -}: HeroVideoExpandProps) => { - const [showLoader, setShowLoader] = useState(true); - const [expanded, setExpanded] = useState(false); - const handlePrimaryClick = useButtonClick(primaryButton.href); - const handleSecondaryClick = useButtonClick(secondaryButton.href); - - const sectionRef = useRef(null); - const { scrollYProgress } = useScroll({ - target: sectionRef, - offset: ["start start", "end start"], - }); - const videoY = useTransform(scrollYProgress, [0, 1], ["0px", "150px"]); - const videoScale = useTransform(scrollYProgress, [0, 1], [1, 1.1]); +export default function HeroVideoExpand({ title, description, videoSrc, thumbnailSrc, onComplete }: HeroVideoExpandProps) { + const [isOpen, setIsOpen] = useState(false); + const videoRef = useRef(null); useEffect(() => { - const expandTimer = setTimeout(() => setExpanded(true), 600); - const hideTimer = setTimeout(() => { - setShowLoader(false); - onComplete?.(); - }, 1500); + if (isOpen && videoRef.current) { + videoRef.current.play().catch(console.error); + } return () => { - clearTimeout(expandTimer); - clearTimeout(hideTimer); + if (onComplete) onComplete(); }; - }, []); + }, [isOpen, onComplete]); return ( - <> - - {showLoader && ( - - - - - - )} - + + + + {title} + {description} + - - - + setIsOpen(true)} /> - - - - - - - - {title} - - - - - - - - - - - - - + setIsOpen(true)} + > + + - - > - ); -}; + -export default HeroVideoExpand; + + {isOpen && ( + + setIsOpen(false)} + className="absolute top-6 right-6 text-white p-2 hover:bg-white/10 rounded-full" + > + + + + + )} + + + ); +} \ No newline at end of file
{description}