2021-09-14 08:45:28 +00:00
|
|
|
import React from "react";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2021-09-14 08:45:28 +00:00
|
|
|
import classNames from "@lib/classNames";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
|
|
|
import Avatar from "@components/ui/Avatar";
|
|
|
|
|
2021-09-14 08:45:28 +00:00
|
|
|
export type AvatarGroupProps = {
|
|
|
|
size: number;
|
|
|
|
truncateAfter?: number;
|
|
|
|
items: {
|
|
|
|
image: string;
|
|
|
|
title?: string;
|
2021-11-18 01:03:19 +00:00
|
|
|
alt?: string;
|
2021-09-14 08:45:28 +00:00
|
|
|
}[];
|
|
|
|
className?: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const AvatarGroup = function AvatarGroup(props: AvatarGroupProps) {
|
|
|
|
return (
|
2022-02-23 11:09:22 +00:00
|
|
|
<ul className={classNames(props.className)}>
|
2021-12-08 11:40:48 +00:00
|
|
|
{props.items.slice(0, props.truncateAfter).map((item, idx) => {
|
|
|
|
if (item.image != null) {
|
|
|
|
return (
|
2022-02-23 11:09:22 +00:00
|
|
|
<li key={idx} className="-mr-3 inline-block">
|
2021-12-08 11:40:48 +00:00
|
|
|
<Avatar imageSrc={item.image} title={item.title} alt={item.alt || ""} size={props.size} />
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})}
|
2021-09-14 08:45:28 +00:00
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AvatarGroup;
|