From 0df7ceb635e56f1f34436c1973655acfad415d16 Mon Sep 17 00:00:00 2001 From: bender Date: Sun, 21 Jun 2026 14:12:33 +0000 Subject: [PATCH] Update src/components/sections/hero/HeroExpand.tsx --- src/components/sections/hero/HeroExpand.tsx | 169 +++++--------------- 1 file changed, 38 insertions(+), 131 deletions(-) diff --git a/src/components/sections/hero/HeroExpand.tsx b/src/components/sections/hero/HeroExpand.tsx index dedb1fc..e5f2eb3 100644 --- a/src/components/sections/hero/HeroExpand.tsx +++ b/src/components/sections/hero/HeroExpand.tsx @@ -1,146 +1,53 @@ -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 HeroExpandProps = { +interface HeroExpandProps { title: string; - primaryButton: { text: string; href: string }; - secondaryButton: { text: string; href: string }; + description: string; onComplete?: () => void; -} & ({ imageSrc: string; videoSrc?: never } | { videoSrc: string; imageSrc?: never }); +} -const HeroExpand = ({ - title, - videoSrc, - imageSrc, - primaryButton, - secondaryButton, - onComplete, -}: HeroExpandProps) => { - 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 HeroExpand({ title, description, onComplete }: HeroExpandProps) { + const [isExpanded, setIsExpanded] = useState(false); + + 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) { + handleComplete(); + } + }, [isExpanded, handleComplete]); return ( - <> +
+ + {title} + +

{description}

+ - {showLoader && ( + {isExpanded && ( - - - + Additional content revealed here! )} - -
- - - - -
- -
-
- - {title} - - -
- - - - - - - - - - -
-
-
-
- +
); -}; - -export default HeroExpand; +} \ No newline at end of file