I'm currently working on developing a chat application using the guidelines outlined in this tutorial: https://socket.io/get-started/private-messaging-part-1/
One of my goals is to customize the appearance of the messages, so that when a message is sent by the user, it will have a grey background instead of the default white.
The challenge I am facing right now is that all messages are assigned the same CSS class (message), which makes it difficult to apply conditional styling. Is there a way to implement conditional styling based on the sender?
In the template section of the code:
<ul class="messages">
<li
v-for="(message, index) in user.messages"
:key="index"
class="message"
>
<div v-if="displaySender(message, index)" class="sender">
{{ message.fromSelf ? "(yourself)" : user.username }}
</div>
{{ message.content }}
</li>
</ul>
In the style section of the code:
.message {
list-style: none;
background-color: white;
border: solid;
border-color: gray;
border-width: 1px;
border-radius: 15px;
margin-bottom: 10px;
padding: 10px;
}