Spaces:
Running
Running
File size: 27,819 Bytes
5059bfc b170f30 5059bfc b170f30 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>GlassChat iOS</title>
<!-- Google Fonts: Vazirmatn (for Persian support) and Inter -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Vazirmatn:wght@300;400;500;700&display=swap" rel="stylesheet">
<!-- FontAwesome CDN (Replacing truncated base64 to ensure icons work) -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* =========================================
USER PROVIDED CSS & UTILITIES
========================================= */
/* Tailwind Base Reset */
*, ::before, ::after {
box-sizing: border-box;
border-width: 0;
border-style: solid;
border-color: #e5e7eb;
}
body {
font-family: 'Inter', 'Vazirmatn', 'Tahoma', sans-serif;
background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%);
background-attachment: fixed;
-webkit-tap-highlight-color: transparent;
margin: 0;
padding: 0;
color: white;
height: 100vh;
overflow: hidden;
}
/* Glassmorphism Core */
.glass-panel {
background: rgba(255, 255, 255, 0.08);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.15);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}
.input-minimal {
background: rgba(0, 0, 0, 0.2);
border: 1px solid rgba(255, 255, 255, 0.1);
color: white;
transition: all 0.3s;
}
.input-minimal:focus {
background: rgba(0, 0, 0, 0.3);
border-color: rgba(255, 255, 255, 0.4);
outline: none;
box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}
.input-minimal::placeholder {
color: rgba(255, 255, 255, 0.5);
}
/* Message Bubbles */
.message-bubble-me {
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
border-radius: 18px 18px 4px 18px;
box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.message-bubble-other {
background: rgba(255, 255, 255, 0.12);
border-radius: 18px 18px 18px 4px;
border: 1px solid rgba(255, 255, 255, 0.05);
}
/* Animations */
.fade-in { animation: fadeIn 0.4s ease-out forwards; }
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.message-enter {
animation: messagePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes messagePop {
0% { opacity: 0; transform: scale(0.85) translateY(20px); }
100% { opacity: 1; transform: scale(1) translateY(0); }
}
/* Utility Classes Mapping */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.h-screen { height: 100vh; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.m-0 { margin: 0; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-full { border-radius: 9999px; }
.text-center { text-align: center; }
.text-white { color: white; }
.text-gray-300 { color: rgba(255,255,255, 0.7); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.font-bold { font-weight: bold; }
.font-medium { font-weight: 500; }
.cursor-pointer { cursor: pointer; }
.transition-all { transition: all 0.3s ease; }
.absolute { position: absolute; }
.relative { position: relative; }
.fixed { position: fixed; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }
.right-0 { right: 0; }
.z-50 { z-index: 50; }
.z-40 { z-index: 40; }
.z-30 { z-index: 30; }
.bg-white { background-color: white; }
.bg-blue-600 { background-color: #2563eb; }
.bg-slate-900 { background-color: #0f172a; }
.bg-white\/10 { background-color: rgba(255, 255, 255, 0.1); }
.border { border-width: 1px; }
.border-t { border-top-width: 1px; }
.border-b { border-bottom-width: 1px; }
.border-white\/10 { border-color: rgba(255, 255, 255, 0.1); }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
/* Custom Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }
/* =========================================
LAYOUT & RESPONSIVE
========================================= */
.app-container {
display: flex;
height: 100vh;
width: 100vw;
overflow: hidden;
}
/* Sidebar Styles */
.sidebar {
width: 320px;
display: flex;
flex-direction: column;
border-right: 1px solid rgba(255, 255, 255, 0.1);
background: rgba(20, 20, 40, 0.4);
backdrop-filter: blur(20px);
z-index: 20;
transition: transform 0.3s ease;
}
.chat-list-item {
padding: 1rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
cursor: pointer;
transition: background 0.2s;
display: flex;
align-items: center;
gap: 1rem;
}
.chat-list-item:hover, .chat-list-item.active {
background: rgba(255, 255, 255, 0.1);
}
.avatar {
width: 48px;
height: 48px;
border-radius: 50%;
object-fit: cover;
border: 2px solid rgba(255, 255, 255, 0.2);
}
.status-dot {
width: 12px;
height: 12px;
background-color: #10b981;
border: 2px solid #1e1b4b;
border-radius: 50%;
position: absolute;
bottom: 0;
right: 0;
}
.avatar-container {
position: relative;
}
/* Main Chat Area */
.main-chat {
flex: 1;
display: flex;
flex-direction: column;
position: relative;
background: rgba(0,0,0,0.2);
}
.chat-header {
padding: 1rem 1.5rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
background: rgba(30, 27, 75, 0.6);
backdrop-filter: blur(20px);
display: flex;
justify-content: space-between;
align-items: center;
}
.messages-container {
flex: 1;
padding: 1.5rem;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 1rem;
}
.input-area {
padding: 1rem;
background: rgba(30, 27, 75, 0.8);
backdrop-filter: blur(20px);
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
/* Sticker Picker */
.sticker-picker {
position: absolute;
bottom: 90px;
left: 20px;
right: 20px;
background: rgba(20, 20, 35, 0.95);
backdrop-filter: blur(25px);
border-radius: 20px;
padding: 15px;
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 10px;
max-height: 220px;
overflow-y: auto;
border: 1px solid rgba(255, 255, 255, 0.1);
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
z-index: 30;
transform-origin: bottom left;
transition: all 0.2s ease;
}
.sticker-picker.hidden {
transform: scale(0.9) translateY(20px);
opacity: 0;
pointer-events: none;
}
.sticker-item {
font-size: 28px;
display: flex;
align-items: center;
justify-content: center;
padding: 8px;
border-radius: 12px;
cursor: pointer;
transition: transform 0.1s;
}
.sticker-item:active { transform: scale(0.9); }
/* Mobile Responsive Logic */
.mobile-menu-btn { display: none; }
.sidebar-overlay { display: none; }
@media (max-width: 768px) {
.sidebar {
position: fixed;
top: 0;
right: 0;
height: 100vh;
width: 85%;
max-width: 320px;
transform: translateX(100%);
box-shadow: -10px 0 30px rgba(0,0,0,0.5);
}
.sidebar.open {
transform: translateX(0);
}
.sidebar-overlay {
display: block;
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(4px);
z-index: 15;
opacity: 0;
pointer-events: none;
transition: opacity 0.3s;
}
.sidebar-overlay.active {
opacity: 1;
pointer-events: auto;
}
.mobile-menu-btn {
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
border-radius: 50%;
background: rgba(255,255,255,0.1);
cursor: pointer;
}
.main-chat { width: 100%; }
}
/* Link Style */
.anycoder-link {
color: rgba(255,255,255,0.5);
text-decoration: none;
font-size: 0.75rem;
transition: color 0.3s;
}
.anycoder-link:hover { color: white; }
</style>
</head>
<body>
<div class="app-container">
<!-- Mobile Sidebar Overlay -->
<div class="sidebar-overlay" id="sidebarOverlay" onclick="toggleSidebar()"></div>
<!-- Sidebar -->
<aside class="sidebar glass-panel" id="sidebar">
<!-- Sidebar Header -->
<div class="p-4 border-b border-white/10 flex justify-between items-center">
<div class="flex items-center gap-2">
<i class="fa-solid fa-comments text-blue-400 text-xl"></i>
<h2 class="text-lg font-bold">Messages</h2>
</div>
<div class="flex gap-3 text-gray-300">
<i class="fa-solid fa-pen-to-square cursor-pointer hover:text-white transition-all"></i>
<i class="fa-solid fa-gear cursor-pointer hover:text-white transition-all"></i>
</div>
</div>
<!-- Search -->
<div class="p-4">
<div class="relative">
<i class="fa-solid fa-magnifying-glass absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 text-sm"></i>
<input type="text" placeholder="Search" class="w-full bg-white/5 border border-white/10 rounded-full py-2 pl-9 pr-4 text-sm text-white focus:outline-none focus:border-blue-400/50 transition-all">
</div>
</div>
<!-- Chat List -->
<div class="flex-1 overflow-y-auto" id="chatList">
<!-- Chat Item 1 -->
<div class="chat-list-item active" onclick="selectChat(0)">
<div class="avatar-container">
<img src="https://picsum.photos/seed/sarah/100/100" class="avatar" alt="User">
<div class="status-dot"></div>
</div>
<div class="flex-1 overflow-hidden">
<div class="flex justify-between items-center mb-1">
<h3 class="font-medium text-sm truncate">Sarah Connor</h3>
<span class="text-xs text-gray-400">10:42 AM</span>
</div>
<p class="text-xs text-gray-400 truncate">Are we still meeting for coffee?</p>
</div>
</div>
<!-- Chat Item 2 -->
<div class="chat-list-item" onclick="selectChat(1)">
<div class="avatar-container">
<img src="https://picsum.photos/seed/john/100/100" class="avatar" alt="User">
</div>
<div class="flex-1 overflow-hidden">
<div class="flex justify-between items-center mb-1">
<h3 class="font-medium text-sm truncate">John Wick</h3>
<span class="text-xs text-gray-400">Yesterday</span>
</div>
<p class="text-xs text-gray-400 truncate">I'll be back.</p>
</div>
</div>
<!-- Chat Item 3 -->
<div class="chat-list-item" onclick="selectChat(2)">
<div class="avatar-container">
<img src="https://picsum.photos/seed/ellon/100/100" class="avatar" alt="User">
<div class="status-dot" style="background-color: #f59e0b;"></div>
</div>
<div class="flex-1 overflow-hidden">
<div class="flex justify-between items-center mb-1">
<h3 class="font-medium text-sm truncate">Ellon Musk</h3>
<span class="text-xs text-gray-400">Mon</span>
</div>
<p class="text-xs text-gray-400 truncate">Sending you the designs now.</p>
</div>
</div>
<!-- Chat Item 4 -->
<div class="chat-list-item" onclick="selectChat(3)">
<div class="avatar-container">
<img src="https://picsum.photos/seed/alex/100/100" class="avatar" alt="User">
<div class="status-dot"></div>
</div>
<div class="flex-1 overflow-hidden">
<div class="flex justify-between items-center mb-1">
<h3 class="font-medium text-sm truncate">Alex Designer</h3>
<span class="text-xs text-gray-400">Sun</span>
</div>
<p class="text-xs text-gray-400 truncate">Check out this new glass effect!</p>
</div>
</div>
</div>
<!-- User Profile (Bottom Sidebar) -->
<div class="p-4 border-t border-white/10 flex items-center gap-3 cursor-pointer hover:bg-white/5 transition-all">
<img src="https://picsum.photos/seed/me/100/100" class="w-10 h-10 rounded-full border border-white/20">
<div class="flex-1">
<h4 class="text-sm font-medium">My Account</h4>
<p class="text-xs text-gray-400">Online</p>
</div>
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">
Built with anycoder
</a>
</div>
</aside>
<!-- Main Chat Area -->
<main class="main-chat">
<!-- Chat Header -->
<header class="chat-header">
<div class="flex items-center gap-3">
<div class="mobile-menu-btn" onclick="toggleSidebar()">
<i class="fa-solid fa-bars text-white"></i>
</div>
<div class="relative">
<img src="https://picsum.photos/seed/sarah/100/100" id="currentChatAvatar" class="w-10 h-10 rounded-full border border-white/20">
<div class="status-dot" id="currentChatStatus"></div>
</div>
<div>
<h2 class="font-bold text-base leading-tight" id="currentChatName">Sarah Connor</h2>
<p class="text-xs text-gray-400">Typing...</p>
</div>
</div>
<div class="flex gap-4 text-gray-300">
<i class="fa-solid fa-phone cursor-pointer hover:text-white transition-all"></i>
<i class="fa-solid fa-video cursor-pointer hover:text-white transition-all"></i>
<i class="fa-solid fa-circle-info cursor-pointer hover:text-white transition-all"></i>
</div>
</header>
<!-- Messages List -->
<div class="messages-container" id="messagesContainer">
<div class="text-center text-xs text-gray-500 my-4">Today</div>
<!-- Message Received -->
<div class="flex items-end gap-2 message-enter">
<img src="https://picsum.photos/seed/sarah/100/100" class="w-8 h-8 rounded-full mb-1">
<div class="message-bubble-other p-4 max-w-[75%]">
<p class="text-sm">Hey! Have you seen the new designs?</p>
</div>
</div>
<!-- Message Sent -->
<div class="flex items-end gap-2 justify-end message-enter" style="animation-delay: 0.1s;">
<div class="message-bubble-me p-4 max-w-[75%]">
<p class="text-sm">Yes, they look amazing! I love the glassmorphism style.</p>
</div>
</div>
<!-- Message Received -->
<div class="flex items-end gap-2 message-enter" style="animation-delay: 0.2s;">
<img src="https://picsum.photos/seed/sarah/100/100" class="w-8 h-8 rounded-full mb-1">
<div class="message-bubble-other p-4 max-w-[75%]">
<p class="text-sm">Great! Are we still meeting for coffee? ☕️</p>
</div>
</div>
</div>
<!-- Sticker Picker Overlay -->
<div class="sticker-picker hidden" id="stickerPicker">
<div class="sticker-item" onclick="sendSticker('😀')">😀</div>
<div class="sticker-item" onclick="sendSticker('😂')">😂</div>
<div class="sticker-item" onclick="sendSticker('😍')">😍</div>
<div class="sticker-item" onclick="sendSticker('🤔')">🤔</div>
<div class="sticker-item" onclick="sendSticker('👍')">👍</div>
<div class="sticker-item" onclick="sendSticker('🔥')">🔥</div>
<div class="sticker-item" onclick="sendSticker('❤️')">❤️</div>
<div class="sticker-item" onclick="sendSticker('🎉')">🎉</div>
<div class="sticker-item" onclick="sendSticker('🚀')">🚀</div>
<div class="sticker-item" onclick="sendSticker('💯')">💯</div>
<div class="sticker-item" onclick="sendSticker('🤖')">🤖</div>
<div class="sticker-item" onclick="sendSticker('💤')">💤</div>
</div>
<!-- Input Area -->
<div class="input-area">
<div class="flex items-center gap-3">
<div class="cursor-pointer text-gray-400 hover:text-yellow-400 transition-all text-xl" onclick="toggleStickers()">
<i class="fa-regular fa-face-smile"></i>
</div>
<div class="flex-1 relative">
<input type="text" id="messageInput" class="input-minimal w-full rounded-full py-3 px-5 text-sm" placeholder="Type a message..." autocomplete="off">
<i class="fa-solid fa-paperclip absolute right-4 top-1/2 transform -translate-y-1/2 text-gray-400 cursor-pointer hover:text-white"></i>
</div>
<button id="sendBtn" class="bg-blue-600 hover:bg-blue-500 text-white rounded-full w-12 h-12 flex items-center justify-center transition-all shadow-lg shadow-blue-600/30">
<i class="fa-solid fa-paper-plane text-sm"></i>
</button>
</div>
</div>
</main>
</div>
<script>
// DOM Elements
const messageInput = document.getElementById('messageInput');
const sendBtn = document.getElementById('sendBtn');
const messagesContainer = document.getElementById('messagesContainer');
const stickerPicker = document.getElementById('stickerPicker');
const sidebar = document.getElementById('sidebar');
const sidebarOverlay = document.getElementById('sidebarOverlay');
const chatListItems = document.querySelectorAll('.chat-list-item');
const currentChatName = document.getElementById('currentChatName');
const currentChatAvatar = document.getElementById('currentChatAvatar');
// Chat Data
const chats = [
{ name: "Sarah Connor", avatar: "https://picsum.photos/seed/sarah/100/100" },
{ name: "John Wick", avatar: "https://picsum.photos/seed/john/100/100" },
{ name: "Ellon Musk", avatar: "https://picsum.photos/seed/ellon/100/100" },
{ name: "Alex Designer", avatar: "https://picsum.photos/seed/alex/100/100" }
];
// Functions
function toggleSidebar() {
sidebar.classList.toggle('open');
sidebarOverlay.classList.toggle('active');
}
function toggleStickers() {
stickerPicker.classList.toggle('hidden');
}
function scrollToBottom() {
messagesContainer.scrollTop = messagesContainer.scrollHeight;
}
function createMessageElement(content, isMe = true, isSticker = false) {
const wrapper = document.createElement('div');
wrapper.className = `flex items-end gap-2 message-enter ${isMe ? 'justify-end' : ''}`;
let innerHTML = '';
if (isMe) {
innerHTML = `
<div class="message-bubble-me p-4 max-w-[75%] ${isSticker ? 'bg-transparent !border-0 !shadow-none !bg-none' : ''}">
${isSticker ? `<span style="font-size: 3rem;">${content}</span>` : `<p class="text-sm">${content}</p>`}
</div>
`;
} else {
innerHTML = `
<img src="${currentChatAvatar.src}" class="w-8 h-8 rounded-full mb-1">
<div class="message-bubble-other p-4 max-w-[75%] ${isSticker ? 'bg-transparent !border-0 !shadow-none' : ''}">
${isSticker ? `<span style="font-size: 3rem;">${content}</span>` : `<p class="text-sm">${content}</p>`}
</div>
`;
}
wrapper.innerHTML = innerHTML;
return wrapper;
}
function sendMessage() {
const text = messageInput.value.trim();
if (text) {
const msgEl = createMessageElement(text, true);
messagesContainer.appendChild(msgEl);
messageInput.value = '';
scrollToBottom();
// Simulate Reply
setTimeout(() => {
const replyEl = createMessageElement("That sounds great! 👍", false);
messagesContainer.appendChild(replyEl);
scrollToBottom();
}, 1500);
}
}
function sendSticker(emoji) {
const msgEl = createMessageElement(emoji, true, true);
messagesContainer.appendChild(msgEl);
stickerPicker.classList.add('hidden');
scrollToBottom();
}
function selectChat(index) {
// Update UI Active State
chatListItems.forEach(item => item.classList.remove('active'));
chatListItems[index].classList.add('active');
// Update Header Info
currentChatName.textContent = chats[index].name;
currentChatAvatar.src = chats[index].avatar;
// Clear current messages (simulation)
messagesContainer.innerHTML = `
<div class="text-center text-xs text-gray-500 my-4">Today</div>
<div class="flex items-center gap-2 justify-center opacity-50 my-10">
<img src="${chats[index].avatar}" class="w-16 h-16 rounded-full border-2 border-white/10">
</div>
<div class="text-center text-sm text-gray-300 mb-4">
Start of conversation with <br> <strong>${chats[index].name}</strong>
</div>
`;
// Close sidebar on mobile after selection
if (window.innerWidth <= 768) {
toggleSidebar();
}
}
// Event Listeners
sendBtn.addEventListener('click', sendMessage);
messageInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
sendMessage();
}
});
// Close sticker picker if clicking outside
document.addEventListener('click', (e) => {
if (!stickerPicker.contains(e.target) && !e.target.closest('.fa-face-smile')) {
stickerPicker.classList.add('hidden');
}
});
// Initial Scroll
scrollToBottom();
</script>
</body>
</html> |