Created
October 22, 2016 15:06
-
-
Save bnhansn/7a2041672625be5b21abd784d8fd9320 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// @flow | |
import React from 'react'; | |
import md5 from 'md5'; | |
type Props = { | |
email: string, | |
size?: number, | |
style?: Object, | |
} | |
const Avatar = ({ email, size = 40, style }: Props) => { | |
const hash = md5(email); | |
const uri = `https://secure.gravatar.com/avatar/${hash}`; | |
return ( | |
<img | |
src={uri} | |
alt={email} | |
style={{ width: `${size}px`, height: `${size}px`, borderRadius: '4px', ...style }} | |
/> | |
); | |
}; | |
export default Avatar; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment