import { Fragment } from "react"; // Wraps each word (and optionally each letter) in spans so headings can be revealed and animated. // The heading itself should carry the full text as its aria-label; these spans are hidden from screen readers. export function SplitWords({ text, letters }: { text: string; letters?: boolean }) { const words = text.trim().split(/\s+/); return ( <> {words.map((word, i) => ( {letters ? [...word].map((c, j) => ( {c} )) : word} {i < words.length - 1 ? " " : null} ))} ); }