element-call/src/Facepile.jsx

34 lines
904 B
React
Raw Normal View History

2021-10-04 22:37:23 +00:00
import React from "react";
import styles from "./Facepile.module.css";
2021-11-10 23:44:08 +00:00
import classNames from "classnames";
2021-12-08 01:59:55 +00:00
import { Avatar } from "./Avatar";
2021-10-04 22:37:23 +00:00
2021-12-08 01:59:55 +00:00
export function Facepile({ className, participants, ...rest }) {
2021-10-04 22:37:23 +00:00
return (
<div
2021-12-08 01:59:55 +00:00
className={classNames(styles.facepile, className)}
2021-10-04 22:37:23 +00:00
title={participants.map((member) => member.name).join(", ")}
2021-12-08 01:59:55 +00:00
{...rest}
2021-10-04 22:37:23 +00:00
>
2021-12-08 01:59:55 +00:00
{participants.slice(0, 3).map((member, i) => (
<Avatar
2021-10-22 17:46:34 +00:00
key={member.userId}
2021-12-08 01:59:55 +00:00
size="sm"
fallback={member.name.slice(0, 1).toUpperCase()}
2021-10-04 22:37:23 +00:00
className={styles.avatar}
2021-12-08 01:59:55 +00:00
style={{ left: i * 22 }}
/>
2021-10-04 22:37:23 +00:00
))}
2021-11-10 23:44:08 +00:00
{participants.length > 3 && (
2021-12-08 01:59:55 +00:00
<Avatar
2021-11-10 23:44:08 +00:00
key="additional"
2021-12-08 01:59:55 +00:00
size="sm"
fallback={`+${participants.length - 3}`}
className={styles.avatar}
style={{ left: 3 * 22 }}
/>
2021-11-10 23:44:08 +00:00
)}
2021-10-04 22:37:23 +00:00
</div>
);
}