webapp/src/components/Inbox/GroupDialogAvatar.tsx

46 lines
1.0 KiB
TypeScript
Raw Normal View History

import type { ChatMember } from '~/graphql/schema/chat.gen'
import { clsx } from 'clsx'
2022-12-17 03:27:00 +00:00
import { For } from 'solid-js'
import DialogAvatar from './DialogAvatar'
2022-12-17 03:27:00 +00:00
import './DialogCard.module.scss'
2022-12-17 03:27:00 +00:00
import styles from './GroupDialogAvatar.module.scss'
type Props = {
users: ChatMember[]
}
const GroupDialogAvatar = (props: Props) => {
const slicedUsers = () => {
if (props.users.length > 3) {
return props.users.slice(0, 2)
}
return props.users.slice(0, 3)
}
return (
<div class={styles.GroupDialogAvatar}>
<For each={slicedUsers()}>
{(user) => (
<DialogAvatar
2023-02-17 09:21:02 +00:00
class={styles.grouped}
2022-12-17 03:27:00 +00:00
bordered={true}
size="small"
name={user.name}
2024-06-24 17:50:27 +00:00
url={user.pic || ''}
2022-12-17 03:27:00 +00:00
/>
)}
</For>
{props.users.length > 3 && (
<div class={clsx(styles.counter, { [styles.hundred]: props.users.length >= 100 })}>
{++props.users.length}
</div>
)}
</div>
)
}
export default GroupDialogAvatar