import { useRef } from "react"; import { useScroll, useTransform, motion } from "motion/react"; import Button from "@/components/ui/Button"; import TextAnimation from "@/components/ui/TextAnimation"; import ImageOrVideo from "@/components/ui/ImageOrVideo"; type AboutTextFillProps = { tag?: string; title: string; description?: string; primaryButton?: { text: string; href: string }; secondaryButton?: { text: string; href: string }; textAnimation: "slide-up" | "fade-blur" | "fade"; } & ({ imageSrc: string; videoSrc?: never } | { videoSrc: string; imageSrc?: never }); const AboutTextFill = ({ tag, title, description, primaryButton, secondaryButton, imageSrc, videoSrc, textAnimation, }: AboutTextFillProps) => { const sectionRef = useRef(null); const words = title.split(" "); const { scrollYProgress } = useScroll({ target: sectionRef, offset: ["start 0.8", "start 0.2"], }); const Word = ({ word, index }: { word: string; index: number }) => { const start = index / words.length; const end = (index + 1) / words.length; const opacity = useTransform(scrollYProgress, [start, end], [0.15, 1]); return ( {word} ); }; return (
{tag && (

{tag}

)}

{words.map((word, i) => ( {i > 0 && " "} ))}

{description && ( )} {(primaryButton || secondaryButton) && (
{primaryButton &&
)}
); }; export default AboutTextFill;