From 5b9ae1a6d4b33c03ee7f219ce4b9f5ab3f886719 Mon Sep 17 00:00:00 2001 From: donny Date: Thu, 28 May 2026 11:04:23 -0700 Subject: [PATCH] feat: clean up RotatingWord component styles --- components/content/RotatingWord.tsx | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 components/content/RotatingWord.tsx diff --git a/components/content/RotatingWord.tsx b/components/content/RotatingWord.tsx new file mode 100644 index 0000000..58130e8 --- /dev/null +++ b/components/content/RotatingWord.tsx @@ -0,0 +1,41 @@ +"use client"; + +import { useEffect, useState } from "react"; + +type RotatingWordProps = { + items: string[]; + intervalSeconds?: number; +}; + +export default function RotatingWord({ + items, + intervalSeconds = 2.5, +}: RotatingWordProps) { + const [activeIndex, setActiveIndex] = useState(0); + + useEffect(() => { + if (items.length <= 1) return; + const id = setInterval(() => { + setActiveIndex((i) => (i + 1) % items.length); + }, intervalSeconds * 1000); + return () => clearInterval(id); + }, [items.length, intervalSeconds]); + + return ( + + {items.map((word, i) => ( + + {word} + + ))} + + ); +}