UNPKG

705 BJSXView Raw
1const React = require('react');
2const MD5 = require('spark-md5');
3
4const URL = 'https://www.gravatar.com/avatar';
5
6/**
7 * Gravatar
8 * @property {string} email the users email to use with gravatar
9 */
10class Gravatar extends React.Component {
11 static propTypes = {
12 email: React.PropTypes.string.isRequired,
13 style: React.PropTypes.string,
14 size: React.PropTypes.number
15 }
16
17 static defaultProps = {
18 style: 'retro',
19 size: 200
20 }
21
22 render() {
23 return <img
24 className={`gravatar ${this.props.className || ''}`}
25 src={`${URL}/${MD5.hash(this.props.email)}?d=${this.props.style}&s=${this.props.size}`}/>
26 }
27}
28
29export {Gravatar};
\No newline at end of file