I'm trying to make a chat based on this link: https://socket.io/get-started/private-messaging-part-1/
and I'm hoping to style it such that when the message is from self, the message will have a grey background instead of white.
However right now, regardless of whether the message is from self or not, they are in the same class (message) and editing the color in this class will simply both background. Is there a way to add conditional styling?
Under template:
<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>
Under style:
.message {
list-style: none;
background-color: white;
border: solid;
border-color: gray;
border-width: 1px;
border-radius: 15px;
margin-bottom: 10px;
padding: 10px;
}
