Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 14807de

Browse files
authored
Show displayname in non-narrow thread summeries (#8036)
* Show displayname in non-narrow thread summeries * Iterate PR * Iterate PR to use line-height based approach * Fix hover/focus chevron on thread summary relying on font character
1 parent c0fec42 commit 14807de

File tree

3 files changed

+64
-28
lines changed

3 files changed

+64
-28
lines changed

res/css/views/rooms/_EventTile.scss

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ $left-gutter: 64px;
723723

724724
.mx_ThreadInfo {
725725
min-width: 267px;
726-
max-width: min(calc(100% - 64px), 600px);
726+
max-width: min(calc(100% - $left-gutter - 64px), 600px); // leave space on both left & right gutters
727727
width: fit-content;
728728
height: 40px;
729729
position: relative;
@@ -740,41 +740,49 @@ $left-gutter: 64px;
740740
justify-content: flex-start;
741741
clear: both;
742742
overflow: hidden;
743+
border: 1px solid $system; // always render a border so the hover effect doesn't require a re-layout
743744

744-
&:hover {
745-
cursor: pointer;
746-
border: 1px solid $quinary-content;
747-
padding-top: 7px;
748-
padding-bottom: 7px;
749-
padding-left: 11px;
750-
padding-right: 15px;
751-
}
752-
753-
&::after {
754-
content: "";
745+
.mx_ThreadInfo_chevron {
755746
position: absolute;
756747
top: 0;
757748
right: 0;
758749
bottom: 0;
759750
width: 60px;
760-
padding: 0 10px;
761-
font-size: 15px;
762-
line-height: 39px;
763751
box-sizing: border-box;
764-
765-
text-align: right;
766-
font-weight: 600;
767-
768752
background: linear-gradient(270deg, $system 52.6%, transparent 100%);
769753

770754
opacity: 0;
771-
transform: translateX(20px);
755+
transform: translateX(60px);
772756
transition: all .1s ease-in-out;
757+
758+
&::before {
759+
content: '';
760+
position: absolute;
761+
top: 50%;
762+
right: 12px;
763+
transform: translateY(-50%);
764+
width: 12px;
765+
height: 12px;
766+
mask-image: url('$(res)/img/compound/chevron-right-12px.svg');
767+
mask-position: center;
768+
mask-size: contain;
769+
mask-repeat: no-repeat;
770+
background-color: $secondary-content;
771+
}
773772
}
774773

775-
&:hover::after {
776-
opacity: 1;
777-
transform: translateX(0);
774+
&:hover, &:focus {
775+
cursor: pointer;
776+
border-color: $quinary-content;
777+
778+
.mx_ThreadInfo_chevron {
779+
opacity: 1;
780+
transform: translateX(0);
781+
}
782+
}
783+
784+
&::before {
785+
align-self: center; // v-align the threads icon
778786
}
779787
}
780788

@@ -784,25 +792,34 @@ $left-gutter: 64px;
784792
width: initial;
785793
}
786794

795+
$threadInfoLineHeight: calc(2 * $font-12px);
796+
797+
.mx_ThreadInfo_sender {
798+
font-weight: $font-semi-bold;
799+
line-height: $threadInfoLineHeight;
800+
}
801+
787802
.mx_ThreadInfo_content {
788803
text-overflow: ellipsis;
789804
overflow: hidden;
790805
white-space: nowrap;
791-
padding-left: 8px;
806+
margin-left: 4px;
792807
font-size: $font-12px;
793-
line-height: calc(2 * $font-12px);
808+
line-height: $threadInfoLineHeight;
794809
color: $secondary-content;
795810
}
796811

797812
.mx_ThreadInfo_avatar {
798813
float: left;
814+
margin-right: 8px;
799815
}
800816

801817
.mx_ThreadInfo_threads-amount {
802-
font-weight: 600;
818+
font-weight: $font-semi-bold;
803819
position: relative;
804820
padding: 0 12px 0 8px;
805821
white-space: nowrap;
822+
line-height: $threadInfoLineHeight;
806823
}
807824

808825
.mx_EventTile[data-shape=ThreadsList] {
Lines changed: 10 additions & 0 deletions
Loading

src/components/views/rooms/ThreadSummary.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,18 @@ const ThreadSummary = ({ mxEvent, thread }: IProps) => {
6161
<span className="mx_ThreadInfo_threads-amount">
6262
{ countSection }
6363
</span>
64-
<ThreadMessagePreview thread={thread} />
64+
<ThreadMessagePreview thread={thread} showDisplayname={!roomContext.narrow} />
65+
<div className="mx_ThreadInfo_chevron" />
6566
</AccessibleButton>
6667
);
6768
};
6869

69-
export const ThreadMessagePreview = ({ thread }: Pick<IProps, "thread">) => {
70+
interface IPreviewProps {
71+
thread: Thread;
72+
showDisplayname?: boolean;
73+
}
74+
75+
export const ThreadMessagePreview = ({ thread, showDisplayname = false }: IPreviewProps) => {
7076
const cli = useContext(MatrixClientContext);
7177
const lastReply = useTypedEventEmitterState(thread, ThreadEvent.Update, () => thread.replyToEvent);
7278
const preview = useAsyncMemo(async () => {
@@ -85,6 +91,9 @@ export const ThreadMessagePreview = ({ thread }: Pick<IProps, "thread">) => {
8591
height={24}
8692
className="mx_ThreadInfo_avatar"
8793
/>
94+
{ showDisplayname && <div className="mx_ThreadInfo_sender">
95+
{ sender?.name ?? lastReply.getSender() }
96+
</div> }
8897
<div className="mx_ThreadInfo_content">
8998
<span className="mx_ThreadInfo_message-preview">
9099
{ preview }

0 commit comments

Comments
 (0)