1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: handle overflowing avatars in the new project card (#7217)

This change prevents the project owner avatars in the new project card
footer from overflowing by making the number of avatars to show
configurable.

It defaults to 9, the old hard-coded number of avatars shown, but can
be configured.

The reason it overflows here is probably that the extra button in the
project card footer (the favorite) makes the footer smaller than what
we have for the group card footer.

Before: 

![image](https://github.com/Unleash/unleash/assets/17786332/972fe471-a78a-436a-a08d-18afefd2501e)

After:


![image](https://github.com/Unleash/unleash/assets/17786332/af569412-85e2-4b9b-97b8-12b91d372a70)
This commit is contained in:
Thomas Heartman 2024-05-30 12:01:17 +02:00 committed by GitHub
parent 07ef4a114f
commit abf4966a37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -47,11 +47,13 @@ interface IGroupCardAvatarsProps {
imageUrl?: string;
}[];
header?: ReactNode;
avatarLimit?: number;
}
export const GroupCardAvatars = ({
users = [],
header = null,
avatarLimit = 9,
}: IGroupCardAvatarsProps) => {
const shownUsers = useMemo(
() =>
@ -68,7 +70,7 @@ export const GroupCardAvatars = ({
}
return 0;
})
.slice(0, 9),
.slice(0, avatarLimit),
[users],
);
@ -109,7 +111,7 @@ export const GroupCardAvatars = ({
/>
))}
<ConditionallyRender
condition={users.length > 9}
condition={users.length > avatarLimit}
show={
<StyledAvatar>
+{users.length - shownUsers.length}

View File

@ -59,6 +59,7 @@ export const ProjectOwners: FC<IProjectOwnersProps> = ({ owners = [] }) => {
<GroupCardAvatars
header={owners.length === 1 ? 'Owner' : 'Owners'}
users={users}
avatarLimit={8}
/>
<ConditionallyRender
condition={owners.length === 1}