forked from mdl29/scratchy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessageList.vue
87 lines (77 loc) · 1.94 KB
/
MessageList.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<template>
<ul class="messages_list_wrapper">
<li v-for="msg in messages" class="messages_item" :key="msg.id">
<div class="messages_title">
<span class="messages_author"> {{msg.author.pseudo}} </span>
<span class="messages_timestamp"> {{ humanDate(msg.timestamp) }} </span>
</div>
<div class="messages_content">
{{msg.content}}
</div>
</li>
</ul>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import moment from 'moment';
// NOTE(vndx): I might have broken whatever (already somewhat broken) timestamp timezone code
// is going on there, but it needs a refractor anyways since it didn't even work.
export default defineComponent({
name: 'message-list',
props: ['messages'],
methods: {
humanDate(ts: string){
return moment(ts).fromNow();
},
},
data: function(){
return {
now: new Date()
};
},
created() {
moment.relativeTimeThreshold('s', 60);
moment.relativeTimeThreshold('m', 60);
moment.relativeTimeThreshold('h', 24);
moment.relativeTimeThreshold('d', 31);
moment.relativeTimeThreshold('M', 12);
moment.relativeTimeThreshold('y', 365);
setInterval(() => {
this.now = new Date();
}, 2000)
},
});
</script>
<style scoped>
.messages_list_wrapper {
list-style-type: none;
display: flex;
flex-direction: column;
background-color: var(--bg4);
margin: 0;
padding-bottom: 50px;
flex-grow: 2;
overflow-y: auto;
}
.messages_item {
margin-top: 20px;
}
.messages_title {
display: flex;
align-items: center;
}
.messages_author {
color: var(--accent);
margin-right: 20px;
}
.messages_timestamp {
color: var(--bg2);
filter: brightness(1.5);
font-size: 0.6em;
}
.messages_content {
margin-top: 5px;
color: #ddd;
font-size: smaller;
}
</style>