import React, { useState, useRef, useEffect } from 'react'; // --- Types --- type Message = { id: string; sender: 'user' | 'other'; senderName?: string; text: string; time: string; isReply?: boolean; replyTo?: { name: string; text: string }; }; // --- Test Data (From your HTML) --- const TEST_MESSAGES: Message[] = [ { id: '1', sender: 'other', senderName: 'Timothy Araujo', text: 'Life is sweet if you want it to be.', time: '21:39', }, { id: '2', sender: 'other', senderName: 'Timothy Araujo', text: 'All this work will pay off, it’s certain.', time: '21:39', }, { id: '3', sender: 'other', senderName: 'Simon Atanushe', text: 'That’s the way, my guy.', time: '21:39', isReply: true, replyTo: { name: 'Timothy Araujo', text: 'All this work will pay off, it’s certain.' }, }, { id: '4', sender: 'user', text: 'Life is sweet if you want it to be.', time: '21:39', }, { id: '5', sender: 'user', text: 'All this work will pay off, it’s certain.', time: '21:39', }, { id: '6', sender: 'other', senderName: 'Timothy Araujo', text: 'God is not wicked. 😭😭', time: '21:39', }, { id: '7', sender: 'other', senderName: 'Simon Atanushe', text: "Let's cook mfs. I have a gig tonight to build a creative asset for a startup. Need to work on it overnight", time: '21:39', isReply: true, replyTo: { name: 'Timothy Araujo', text: 'All this work will pay off, it’s certain.' }, }, { id: '8', sender: 'other', senderName: 'Jeremiah Annuit', text: "It's shopify marketing I want to be doing. All this code is not my concern.", time: '21:39', isReply: true, replyTo: { name: 'Timothy Araujo', text: 'All this work will pay off, it’s certain.' }, }, ]; // --- Components --- const PinnedMessage = () => (
Pinned Message

Me in the next 2 years

); const MessageBubble = ({ msg }: { msg: Message }) => { const isUser = msg.sender === 'user'; return (
{!isUser && (
)}
{/* Reply Context */} {msg.isReply && msg.replyTo && (

{msg.replyTo.name}

{msg.replyTo.text}

)} {/* Sender Name (Only for others) */} {!isUser && msg.senderName && ( {msg.senderName} )} {/* Message Text */}

{msg.text}

{/* Timestamp */}
{msg.time}
{/* SVG Tails (Exact Geometry from CSS) */} {!isUser && (
)} {isUser && (
)}
); }; const ScrollDownCircle = ({ onClick }: { onClick: () => void }) => ( ); // --- Main Container --- interface TestChatLayoutProps { testMode?: boolean; // Toggle testing on/off } const TestChatLayout = ({ testMode = true }: TestChatLayoutProps) => { const [messages, setMessages] = useState(testMode ? TEST_MESSAGES : []); const bottomRef = useRef(null); const scrollToBottom = () => { bottomRef.current?.scrollIntoView({ behavior: 'smooth' }); }; useEffect(() => { if (testMode) { setMessages(TEST_MESSAGES); } else { setMessages([]); } }, [testMode]); return (
{/* 1. Pinned Message */} {/* 2. Messages List */}
{messages.map((msg) => ( ))} {/* Empty State Helper */} {!testMode && messages.length === 0 && (
No messages (Test Mode Off)
)}
{/* 3. Scroll Down Circle */}
); }; export default TestChatLayout;