Skip to content

Commit 1346ddb

Browse files
t-hamanoMamadukajasmussenadamsilverstein
authored andcommitted
Notes: Refine avatar (#72773)
* Notes: Refine avatar * Implement design as much as possible Co-authored-by: t-hamano <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: jasmussen <[email protected]> Co-authored-by: adamsilverstein <[email protected]>
1 parent 0a15abe commit 1346ddb

File tree

2 files changed

+25
-75
lines changed

2 files changed

+25
-75
lines changed

packages/editor/src/components/collab-sidebar/comment-indicator-toolbar.js

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
/**
22
* WordPress dependencies
33
*/
4-
import { ToolbarButton } from '@wordpress/components';
5-
import { __, _n, sprintf } from '@wordpress/i18n';
4+
import {
5+
ToolbarButton,
6+
__experimentalText as Text,
7+
__experimentalHStack as HStack,
8+
} from '@wordpress/components';
9+
import { __, sprintf } from '@wordpress/i18n';
610
import { useMemo } from '@wordpress/element';
711
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
812

@@ -49,10 +53,16 @@ const CommentAvatarIndicator = ( { onClick, thread } ) => {
4953
return null;
5054
}
5155

52-
// Show up to 3 avatars, with overflow indicator.
56+
// If there are more than 3 participants, show 2 avatars and a "+n" number.
5357
const maxAvatars = 3;
54-
const visibleParticipants = threadParticipants.slice( 0, maxAvatars );
55-
const overflowCount = Math.max( 0, threadParticipants.length - maxAvatars );
58+
const isOverflow = threadParticipants.length > maxAvatars;
59+
const visibleParticipants = isOverflow
60+
? threadParticipants.slice( 0, maxAvatars - 1 )
61+
: threadParticipants;
62+
const overflowCount = Math.max(
63+
0,
64+
threadParticipants.length - visibleParticipants.length
65+
);
5666
const threadHasMoreParticipants = threadParticipants.length > 100;
5767

5868
// If we hit the comment limit, show "100+" instead of exact overflow count.
@@ -65,19 +75,6 @@ const CommentAvatarIndicator = ( { onClick, thread } ) => {
6575
overflowCount
6676
);
6777

68-
const overflowTitle =
69-
threadHasMoreParticipants && overflowCount > 0
70-
? __( '100+ participants' )
71-
: sprintf(
72-
// translators: %s: Number of participants.
73-
_n(
74-
'+%s more participant',
75-
'+%s more participants',
76-
overflowCount
77-
),
78-
overflowCount
79-
);
80-
8178
return (
8279
<CommentIconToolbarSlotFill.Fill>
8380
<ToolbarButton
@@ -86,31 +83,24 @@ const CommentAvatarIndicator = ( { onClick, thread } ) => {
8683
onClick={ onClick }
8784
showTooltip
8885
>
89-
<div className="comment-avatar-stack">
90-
{ visibleParticipants.map( ( participant, index ) => (
86+
<HStack spacing="1">
87+
{ visibleParticipants.map( ( participant ) => (
9188
<img
9289
key={ participant.id }
9390
src={ participant.avatar }
9491
alt={ participant.name }
9592
className="comment-avatar"
9693
style={ {
97-
zIndex: maxAvatars - index,
9894
borderColor: getAvatarBorderColor(
9995
participant.id
10096
),
10197
} }
10298
/>
10399
) ) }
104100
{ overflowCount > 0 && (
105-
<div
106-
className="comment-avatar-overflow"
107-
style={ { zIndex: 0 } }
108-
title={ overflowTitle }
109-
>
110-
{ overflowText }
111-
</div>
101+
<Text weight={ 500 }>{ overflowText }</Text>
112102
) }
113-
</div>
103+
</HStack>
114104
</ToolbarButton>
115105
</CommentIconToolbarSlotFill.Fill>
116106
);

packages/editor/src/components/collab-sidebar/style.scss

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
border-width: var(--wp-admin-border-width-focus);
7979
border-style: solid;
8080
padding: var(--wp-admin-border-width-focus);
81+
background: $white;
8182
}
8283

8384
.editor-collab-sidebar-panel__comment-status {
@@ -154,57 +155,16 @@
154155
bottom: $grid-unit-10;
155156
}
156157

157-
// Comment avatar indicators.
158-
.comment-avatar-indicator {
159-
position: relative;
160-
padding: 4px;
161-
min-width: auto;
162-
background: transparent;
163-
border: none;
164-
}
165-
166-
.comment-avatar-stack {
167-
display: flex;
168-
align-items: center;
169-
position: relative;
170-
height: $icon-size;
171-
}
172-
173158
.comment-avatar {
174159
width: $icon-size;
175-
height: $icon-size;
176160
border-radius: $radius-round;
177-
border: 2px solid $white;
178-
margin-left: -6px;
179-
flex-shrink: 0;
161+
margin-left: -12px;
162+
border-width: var(--wp-admin-border-width-focus);
163+
border-style: solid;
164+
padding: var(--wp-admin-border-width-focus);
165+
background: $white;
180166

181167
&:first-child {
182168
margin-left: 0;
183-
border-color: #de6e55;
184-
}
185-
186-
&:nth-child(2) {
187-
border-color: #599637;
188-
}
189-
190-
&:nth-child(3) {
191-
border-color: #3858e9;
192169
}
193170
}
194-
195-
.comment-avatar-overflow {
196-
width: fit-content;
197-
height: $icon-size;
198-
border-radius: 4rem;
199-
padding: 0 4px;
200-
background: #757575;
201-
color: $white;
202-
border: 2px solid $white;
203-
margin-left: -6px;
204-
display: flex;
205-
align-items: center;
206-
justify-content: center;
207-
font-size: 10px;
208-
font-weight: 600;
209-
flex-shrink: 0;
210-
}

0 commit comments

Comments
 (0)