diff --git a/frontend/src/component/common/UserAvatar/UserAvatar.tsx b/frontend/src/component/common/UserAvatar/UserAvatar.tsx index be3a37c6d0..16969bb6bf 100644 --- a/frontend/src/component/common/UserAvatar/UserAvatar.tsx +++ b/frontend/src/component/common/UserAvatar/UserAvatar.tsx @@ -1,14 +1,15 @@ import { Avatar, type AvatarProps, + Box, styled, type SxProps, type Theme, } from '@mui/material'; import type { IUser } from 'interfaces/user'; import { forwardRef } from 'react'; -import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { HtmlTooltip } from '../HtmlTooltip/HtmlTooltip'; + const StyledAvatar = styled(Avatar)(({ theme }) => ({ width: theme.spacing(3.5), height: theme.spacing(3.5), @@ -19,6 +20,23 @@ const StyledAvatar = styled(Avatar)(({ theme }) => ({ fontWeight: theme.fontWeight.bold, })); +const StyledTooltip = styled(Box)(({ theme }) => ({ + display: 'flex', + gap: theme.spacing(2), +})); + +const StyledTooltipAvatar = styled(StyledAvatar)(({ theme }) => ({ + width: theme.spacing(5), + height: theme.spacing(5), + fontSize: theme.fontSizes.smallBody, +})); + +const StyledTooltipContent = styled(Box)({ + display: 'flex', + flexDirection: 'column', + justifyContent: 'center', +}); + export interface IUserAvatarProps extends AvatarProps { user?: Partial< Pick @@ -37,8 +55,8 @@ const tooltipContent = ( } const [mainIdentifier, secondaryInfo] = [ - user.email || user.username, user.name, + user.email || user.username, ]; if (mainIdentifier) { @@ -56,8 +74,10 @@ const TooltipSecondaryContent = styled('div')(({ theme }) => ({ color: theme.palette.text.secondary, fontSize: theme.typography.body2.fontSize, })); + const TooltipMainContent = styled('div')(({ theme }) => ({ fontSize: theme.typography.body1.fontSize, + overflowWrap: 'anywhere', })); export const UserAvatar = forwardRef( @@ -84,29 +104,45 @@ export const UserAvatar = forwardRef( alt={user?.name || user?.email || user?.username || 'Gravatar'} src={src || user?.imageUrl} > - + {fallback ? fallback : children} ); const tooltip = disableTooltip ? undefined : tooltipContent(user); if (tooltip) { + const { main, secondary } = tooltip; + return ( - - {tooltip.secondary} - - - {tooltip.main} - - + + + {fallback ? fallback : children} + + + {main && ( + + {main} + + )} + {secondary && ( + + {secondary} + + )} + + } > {Avatar}