Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/components/molecules/commentItem/commentItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const CommentItem = ({
<div className="flex-col w-full py-2 mx-auto bg-white sm:px-4 md:px-4 md:w-2/3">
<Card tag="div">
<div className="flex flex-row md-10">
<UserAvatar avatar={author.avatar_URL} size={12} />
<UserAvatar avatar={author.avatar_URL} size="12" />
<div className="flex-col mt-1">
<div className="flex items-center flex-1 px-4 font-bold leading-tight">
{author.name}
Expand Down
13 changes: 9 additions & 4 deletions apps/web/components/molecules/userAvatar/userAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ import clsx from 'clsx';

type CommentUserAvatarProps = {
avatar: string;
size?: number;
size?: '12' | '10' | '24';
};

export const UserAvatar = ({ avatar, size = 24 }: CommentUserAvatarProps) => {
const sizeClass = `w-${size} h-${size}`;
export const UserAvatar = ({ avatar, size = '24' }: CommentUserAvatarProps) => {
const sizes = {
24: 'w-24 h-24',
12: 'w-12 h-12',
10: 'w-10 h-10',
};
Comment on lines +10 to +14
Copy link

@goodideagiver goodideagiver Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be placed outside of the component (above component declaration) as a const

SIZES or AVATAR_SIZES


return (
<Image
alt=""
Expand All @@ -16,7 +21,7 @@ export const UserAvatar = ({ avatar, size = 24 }: CommentUserAvatarProps) => {
height={1000}
className={clsx(
'object-cover border-2 border-gray-300 rounded-full',
sizeClass,
sizes[size],
)}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export const HeaderUserLoggedInContent = ({
<div className="flex flex-col lg:flex-row items-center">
<div className="mr-2">
{user.avatarSrc ? (
<UserAvatar avatar={user.avatarSrc} size={10} />
<UserAvatar avatar={user.avatarSrc} size="10" />
) : (
<UserAvatar avatar={profileDefaultSvg} size={10} />
<UserAvatar avatar={profileDefaultSvg} size="10" />
)}
</div>
<p className="p-0 m-0">Witaj, {user.nickname}!</p>
Expand Down