import React from 'react'; import Avatar from '.'; import { Box, Flex } from '@chakra-ui/react'; /** * AvatarGroup * * @param avatars - avatars array * @param max - max avatars to show * @param [groupId] - group id to make the key unique * @returns */ function AvatarGroup({ avatars, max = 3, total }: { max?: number; avatars: string[]; total?: number; }) { const remain = total ?? avatars.length - max; return ( {avatars.slice(0, max).map((avatar, index) => ( 0 ? 'absolute' : 'relative'} left={index > 0 ? `${index * 15}px` : 0} zIndex={index > 0 ? index + 1 : 0} w={'24px'} borderRadius={'50%'} /> ))} {remain > 0 && ( +{String(remain)} )} ); } export default AvatarGroup;