-
Notifications
You must be signed in to change notification settings - Fork 0
/
MessageItem.vue
95 lines (86 loc) 路 1.68 KB
/
MessageItem.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
88
89
90
91
92
93
94
95
<script setup>
defineProps({
self: {
type: Boolean,
default: false
},
author: {
type: String,
required: true
},
message: {
type: String,
required: true
},
time: {
type: String,
required: true
}
})
</script>
<template>
<div :class="{ message: true, 'message-left': !self, 'message-right': self }">
<p v-if="!self" class="author">{{ author }}</p>
<div class="content-wrapper">
<p class="content">{{ message }}</p>
<p class="time">{{ time }}</p>
</div>
</div>
</template>
<style scoped>
.message {
display: flex;
position: relative;
max-width: 26rem;
width: fit-content;
margin-top: 1.2rem;
padding: 0.4rem 0.6rem 0.5rem 0.8rem;
font-size: 1.4rem;
border-radius: 0 0.6rem 0.6rem 0.6rem;
/* @todo #45:15m Replace background-color value with the constant */
background-color: #f2f2f7;
overflow-wrap: anywhere;
}
.content {
padding-bottom: 2rem;
}
.time {
min-width: fit-content;
margin-top: auto;
padding-left: 0.8rem;
text-align: right;
}
.content-wrapper {
display: flex;
margin-top: 0.4rem;
}
.message-right {
background-color: var(--color-primary);
color: var(--color-on-primary);
margin-left: auto;
border-radius: 0.6rem 0 0.6rem 0.6rem;
}
.message-left {
flex-direction: column;
}
.message-left::before {
content: '';
position: absolute;
right: 100%;
top: 0;
width: 0;
height: 0;
border-right: 1.5rem solid #f2f2f7;
border-bottom: 1.5rem solid transparent;
}
.message-right::after {
content: '';
position: absolute;
left: 100%;
top: 0;
width: 0;
height: 0;
border-right: 1.5rem solid transparent;
border-top: 1.5rem solid var(--color-primary);
}
</style>