Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Telegram Clone #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Telegram/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
<title>Telegram UI Clone</title>
</head>
<body class="flex bg-gray-200 h-screen">
<div class="bg-white w-1/3 border-r border-gray-300 p-4">
<h1 class="text-2xl font-bold mb-4">Chats</h1>
<div id="chat-list">
<div class="chat-item cursor-pointer p-2 hover:bg-gray-100">John Doe</div>
<div class="chat-item cursor-pointer p-2 hover:bg-gray-100">Jane Smith</div>
<div class="chat-item cursor-pointer p-2 hover:bg-gray-100">Group Chat</div>
</div>
</div>

<div class="flex-1 p-4">
<div id="chat-window" class="bg-white h-full rounded-lg shadow-md p-4 overflow-y-auto">
<h2 class="text-xl font-bold mb-2">Chat with John Doe</h2>
<div id="messages" class="flex flex-col">
<!-- Messages will be appended here -->
</div>
</div>
<div class="mt-4">
<input type="text" id="message-input" class="border rounded w-full p-2" placeholder="Type a message">
<button id="send-button" class="bg-blue-500 text-white rounded p-2 mt-2 w-full">Send</button>
</div>
</div>

<script src="script.js"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions Telegram/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
document.getElementById('send-button').addEventListener('click', function() {
const input = document.getElementById('message-input');
const message = input.value;

if (message.trim() === '') {
return; // Don't send empty messages
}

const messagesContainer = document.getElementById('messages');
const newMessage = document.createElement('div');
newMessage.className = 'bg-blue-100 p-2 my-1 rounded-lg';
newMessage.innerText = message;

messagesContainer.appendChild(newMessage);
input.value = ''; // Clear the input
messagesContainer.scrollTop = messagesContainer.scrollHeight; // Scroll to the bottom
});