'use client'; import * as React from 'react'; import { motion, useInView, type HTMLMotionProps, type Transition, type UseInViewOptions, } from 'motion/react'; import { cn } from '@workspace/ui/lib/utils'; type HighlightTextProps = HTMLMotionProps<'span'> & { text: string; inView?: boolean; inViewMargin?: UseInViewOptions['margin']; inViewOnce?: boolean; transition?: Transition; }; function HighlightText({ ref, text, className, inView = false, inViewMargin = '0px', transition = { duration: 2, ease: 'easeInOut' }, ...props }: HighlightTextProps) { const localRef = React.useRef(null); React.useImperativeHandle(ref, () => localRef.current as HTMLSpanElement); const inViewResult = useInView(localRef, { once: true, margin: inViewMargin, }); const isInView = !inView || inViewResult; return ( {text} ); } export { HighlightText, type HighlightTextProps };