Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/**
* WordPress dependencies
*/
import { ToolbarButton } from '@wordpress/components';
import { __, _n, sprintf } from '@wordpress/i18n';
import {
ToolbarButton,
__experimentalText as Text,
__experimentalHStack as HStack,
} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { useMemo } from '@wordpress/element';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

Expand Down Expand Up @@ -49,10 +53,16 @@ const CommentAvatarIndicator = ( { onClick, thread } ) => {
return null;
}

// Show up to 3 avatars, with overflow indicator.
// If there are more than 3 participants, show 2 avatars and a "+n" number.
const maxAvatars = 3;
const visibleParticipants = threadParticipants.slice( 0, maxAvatars );
const overflowCount = Math.max( 0, threadParticipants.length - maxAvatars );
const isOverflow = threadParticipants.length > maxAvatars;
const visibleParticipants = isOverflow
? threadParticipants.slice( 0, maxAvatars - 1 )
: threadParticipants;
const overflowCount = Math.max(
0,
threadParticipants.length - visibleParticipants.length
);
const threadHasMoreParticipants = threadParticipants.length > 100;

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

const overflowTitle =
threadHasMoreParticipants && overflowCount > 0
? __( '100+ participants' )
: sprintf(
// translators: %s: Number of participants.
_n(
'+%s more participant',
'+%s more participants',
overflowCount
),
overflowCount
);

return (
<CommentIconToolbarSlotFill.Fill>
<ToolbarButton
Expand All @@ -86,31 +83,24 @@ const CommentAvatarIndicator = ( { onClick, thread } ) => {
onClick={ onClick }
showTooltip
>
<div className="comment-avatar-stack">
{ visibleParticipants.map( ( participant, index ) => (
<HStack spacing="1">
{ visibleParticipants.map( ( participant ) => (
<img
key={ participant.id }
src={ participant.avatar }
alt={ participant.name }
className="comment-avatar"
style={ {
zIndex: maxAvatars - index,
borderColor: getAvatarBorderColor(
participant.id
),
} }
/>
) ) }
{ overflowCount > 0 && (
<div
className="comment-avatar-overflow"
style={ { zIndex: 0 } }
title={ overflowTitle }
>
{ overflowText }
</div>
<Text weight={ 500 }>{ overflowText }</Text>
) }
</div>
</HStack>
</ToolbarButton>
</CommentIconToolbarSlotFill.Fill>
);
Expand Down
52 changes: 6 additions & 46 deletions packages/editor/src/components/collab-sidebar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
border-width: var(--wp-admin-border-width-focus);
border-style: solid;
padding: var(--wp-admin-border-width-focus);
background: $white;
}

.editor-collab-sidebar-panel__comment-status {
Expand Down Expand Up @@ -154,57 +155,16 @@
bottom: $grid-unit-10;
}

// Comment avatar indicators.
.comment-avatar-indicator {
position: relative;
padding: 4px;
min-width: auto;
background: transparent;
border: none;
}

.comment-avatar-stack {
display: flex;
align-items: center;
position: relative;
height: $icon-size;
}

.comment-avatar {
width: $icon-size;
height: $icon-size;
border-radius: $radius-round;
border: 2px solid $white;
margin-left: -6px;
flex-shrink: 0;
margin-left: -12px;
border-width: var(--wp-admin-border-width-focus);
border-style: solid;
padding: var(--wp-admin-border-width-focus);
background: $white;

&:first-child {
margin-left: 0;
border-color: #de6e55;
}

&:nth-child(2) {
border-color: #599637;
}

&:nth-child(3) {
border-color: #3858e9;
}
}

.comment-avatar-overflow {
width: fit-content;
height: $icon-size;
border-radius: 4rem;
padding: 0 4px;
background: #757575;
color: $white;
border: 2px solid $white;
margin-left: -6px;
display: flex;
align-items: center;
justify-content: center;
font-size: 10px;
font-weight: 600;
flex-shrink: 0;
}
Loading