UNPKG

@primer/react-brand

Version:

Primer Brand is a GitHub's design system for creating React-based marketing websites and digital experiences.

31 lines (30 loc) 916 B
import { useEffect as e, useRef as t, useState as n } from "react"; //#region src/animation/TextRevealAnimation/useTextRevealAnimationLines.ts var r = (r, i) => { let a = t(null), o = i ?? a, [s, c] = n(); return e(() => { !o.current || !r || (() => { let e = o.current; if (!e || !r) return; let t = window.getComputedStyle(e).color; e.style.color = "transparent", e.textContent = ""; let n = r.split(" "), i = [], a = 0, s = []; for (let t of n) { e.textContent += `${t} `; let n = e.offsetHeight; if (s.length === 0) { a = n, s.push([t]); continue; } n > a ? (i.push(s.length), s.push([t])) : s.at(-1)?.push(t), a = n; } e.style.color = t, e.textContent = "", c(s.map((e) => e.join(" "))); })(); }, [r, o]), { ref: o, lines: s }; }; //#endregion export { r as useTextRevealAnimationLines }; //# sourceMappingURL=useTextRevealAnimationLines.js.map