I have created a messenger system with vue and a Laravel backend and I want to group the messages that are mine (Jim, the person I'm currently signed in as) on the right in blue and Debbie (The user I'm talking to) on the left in yellow using flexbox. Like Facebook or twitter:
Mock JSON Output
{
"0": {
"name": "Debbie",
"message": "Good, Thinks for asking."
},
"1": {
"name": "Jim",
"message": "I'm good, how are you?"
},
"2": {
"name": "Debbie",
"message": "How are you?"
},
"3": {
"name": "Jim",
"message": "Hi Debbie"
},
"4": {
"name": "Debbie",
"message": "Hi Jim"
}
}
What would I have to send through my JSON API to identify myself from any other user and thier messages? Or is there a way I could do that without having to do it without having to alter the JSON output?
How would I implement this into this messenger system that I've built using flexbox? The main component that I'm working with is the conversation-messages component:
Vue.component('conversation-messages',{
template: '#conversation-messages',
props: ['conversationId'],
data: function() {
return {
messages: [],
url: ''
}
},
mounted() {
console.log("message mounted")
this.getOldMessages(this.conversationId);
},
});
Here's a link to this question being answered only using css.
From the CSS link on how to create a chat bubble system like FB
HTML Structure Example From Link Using Floats Not Flexbox
<ul>
<li class="him">By Other User</li>
<li class="me">By this User, first message</li>
<li class="me">By this User, secondmessage</li>
<li class="me">By this User, third message</li>
<li class="me">By this User, fourth message</li>
</ul>
CSS Example From Answer In Link
ul{
list-style: none;
margin: 0;
padding: 0;
}
ul li{
display:inline-block;
clear: both;
padding: 20px;
border-radius: 30px;
margin-bottom: 2px;
font-family: Helvetica, Arial, sans-serif;
}
.him{
background: #eee;
float: left;
}
.me{
float: right;
background: #0084ff;
color: #fff;
}
.him + .me{
border-bottom-right-radius: 5px;
}
.me + .me{
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
.me:last-of-type {
border-bottom-right-radius: 30px;
}