/* global React */ const { useState: useStateQuote, useEffect: useEffectQuote } = React; function ImmersiveQuote({ quotes }) { const [i, setI] = useStateQuote(0); useEffectQuote(() => { const t = setInterval(() => setI(x => (x + 1) % quotes.length), 7000); return () => clearInterval(t); }, [quotes.length]); const move = (d) => setI(x => (x + d + quotes.length) % quotes.length); const q = quotes[i]; const total = String(quotes.length).padStart(2, '0'); const now = String(i + 1).padStart(2, '0'); return (
{q.before}{q.italic}{q.after}
{q.name} {q.role}
{now} / {total}
); } window.ImmersiveQuote = ImmersiveQuote;