Design and implement a real-time chat interface with message history and user presence
Build a modern chat interface that displays messages in real-time, shows typing indicators, and includes features like message reactions and user status.
To get started, you can use the following code snippet to structure messages:
function addMessage(text, sender, timestamp) {
const messageDiv = document.createElement('div');
messageDiv.className = `message ${sender === 'me' ? 'sent' : 'received'}`;
messageDiv.innerHTML = `
<div class="message-content">${text}</div>
<div class="message-time">${formatTime(timestamp)}</div>
`;
document.getElementById('chat-messages').appendChild(messageDiv);
scrollToBottom();
}