Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alanthomas-0 committed Aug 18, 2024
1 parent 72d4aff commit 85d1f65
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions a.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo "node_modules/" > .gitignore
17 changes: 17 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Chat App</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="chat-container">
<div id="messages"></div>
<input type="text" id="message-input" placeholder="Type a message..." />
<button id="send-button">Send</button>
</div>
<script src="script.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
document.getElementById('send-button').addEventListener('click', sendMessage);
document.getElementById('message-input').addEventListener('keypress', function (e) {
if (e.key === 'Enter') {
sendMessage();
}
});

function sendMessage() {
const messageInput = document.getElementById('message-input');
const messageText = messageInput.value.trim();

if (messageText !== '') {
const messageElement = document.createElement('div');
messageElement.textContent = messageText;
document.getElementById('messages').appendChild(messageElement);

messageInput.value = '';
messageInput.focus();
}
}
35 changes: 35 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}

#chat-container {
width: 300px;
background: white;
padding: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
border-radius: 5px;
}

#messages {
height: 200px;
overflow-y: auto;
border: 1px solid #ddd;
padding: 5px;
margin-bottom: 10px;
}

#message-input {
width: calc(100% - 60px);
padding: 5px;
margin-right: 5px;
}

#send-button {
width: 50px;
}

0 comments on commit 85d1f65

Please sign in to comment.