refactor: add color initials to avatar, improve usage of user avatar (#753)

This commit is contained in:
Meier Lukas
2024-07-08 00:00:54 +02:00
committed by GitHub
parent 408cdeb5c3
commit 3214d889fa
7 changed files with 25 additions and 33 deletions

View File

@@ -12,15 +12,10 @@ interface UserAvatarProps {
}
export const UserAvatar = ({ user, size }: UserAvatarProps) => {
const commonProps = {
size,
color: "primaryColor",
} satisfies Partial<AvatarProps>;
if (!user?.name) return <Avatar {...commonProps} />;
if (!user?.name) return <Avatar size={size} />;
if (user.image) {
return <Avatar {...commonProps} src={user.image} alt={user.name} />;
return <Avatar src={user.image} alt={user.name} size={size} />;
}
return <Avatar {...commonProps}>{user.name.substring(0, 2).toUpperCase()}</Avatar>;
return <Avatar name={user.name} color="initials" size={size}></Avatar>;
};