1 | const React = require('react');
|
2 | const MD5 = require('spark-md5');
|
3 |
|
4 | const URL = 'https://www.gravatar.com/avatar';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | class 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 |
|
29 | export {Gravatar}; |
\ | No newline at end of file |