Skip to content

Commit ad42fac

Browse files
committed
(fix) message avatar position
1 parent cb9b54a commit ad42fac

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed

src/lib/Message/Message.scss

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,25 @@
5959
line-height: 1.4;
6060
}
6161

62+
$avatar-size: 28px;
63+
6264
.vac-avatar {
63-
height: 28px;
64-
width: 28px;
65-
min-height: 28px;
66-
min-width: 28px;
65+
height: $avatar-size;
66+
width: $avatar-size;
67+
min-height: $avatar-size;
68+
min-width: $avatar-size;
6769
margin: 0 0 2px 0;
6870
align-self: flex-end;
6971
}
7072

73+
.vac-avatar-current-offset {
74+
margin-right: $avatar-size;
75+
}
76+
77+
.vac-avatar-offset {
78+
margin-left: $avatar-size;
79+
}
80+
7181
.vac-failure-container {
7282
position: relative;
7383
align-self: flex-end;
@@ -225,18 +235,28 @@
225235
max-width: 80%;
226236
}
227237

238+
$avatar-size-small: 25px;
239+
228240
.vac-avatar {
229-
height: 25px;
230-
width: 25px;
231-
min-height: 25px;
232-
min-width: 25px;
241+
height: $avatar-size-small;
242+
width: $avatar-size-small;
243+
min-height: $avatar-size-small;
244+
min-width: $avatar-size-small;
233245
margin: 0 6px 1px 0;
234246

235247
&.vac-avatar-current {
236248
margin: 0 0 1px 6px;
237249
}
238250
}
239251

252+
.vac-avatar-current-offset {
253+
margin-right: calc(#{$avatar-size-small} + 6px);
254+
}
255+
256+
.vac-avatar-offset {
257+
margin-left: calc(#{$avatar-size-small} + 6px);
258+
}
259+
240260
.vac-failure-container {
241261
margin-left: 2px;
242262

src/lib/Message/Message.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
class="vac-avatar"
3434
:style="{ 'background-image': `url('${message.avatar}')` }"
3535
/>
36+
<div
37+
v-if="hasSenderUserAvatar && !message.avatar"
38+
class="vac-avatar-offset"
39+
/>
3640
<div
3741
class="vac-message-container"
3842
:class="{
@@ -194,6 +198,10 @@
194198
class="vac-avatar vac-avatar-current"
195199
:style="{ 'background-image': `url('${message.avatar}')` }"
196200
/>
201+
<div
202+
v-if="hasCurrentUserAvatar && !message.avatar"
203+
class="vac-avatar-current-offset"
204+
/>
197205
</slot>
198206
</div>
199207
</div>
@@ -292,6 +300,16 @@ export default {
292300
!this.message.deleted &&
293301
(this.message.saved || this.message.distributed || this.message.seen)
294302
)
303+
},
304+
hasCurrentUserAvatar() {
305+
return this.messages.some(
306+
message => message.senderId === this.currentUserId && message.avatar
307+
)
308+
},
309+
hasSenderUserAvatar() {
310+
return this.messages.some(
311+
message => message.senderId !== this.currentUserId && message.avatar
312+
)
295313
}
296314
},
297315

0 commit comments

Comments
 (0)