From 433eac58f1178093c3c76a323fc0509a3a728f16 Mon Sep 17 00:00:00 2001 From: Glen Maddern Date: Fri, 20 Jun 2025 21:05:39 +1000 Subject: [PATCH] Add random starting point for hue-rotate animation - Generate random negative animation-delay between 0 and -60 seconds - Starts animation at random point in the 60-second cycle - Each page load will show different initial colors - Uses useState with initializer function to set delay once on mount - CSS doesn't have random functions, so JavaScript handles the randomization --- examples/chat-ui/src/components/ChatApp.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/chat-ui/src/components/ChatApp.tsx b/examples/chat-ui/src/components/ChatApp.tsx index 256afc4..ad1f614 100644 --- a/examples/chat-ui/src/components/ChatApp.tsx +++ b/examples/chat-ui/src/components/ChatApp.tsx @@ -22,6 +22,7 @@ const ChatApp: React.FC = () => { const [selectedModel, setSelectedModel] = useState(getSelectedModel()); const [apiKeyUpdateTrigger, setApiKeyUpdateTrigger] = useState(0); const [mcpTools, setMcpTools] = useState([]); + const [animationDelay] = useState(() => -Math.random() * 60); const db = useIndexedDB(); const handleApiKeyUpdate = () => { @@ -102,7 +103,10 @@ const ChatApp: React.FC = () => { }; return ( -
+
{/* Sidebar and Navbar components hidden but kept in codebase */} {false && (