From 802fb3b19456c26464ec7f9a9715d1ea7826c7f0 Mon Sep 17 00:00:00 2001 From: chapoi <101828855+chapoi@users.noreply.github.com> Date: Mon, 26 Jun 2023 21:47:13 +0900 Subject: [PATCH] UX: chat message thread indicator improvements (#22224) - gridified the thread message indicator, alleviating some problems with positioning and overflow participant avatars will overlap/smush on smaller size and mobile - the excerpt went from 3 > 2 lines of wrapping on smaller size, still 1 line on large size - dropped the copy of "last reply" - fixed wrong line height - moved the "x replies" over to the right near the participants, as that makes more sense - using a bubble to indicate other participants, instead of copy This PR introduces the @container query, which is experimental. Nothing will break when it's being viewed in a not-supported browser, but it will be less elegant. --- .../chat-message-thread-indicator.hbs | 58 ++++-------- .../components/chat/thread/participants.hbs | 16 ++-- .../common/chat-message-thread-indicator.scss | 92 +++++++++---------- .../common/chat-thread-participants.scss | 47 +++++++++- .../chat-message-thread-indicator.scss | 68 ++++---------- .../mobile/chat-message-thread-indicator.scss | 39 +++----- 6 files changed, 142 insertions(+), 178 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-thread-indicator.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-message-thread-indicator.hbs index ed467c7dc9f..12f5cbbabbc 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-message-thread-indicator.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-thread-indicator.hbs @@ -8,50 +8,24 @@ role="button" title={{i18n "chat.threads.open"}} > - {{#unless this.chatStateManager.isDrawerActive}} -
- -
- {{/unless}} -
-
-
- {{#if (or this.site.mobileView this.chatStateManager.isDrawerActive)}} - - - - {{/if}} - - {{@message.thread.preview.lastReplyUser.username}} - -
- - {{format-date - @message.thread.preview.lastReplyCreatedAt - leaveAgo="true" - prefix=(i18n "chat.thread.last_reply") - }} - - | - - {{i18n "chat.thread.replies" count=@message.thread.preview.replyCount}} - -
-
- {{replace-emoji (html-safe @message.thread.preview.lastReplyExcerpt)}} -
+
+
-
- +
+ + {{@message.thread.preview.lastReplyUser.username}} + + + {{format-date @message.thread.preview.lastReplyCreatedAt leaveAgo="true"}} + +
+ +
+ {{replace-emoji (html-safe @message.thread.preview.lastReplyExcerpt)}}
\ No newline at end of file diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/thread/participants.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/thread/participants.hbs index cca09b3f96e..6670bfb536d 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat/thread/participants.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat/thread/participants.hbs @@ -1,4 +1,7 @@ {{#if (gt @thread.preview.participantUsers.length 1)}} +
+ {{i18n "chat.thread.replies" count=@thread.preview.replyCount}} +
{{#each @thread.preview.participantUsers as |user|}} @@ -8,14 +11,11 @@ @showPresence={{false}} /> {{/each}} + {{#if @thread.preview.otherParticipantCount}} +
+ +{{@thread.preview.otherParticipantCount}} +
+ {{/if}}
- {{#if @thread.preview.otherParticipantCount}} -
- {{i18n - "chat.thread.participants_other_count" - count=@thread.preview.otherParticipantCount - }} -
- {{/if}}
{{/if}} \ No newline at end of file diff --git a/plugins/chat/assets/stylesheets/common/chat-message-thread-indicator.scss b/plugins/chat/assets/stylesheets/common/chat-message-thread-indicator.scss index d700e9ff460..f7d724fc541 100644 --- a/plugins/chat/assets/stylesheets/common/chat-message-thread-indicator.scss +++ b/plugins/chat/assets/stylesheets/common/chat-message-thread-indicator.scss @@ -1,14 +1,16 @@ +.chat-message { + container-type: inline-size; +} + .chat-message-thread-indicator { - display: flex; - align-items: center; - gap: 1rem; cursor: pointer; grid-area: threadindicator; - max-width: 1000px; + box-sizing: border-box; + display: grid; + grid-template-columns: auto 1fr auto auto; background-color: var(--primary-very-low); margin: 4px 0 -2px calc(var(--message-left-width) - 0.25rem); - padding-block: 0.5rem; - padding-inline: 0.5rem; + padding: 0.5rem; border-radius: 8px; color: var(--primary); @@ -21,6 +23,12 @@ color: var(--primary); } + &:hover { + .chat-message-thread-indicator__replies-count { + text-decoration: underline; + } + } + .touch & { &.-active { box-shadow: var(--shadow-dropdown); @@ -33,70 +41,52 @@ } } - &__participants { - flex-shrink: 0; - align-self: flex-start; - } - &__last-reply-avatar { - align-self: flex-start; + grid-area: avatar; + margin-right: 0.5rem; + .chat-user-avatar { width: auto !important; } } - &__last-reply-metadata { - display: flex; - align-items: flex-end; - gap: 0.25rem; - color: var(--primary-medium); - - .separator { - font-size: var(--font-down-1); - } - } - - &__last-reply-container { - display: inline-flex; - align-items: flex-end; - font-size: var(--font-down-1); - min-width: 0; - - .relative-date { - @include ellipsis; - } - } - - &__last-reply-user { - font-weight: bold; - color: var(--secondary-low); - } - &__last-reply-username { + @include ellipsis; font-weight: bold; - color: var(--secondary-low); + color: var(--primary-very-high); + margin-right: 0.25rem; + } + + &__last-reply-info { + grid-area: info; + display: flex; + align-items: center; + gap: 0.25rem; + } + + &__last-reply-timestamp { + color: var(--primary-high); + font-size: var(--font-down-2); } &__last-reply-excerpt { @include ellipsis; - line-height: 1.8rem; + grid-area: excerpt; } - &__body { - overflow: hidden; - white-space: nowrap; - flex-shrink: 1; - } - - &:hover { - .chat-message-thread-indicator__replies-count { - text-decoration: underline; - } + .chat-thread-participants { + grid-area: participants; + flex-shrink: 0; + display: flex; + align-items: center; + justify-content: flex-end; + gap: 0.5rem; } &__replies-count { @include ellipsis; color: var(--tertiary); font-size: var(--font-down-1); + text-align: right; } } diff --git a/plugins/chat/assets/stylesheets/common/chat-thread-participants.scss b/plugins/chat/assets/stylesheets/common/chat-thread-participants.scss index 56a3127ccc2..de5031bed86 100644 --- a/plugins/chat/assets/stylesheets/common/chat-thread-participants.scss +++ b/plugins/chat/assets/stylesheets/common/chat-thread-participants.scss @@ -1,14 +1,31 @@ .chat-thread-participants { + margin-left: 0.5rem; &__other-count { + display: flex; + align-items: center; + justify-content: center; + width: 22px; + height: 22px; + border: 1px solid rgba(0, 0, 0, 0); + box-sizing: border-box; font-size: var(--font-down-2); - text-align: right; - color: var(--primary-medium); + color: var(--primary-very-low); + background: var(--secondary-high); + padding: 0.21em 0.42em; + border-radius: 1em; + text-align: center; + white-space: nowrap; } &__avatar-group { display: flex; + align-items: center; justify-content: flex-end; + .chat-user-avatar-container { + padding: 0; + } + .chat-user-avatar { width: auto !important; @@ -20,3 +37,29 @@ } } } + +@container (max-width: 400px) { + .chat-thread-participants { + &__avatar-group { + flex-direction: row-reverse; + justify-content: flex-start; + .chat-user-avatar { + &:not(:first-child) { + margin-right: -12px; + } + .avatar { + width: 22px; + height: 22px; + border: 1px solid var(--primary-very-low); + } + } + } + &__other-count { + width: 22px; + height: 22px; + margin-right: -12px; + z-index: 1; + border: 1px solid var(--primary-very-low); + } + } +} diff --git a/plugins/chat/assets/stylesheets/desktop/chat-message-thread-indicator.scss b/plugins/chat/assets/stylesheets/desktop/chat-message-thread-indicator.scss index 64f84c469d2..7f53cb2a0cb 100644 --- a/plugins/chat/assets/stylesheets/desktop/chat-message-thread-indicator.scss +++ b/plugins/chat/assets/stylesheets/desktop/chat-message-thread-indicator.scss @@ -1,59 +1,31 @@ .chat-message-thread-indicator { - max-width: 600px; + grid-template-areas: + "avatar info replies participants" + "avatar excerpt excerpt excerpt"; - .chat-drawer & { - align-items: stretch; - flex-wrap: wrap; - width: auto; - max-width: 100%; - min-width: auto; - gap: 0.25rem; + &__replies-count { + display: flex; + align-self: center; } +} - &__last-reply-avatar { - .chat-drawer & { - display: inline-block; +@container (max-width: 400px) { + .chat-message-thread-indicator { + grid-template-areas: + "avatar info info participants" + "excerpt excerpt excerpt replies"; + &__replies-count { + align-self: flex-start; + grid-area: replies; + justify-content: flex-end; } - } - - &__last-reply-user { - margin-right: 0.25rem; - - .chat-drawer & { - display: flex; - align-items: center; - gap: 0.5rem; - margin-right: auto; - } - } - - &__last-reply-metadata { - .chat-drawer & { - flex-wrap: wrap; - } - } - - &__last-reply-excerpt { - .chat-drawer & { + &__last-reply-excerpt { white-space: wrap; display: -webkit-box; - -webkit-line-clamp: 3; + -webkit-line-clamp: 2; -webkit-box-orient: vertical; - margin-left: calc(26px + 0.5rem); - } - } - - &__body { - .chat-drawer & { - flex-grow: 1; - } - } - &__participants { - margin-left: auto; - - .chat-drawer & { - align-self: flex-end; - flex-basis: 100%; + margin-top: 0.5rem; + margin-right: 0.25rem; } } } diff --git a/plugins/chat/assets/stylesheets/mobile/chat-message-thread-indicator.scss b/plugins/chat/assets/stylesheets/mobile/chat-message-thread-indicator.scss index e65ee62505d..ff8614ed93c 100644 --- a/plugins/chat/assets/stylesheets/mobile/chat-message-thread-indicator.scss +++ b/plugins/chat/assets/stylesheets/mobile/chat-message-thread-indicator.scss @@ -1,39 +1,24 @@ .chat-message-thread-indicator { - &__participants, - &__last-reply-avatar:not(.-mobile) { - display: none; - } + grid-template-areas: + "avatar info info participants" + "excerpt excerpt excerpt replies"; - &__last-reply-metadata { - display: flex; - align-items: center; - gap: 0.25rem; - margin-bottom: 0.25rem; - } - - &__last-reply-user { - display: flex; - align-items: center; - gap: 0.5rem; - margin-right: auto; - } - - &__last-reply-avatar { - align-self: center; + .chat-thread-participants { .avatar { - width: 18px; - height: 18px; + width: 22px; + height: 22px; } } - &__last-reply-username { - margin-right: auto; - } - &__last-reply-excerpt { white-space: wrap; display: -webkit-box; - -webkit-line-clamp: 3; + -webkit-line-clamp: 2; -webkit-box-orient: vertical; + margin-top: 0.5rem; + margin-right: 0.25rem; + } + &__replies-count { + grid-area: replies; } }