Skip to content

Commit

Permalink
fix(MessageList): center date separator with grid layout and hidden t…
Browse files Browse the repository at this point in the history
…imestamp

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Jul 26, 2024
1 parent e08ca28 commit 878e2a0
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<span class="messages-group__date-text" role="heading" aria-level="3">
{{ dateSeparatorLabels[dateTimestamp] }}
</span>
<span class="messages-group__date-hidden">{{ getHiddenTime(dateTimestamp) }}</span>
</li>
<component :is="messagesGroupComponent(group)"
v-for="group in list"
Expand Down Expand Up @@ -1228,7 +1229,11 @@ export default {
onMessageHeightChanged({ heightDiff }) {
// scroll down by the height difference
this.$refs.scroller.scrollTop += heightDiff
}
},
getHiddenTime(timestamp) {
return moment(timestamp * 1000).format('LT')
},
},
}
</script>
Expand Down Expand Up @@ -1277,23 +1282,30 @@ export default {
&__date {
position: sticky;
top: 0;
display: flex;
justify-content: center;
display: grid;
grid-template-columns: minmax(0, $messages-text-max-width) 1fr;
z-index: 2;
margin-left: $message-avatar-column-width;
margin-bottom: 5px;
pointer-events: none;
}
&__date-text {
margin-right: calc(var(--default-clickable-area) * 2);
content: attr(data-date);
padding: 4px 12px;
left: 50%;
margin: 0 auto;
padding: var(--default-grid-baseline) calc(2 * var(--default-grid-baseline));
text-wrap: nowrap;
color: var(--color-text-maxcontrast);
background-color: var(--color-background-dark);
border-radius: var(--border-radius-pill);
}
&__date-hidden {
width: max-content;
pointer-events: none;
opacity: 0;
margin-right: $message-status-icon-width;
}
&:last-child {
margin-bottom: 16px;
}
Expand Down

0 comments on commit 878e2a0

Please sign in to comment.