"use client" import { useRef } from "react" import { motion, useReducedMotion, useScroll, useTransform, type MotionValue, } from "motion/react" import { cn } from "@/lib/utils" function Word({ children, progress, range, }: { children: string progress: MotionValue range: [number, number] }) { const opacity = useTransform(progress, range, [0.14, 1]) return ( {children}{" "} ) } /** A statement whose words light up one after another while scrolling. */ export function ScrollStatement({ text, className, }: { text: string className?: string }) { const ref = useRef(null) const reduced = useReducedMotion() const { scrollYProgress } = useScroll({ target: ref, offset: ["start 0.85", "end 0.5"], }) const words = text.split(" ") if (reduced) { return (

{text}

) } return (

{words.map((word, index) => ( {word} ))}

) }