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 = {
|
2022-02-23 13:55:59 +00:00
|
|
|
border?: string; // this needs to be the color of the parent container background, i.e.: border-white dark:border-gray-900
|
2021-09-14 08:45:28 +00:00
|
|
|
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 13:55:59 +00:00
|
|
|
<li key={idx} className={classNames("-mr-2 inline-block border-2", props.border)}>
|
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;
|