chat app
chat app
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ChatApp</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"
rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?
family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
body {
.chat-height {
.message-input {
height: 4rem;
.typing-indicator::after {
content: '';
@keyframes typing {
0% { content: ''; }
</style>
</head>
<body class="bg-gray-50">
<div class="space-y-4">
<div id="login-form">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="mt-4">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Simulated data
{ id: 1, name: 'John Doe', lastMessage: 'Hello there!', time: '2m ago' },
{ id: 2, name: 'Jane Smith', lastMessage: 'How are you?', time: '1h ago' }
];
// Auth functions
function toggleAuth() {
document.getElementById('login-form').classList.toggle('hidden');
document.getElementById('register-form').classList.toggle('hidden');
function login() {
// Simulate login
document.getElementById('auth-screen').classList.add('hidden');
document.getElementById('chat-screen').classList.remove('hidden');
loadConversations();
function register() {
// Simulate registration
toggleAuth();
// Chat functions
function loadConversations() {
const conversationsList = document.getElementById('conversations-list');
<h4 class="font-semibold">${conv.name}</h4>
</div>
</div>
</div>
</div>
`).join('');
function loadChat(conversationId) {
${msg.text}
${msg.time}
</div>
</div>
</div>
`).join('');
messagesContainer.scrollTop = messagesContainer.scrollHeight;
function sendMessage() {
if (input.value.trim()) {
messages.push({
senderId: currentUser.id,
text: input.value,
});
input.value = '';
loadChat(1);
function showNewMessage() {
// Event listeners
sendMessage();
});
</script>
</body>
</html>