Skip to content

Commit

Permalink
do not apply a bgcolor on an avatar that has an image (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
willydouhard authored Jan 10, 2024
1 parent 7fae300 commit 494b6ff
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions libs/react-components/src/elements/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ interface Props {
element?: IAvatarElement;
}

const AvatarElement = ({ element, author, bgColor }: Props) => (
<span className={`message-avatar`}>
<Avatar
sx={{
width: 26,
height: 26,
bgcolor: bgColor,
fontSize: '0.75rem',
mt: '-2px'
}}
src={element?.url}
>
{author[0]}
</Avatar>
</span>
);
const AvatarElement = ({ element, author, bgColor }: Props) => {
let avatar: JSX.Element;
const sx = {
width: 26,
height: 26,
fontSize: '0.75rem',
mt: '-2px',
bgcolor: element?.url ? 'transparent' : bgColor
};
if (element?.url) {
avatar = <Avatar sx={sx} src={element?.url} />;
} else {
avatar = <Avatar sx={sx}>{author[0]}</Avatar>;
}
return <span className={`message-avatar`}>{avatar}</span>;
};

export { AvatarElement };

0 comments on commit 494b6ff

Please sign in to comment.