Skip to content

Commit

Permalink
Add autoscroll and title, fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
kova98 committed Oct 19, 2023
1 parent 3da0a1b commit 6fe229e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions web-client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function handleChatMessage(messageObject) {

const messages = document.getElementById('messages');
messages.appendChild(message);
messages.scrollTop = messages.scrollHeight
}

function sendMessage() {
Expand Down
3 changes: 2 additions & 1 deletion web-client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebSocket Chat</title>
<title>Chat</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>

<div id="app">
<div class="page" id="homePage" style="display: block;">
<div class="home-container">
<h1>Chat</h1>
<div class="status" hidden></div>
<input class="input" type="text" id="nameInput" placeholder="Enter your name">
<button class="button" onclick="connect()">Join</button>
Expand Down
27 changes: 19 additions & 8 deletions web-client/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,33 @@ body {
.home-container {
display: flex;
flex-direction: column;
align-items: stretch; /* Changed from center to stretch to allow child elements to grow */
align-items: stretch;
justify-content: center;
background-color: var(--primary-color);
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 50px;
height: 30vh;
padding: 20px 50px 50px 50px;
width: 50vw;
max-height: 100px;
max-width: 300px;
}


.status {
margin-bottom: 12px;
color: var(--font-color);
text-align: center;
text-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
}

h1 {
text-align: center;
margin-bottom: 16px;
}

.button, .input {
flex-grow: 1; /* Allows the elements to grow and take up available space */
width: 100%; /* Makes sure the elements take the full width of the container */
margin: 4px 0; /* Adjusted margin to apply only to the top and bottom */
flex-grow: 1;
width: 100%;
margin: 4px 0;
}

.button {
Expand All @@ -46,7 +57,7 @@ body {
background-color: var(--accent-color);
color: white;
cursor: pointer;
max-height: 40px; /* Added max-height to prevent the button from growing too large */
max-height: 40px;
}

.button:hover {
Expand Down

0 comments on commit 6fe229e

Please sign in to comment.