Last active
July 1, 2019 17:20
-
-
Save johnbuck/f209eabeb36cb078f6af1b8177c31cb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import styled from 'styled-components'; | |
import PropTypes from 'prop-types'; | |
import { Link } from '../pages/routes'; | |
const ProfileImageElement = styled.div` | |
border-radius: 100%; | |
width: ${props => props.width || '75px'}; | |
height: ${props => props.width || '75px'}; | |
background-image: url(${props => props.src || '/static/userIcon.png'}); | |
background-size: cover; | |
background-color: #FFF; | |
`; | |
const ProfileImage = ({profileLink, src, ...other}) => { | |
const RenderedProfileImage = <ProfileImageElement src={src} />; | |
return profileLink ? ( | |
<Link href={profileLink}> | |
<a>{ProfileImageElement}</a> | |
</Link> | |
): | |
RenderedProfileImage; | |
}; | |
ProfileImage.propTypes = { | |
src: PropTypes.string, | |
profileLink: PropTypes.string, | |
width: PropTypes.string, | |
}; | |
export default ProfileImage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment