I'm currently in the process of designing a web application for a chat platform. I have access to an API that provides a list of messages:
chatsite.com/api/thread/1/messages/
[
{
"id": 2,
"sender": {
"id": 2,
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="81f4f2e4f3f5f6ec1e6ece0e8edafe2eeec">[email protected]</a>"
},
"sent_datetime": "2017-09-06T17:31:30Z",
"body": "user two sending a message in new thread (pk1)"
},
{
"id": 1,
"sender": {
"id": 1,
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="433630263103242e222a2f6d202c2e">[email protected]</a>"
},
"sent_datetime": "2017-09-06T17:28:56Z",
"body": "New thread test body"
}
]
This is how the current HTML is structured:
<div id="Thread">
<div id="Header"></div>
<div id="MessageList">
<div class="message">
<p>{{message.body}}</p>
</div>
<div class="message">
<p>{{message.body}}</p>
</div>
<div class="message">
<p>{{message.body}}</p>
</div>
</div>
<div id="Footer"></div>
</div>
Below is the related CSS styling:
#Thread {
background-color: mediumseagreen;
display: flex;
flex-direction: column;
overflow-y: hidden;
height: 600px;
}
#Header {
height: 100px;
background-color: blueviolet;
}
#MessageList {
background-color: deepskyblue;
height: 100%;
display: flex;
flex-direction: column;
overflow-y: auto;
}
.message {
background-color: white;
padding: 8px;
border: 1px solid #f9f9f9;
font-size: 30px;
margin: 4px;
}
#Footer {
height: 100px;
background: red;
}
Currently, the messages are displayed from top to bottom with the latest message at the top. However, I would like to reverse this order and display the messages from bottom to top:
__________________
| |
| HEADER |
|________________|
| |
| Latest Message |
|________________|
| |
| 2nd Latest Message |
|________________|
| |
| |
| |
| |
|________________|
| |
| FOOTER |
|________________|
To achieve this layout change, I plan on utilizing Vue.js as my frontend framework.