import React, { ElementRef, forwardRef } from "react" import { classNames } from "../../utils" import { Avatar, AvatarImageProps } from "../Avatar" import { CenterAligned } from "../CenterAligned" import { Flex, FlexProps } from "../Flex" export type FacepileProps = FlexProps & { avatars: Pick[] size?: number /** * The margin between the avatars when they overlap. */ overlapMargin?: number /** * The maximum number of avatars to display. */ displayLimit?: number overrides?: { Avatar?: Partial } } export const Facepile = forwardRef, FacepileProps>( function Facepile( { avatars, className, size = 24, overlapMargin = 8, displayLimit = 3, overrides, ...rest }, ref, ) { const avatarClassName = overrides?.Avatar?.className return ( {avatars.slice(0, displayLimit).map((avatar, index) => ( 0 ? `-${overlapMargin}px` : undefined, }} {...overrides?.Avatar} className={avatarClassName} /> ))} {avatars.length > displayLimit && ( +{avatars.length - displayLimit} )} ) }, )