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
|
|
|
|
2022-07-14 10:28:46 +00:00
|
|
|
import { AvatarSSR } from "@components/ui/AvatarSSR";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
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 15:29:40 +00:00
|
|
|
<li key={idx} className="-mr-2 inline-block">
|
2022-07-14 10:28:46 +00:00
|
|
|
<AvatarSSR
|
2022-02-23 15:29:40 +00:00
|
|
|
className={props.border}
|
|
|
|
imageSrc={item.image}
|
|
|
|
title={item.title}
|
|
|
|
alt={item.alt || ""}
|
|
|
|
size={props.size}
|
|
|
|
/>
|
2021-12-08 11:40:48 +00:00
|
|
|
</li>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})}
|
2021-09-14 08:45:28 +00:00
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AvatarGroup;
|