From c533860383e9645f09cc7ea096392bd0372d5fb8 Mon Sep 17 00:00:00 2001 From: bender Date: Sun, 14 Jun 2026 12:28:59 +0000 Subject: [PATCH] Update src/components/sections/hero/HeroVideoExpand.tsx --- .../sections/hero/HeroVideoExpand.tsx | 177 +++++------------- 1 file changed, 47 insertions(+), 130 deletions(-) diff --git a/src/components/sections/hero/HeroVideoExpand.tsx b/src/components/sections/hero/HeroVideoExpand.tsx index e0e7f08..abd44f0 100644 --- a/src/components/sections/hero/HeroVideoExpand.tsx +++ b/src/components/sections/hero/HeroVideoExpand.tsx @@ -1,146 +1,63 @@ -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, useCallback } from 'react'; +import { motion, AnimatePresence } from 'framer-motion'; -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; + videoUrl: 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); +export default function HeroVideoExpand({ title, description, videoUrl, onComplete }: HeroVideoExpandProps) { + const [isExpanded, setIsExpanded] = useState(false); - 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]); + const handleComplete = useCallback(() => { + if (onComplete) onComplete(); + }, [onComplete]); useEffect(() => { - const expandTimer = setTimeout(() => setExpanded(true), 600); - const hideTimer = setTimeout(() => { - setShowLoader(false); - onComplete?.(); - }, 1500); - return () => { - clearTimeout(expandTimer); - clearTimeout(hideTimer); - }; - }, []); + if (isExpanded) { + const timer = setTimeout(handleComplete, 3000); + return () => clearTimeout(timer); + } + }, [isExpanded, handleComplete]); return ( - <> - - {showLoader && ( - +
+ +

{title}

+

{description}

+
-
- -
-
+ + {isExpanded && ( setIsExpanded(false)} > - {title} + - -
- - - - - - - - - - -
-
-
- - + )} + +
+ ); -}; - -export default HeroVideoExpand; +} \ No newline at end of file