mirror of https://gitlab.com/ecentrics/concordia
Ezerous
4 years ago
9 changed files with 142 additions and 120 deletions
@ -0,0 +1,52 @@ |
|||
import React, { useMemo } from 'react'; |
|||
import Avatar from 'react-avatar'; |
|||
import { Link } from 'react-router-dom'; |
|||
import PropTypes from 'prop-types'; |
|||
import { USER_PROFILE_PICTURE } from '../constants/orbit/UserDatabaseKeys'; |
|||
|
|||
const ProfileImage = (props) => { |
|||
const { |
|||
topicAuthorAddress, topicAuthor, topicAuthorMeta, avatarUrl, size, link, |
|||
} = props; |
|||
|
|||
const stopClickPropagation = (event) => { |
|||
event.stopPropagation(); |
|||
}; |
|||
|
|||
const authorAvatar = useMemo(() => { |
|||
let profileImageUrl = ''; |
|||
if (avatarUrl) profileImageUrl = avatarUrl; |
|||
else if (topicAuthorMeta && topicAuthorMeta[USER_PROFILE_PICTURE]) profileImageUrl = topicAuthorMeta[USER_PROFILE_PICTURE]; |
|||
|
|||
return ( |
|||
<Avatar |
|||
name={topicAuthor} |
|||
size={size} |
|||
round |
|||
src={profileImageUrl} |
|||
/> |
|||
); |
|||
}, [avatarUrl, size, topicAuthor, topicAuthorMeta]); |
|||
|
|||
return useMemo(() => { |
|||
if (link && topicAuthorAddress) { |
|||
return ( |
|||
<Link to={`/users/${topicAuthorAddress}`} onClick={stopClickPropagation}> |
|||
{authorAvatar} |
|||
</Link> |
|||
); |
|||
} |
|||
return authorAvatar; |
|||
}, [authorAvatar, link, topicAuthorAddress]); |
|||
}; |
|||
|
|||
ProfileImage.propTypes = { |
|||
topicAuthorAddress: PropTypes.string, |
|||
topicAuthor: PropTypes.string, |
|||
topicAuthorMeta: PropTypes.shape({ id: PropTypes.string, profile_picture: PropTypes.string }), |
|||
avatarUrl: PropTypes.string, |
|||
size: PropTypes.string, |
|||
link: PropTypes.bool, |
|||
}; |
|||
|
|||
export default ProfileImage; |
@ -1,7 +1,12 @@ |
|||
.general-tab-profile-picture { |
|||
border-radius: 50%; |
|||
width: 12rem !important; |
|||
height: 12rem !important; |
|||
margin: 2rem; |
|||
vertical-align: middle; |
|||
.profile-image{ |
|||
padding: 3rem !important; |
|||
} |
|||
|
|||
#edit-info-button { |
|||
margin: 1rem; |
|||
background-color: var(--secondary-color); |
|||
} |
|||
|
|||
#edit-info-button:hover { |
|||
background-color: var(--secondary-color-highlighted); |
|||
} |
|||
|
Loading…
Reference in new issue