Skip to content

Commit

Permalink
add css for online user list
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Nov 16, 2023
1 parent 69fb996 commit 4b54cbd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
12 changes: 11 additions & 1 deletion springChatRoom/src/main/resources/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,14 @@ button.accent {
.chat-header h2 {
font-size: 1.1em;
}
}
}

/* online user */
.green-light {
display: inline-block;
width: 10px; /* Adjust the width as needed */
height: 10px; /* Adjust the height as needed */
background-color: green;
border-radius: 50%;
margin-right: 5px; /* Adjust the margin as needed */
}
24 changes: 23 additions & 1 deletion springChatRoom/src/main/resources/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,33 @@ function updateOnlineUsers(users) {
const userList = document.getElementById('userList');
userList.innerHTML = ''; // Clear the list first

// users.forEach(user => {
// const listItem = document.createElement('li');
// listItem.textContent = user;
// userList.appendChild(listItem);
// });

users.forEach(user => {
const listItem = document.createElement('li');
listItem.textContent = user;

// Create a span for the green light
const greenLight = document.createElement('span');
greenLight.classList.add('green-light'); // You may need to define a CSS class for styling

// Append the green light span to the list item
listItem.appendChild(greenLight);

// Create a span for the username
const usernameSpan = document.createElement('span');
usernameSpan.textContent = user;

// Append the username span to the list item
listItem.appendChild(usernameSpan);

// Append the list item to the user list
userList.appendChild(listItem);
});

}

// Call the fetchUserList function to initially populate the user list
Expand Down

0 comments on commit 4b54cbd

Please sign in to comment.