use a variable for the avatar size

This commit is contained in:
Jorik Schellekens 2020-09-23 15:47:49 +01:00
parent ee8c860507
commit 50f51d373f

View File

@ -24,6 +24,8 @@ import logo from '../imgs/chat-icon.svg';
import './Avatar.scss';
const AVATAR_SIZE = 60;
interface IProps {
className?: string;
avatarUrl: string;
@ -59,11 +61,18 @@ export const UserAvatar: React.FC<IPropsUserAvatar> = ({
userId,
}: IPropsUserAvatar) => {
const [hs] = useHSs({ identifier: userId });
return <Avatar
avatarUrl={getThumbnailURI(hs, 34, 34, user.avatar_url)}
return (
<Avatar
avatarUrl={getThumbnailURI(
hs,
AVATAR_SIZE,
AVATAR_SIZE,
user.avatar_url
)}
label={user.displayname ? user.displayname : userId}
/>;
}
/>
);
};
interface IPropsRoomAvatar {
room: Room;
@ -73,11 +82,18 @@ export const RoomAvatar: React.FC<IPropsRoomAvatar> = ({
room,
}: IPropsRoomAvatar) => {
const [hs] = useHSs({ identifier: room.room_id });
return <Avatar
avatarUrl={getThumbnailURI(hs, 34, 34, room.avatar_url)}
return (
<Avatar
avatarUrl={getThumbnailURI(
hs,
AVATAR_SIZE,
AVATAR_SIZE,
room.avatar_url
)}
label={room.name || room.room_id}
/>;
}
/>
);
};
interface IPropsGroupAvatar {
group: Group;
@ -89,10 +105,17 @@ export const GroupAvatar: React.FC<IPropsGroupAvatar> = ({
groupId,
}: IPropsGroupAvatar) => {
const [hs] = useHSs({ identifier: groupId });
return <Avatar
avatarUrl={getThumbnailURI(hs, 34, 34, group.avatar_url)}
return (
<Avatar
avatarUrl={getThumbnailURI(
hs,
AVATAR_SIZE,
AVATAR_SIZE,
group.avatar_url
)}
label={group.name}
/>;
}
/>
);
};
export default Avatar;