From 196801759cb65724c327464839eb9c78fbb92a20 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Dec 2024 13:35:29 +0200 Subject: [PATCH] fixed sonar issues, made changes according to comments to PR --- .../components/user-avatar/UserAvatar.tsx | 90 +++++++++++-------- 1 file changed, 52 insertions(+), 38 deletions(-) diff --git a/src/design-system/components/user-avatar/UserAvatar.tsx b/src/design-system/components/user-avatar/UserAvatar.tsx index f8063dd20..db6c09c1c 100644 --- a/src/design-system/components/user-avatar/UserAvatar.tsx +++ b/src/design-system/components/user-avatar/UserAvatar.tsx @@ -23,7 +23,6 @@ export type UserAvatarProps = BaseUserAvatarProps & Omit type Ref = MuiAvatarProps['ref'] - const UserAvatar = forwardRef( ( { @@ -40,46 +39,62 @@ const UserAvatar = forwardRef( ) => { const monogram = firstName.charAt(0) + lastName.charAt(0) + const avatarClass = cn('s2s-avatar', `s2s-avatar-${size}`) + + let avatarContent + if (variant === 'photo' && src) { + avatarContent = ( + + ) + } else if (variant === 'monogram') { + avatarContent = ( + + {monogram} + + ) + } else if (variant === 'check') { + avatarContent = ( + + + + ) + } else { + avatarContent = ( + + ) + } + return (
- {variant === 'photo' && src ? ( - - ) : variant === 'monogram' ? ( - - {monogram} - - ) : variant === 'check' ? ( - - - - ) : ( - - )} + {avatarContent} {isOnline && ( )}
@@ -88,5 +103,4 @@ const UserAvatar = forwardRef( ) UserAvatar.displayName = 'UserAvatar' - export default UserAvatar