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