element-call/src/Facepile.jsx

34 lines
914 B
React
Raw Normal View History

2021-10-04 22:37:23 +00:00
import React from "react";
import styles from "./Facepile.module.css";
import ColorHash from "color-hash";
2021-11-10 23:44:08 +00:00
import classNames from "classnames";
2021-10-04 22:37:23 +00:00
const colorHash = new ColorHash({ lightness: 0.3 });
export function Facepile({ participants }) {
return (
<div
className={styles.facepile}
title={participants.map((member) => member.name).join(", ")}
>
2021-11-10 23:44:08 +00:00
{participants.slice(0, 3).map((member) => (
2021-10-04 22:37:23 +00:00
<div
2021-10-22 17:46:34 +00:00
key={member.userId}
2021-10-04 22:37:23 +00:00
className={styles.avatar}
style={{ backgroundColor: colorHash.hex(member.name) }}
>
<span>{member.name.slice(0, 1).toUpperCase()}</span>
</div>
))}
2021-11-10 23:44:08 +00:00
{participants.length > 3 && (
<div
key="additional"
className={classNames(styles.avatar, styles.additional)}
>
<span>{`+${participants.length - 3}`}</span>
</div>
)}
2021-10-04 22:37:23 +00:00
</div>
);
}