mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
fix: cap number of collaborators displayed (#7879)
Caps the number of collaborators to display to a constant (currently set to 99). Above that, it'll always show "+99". However, we also add a tooltip that shows you a prettified version of the extra collaborators (using the `millify` package that we already use for metrics) Screenies: < 1000 collaborators: ![image](https://github.com/user-attachments/assets/b030e77e-e23d-4cac-a1d1-7841a4ba86e7) 1000 - 1M collaborators: ![image](https://github.com/user-attachments/assets/b72ca22e-513d-4d69-b78d-c675951c894a) 1M+ collaborators: ![image](https://github.com/user-attachments/assets/6341e87d-17da-4359-bce3-e31df637cd5c) Update, it now shows the total number of collaborators instead of the overflow: ![image](https://github.com/user-attachments/assets/67a459c5-91b8-475d-b0e3-c5c19aaf62d7)
This commit is contained in:
parent
f276728688
commit
dad30a08f0
@ -4,6 +4,7 @@ import type { IGroupUser } from 'interfaces/group';
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { UserAvatar } from 'component/common/UserAvatar/UserAvatar'; // usage
|
import { UserAvatar } from 'component/common/UserAvatar/UserAvatar'; // usage
|
||||||
import { objectId } from 'utils/objectId';
|
import { objectId } from 'utils/objectId';
|
||||||
|
import millify from 'millify';
|
||||||
|
|
||||||
const StyledAvatars = styled('div')(({ theme }) => ({
|
const StyledAvatars = styled('div')(({ theme }) => ({
|
||||||
display: 'inline-flex',
|
display: 'inline-flex',
|
||||||
@ -48,6 +49,8 @@ type AvatarGroupInnerProps = Omit<AvatarGroupProps, 'AvatarComponent'> & {
|
|||||||
AvatarComponent: typeof UserAvatar;
|
AvatarComponent: typeof UserAvatar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const MAX_OVERFLOW_DISPLAY_NUMBER = 99;
|
||||||
|
|
||||||
const AvatarGroupInner = ({
|
const AvatarGroupInner = ({
|
||||||
users = [],
|
users = [],
|
||||||
avatarLimit = 9,
|
avatarLimit = 9,
|
||||||
@ -73,16 +76,22 @@ const AvatarGroupInner = ({
|
|||||||
[users],
|
[users],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const overflow = users.length - avatarLimit;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledAvatars className={className}>
|
<StyledAvatars className={className}>
|
||||||
{shownUsers.map((user) => (
|
{shownUsers.map((user) => (
|
||||||
<AvatarComponent key={objectId(user)} user={user} />
|
<AvatarComponent key={objectId(user)} user={user} />
|
||||||
))}
|
))}
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={users.length > avatarLimit}
|
condition={overflow > 0}
|
||||||
show={
|
show={
|
||||||
<AvatarComponent>
|
<AvatarComponent
|
||||||
+{users.length - shownUsers.length}
|
user={{
|
||||||
|
username: `Total: ${millify(users.length)}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
+{Math.min(overflow, MAX_OVERFLOW_DISPLAY_NUMBER)}
|
||||||
</AvatarComponent>
|
</AvatarComponent>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user