import { accentForIndex, initials } from '../lib/avatar'
import './UserAvatar.css'
interface UserAvatarProps {
username: string
colorIndex: number
size?: number
avatarUrl?: string | null
// undefined -- no presence data for this context (e.g. a bot), don't
// render a dot at all, rather than guessing.
status?: 'online' | 'offline'
}
export function UserAvatar({ username, colorIndex, size = 28, avatarUrl, status }: UserAvatarProps) {
const dotSize = Math.max(8, Math.round(size * 0.32))
const dot = status && (
)
if (avatarUrl) {
return (
{dot}
)
}
return (
{initials(username)}
{dot}
)
}