Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 22, 2016 15:06
Show Gist options
  • Save bnhansn/7a2041672625be5b21abd784d8fd9320 to your computer and use it in GitHub Desktop.
Save bnhansn/7a2041672625be5b21abd784d8fd9320 to your computer and use it in GitHub Desktop.
// @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