Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
react-awesome-gravatar
Advanced tools
Readme
npm install react-awesome-gravatar --save
yarn add react-awesome-gravatar
import Gravatar from 'react-awesome-gravatar';
<Gravatar email={email}>
{ url => (<img src={url} />) }
</Gravatar>
// Should generate an <img /> tag with the correct gravatar profile url: https://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8
import { GravatarOptions } from 'react-awesome-gravatar';
const options: GravatarOptions = {
size: 50,
}; // check below for all available options
<Gravatar email="example@example.com" options={ options }>
{ url => (<img src={url} />) }
</Gravatar>
// Should generate an <img /> tag with the correct gravatar profile url: https://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?size=50
If you just need the URL to the profile image of gravatar, you can omit the use of the component and call the function that the component calls directly.
import { getGravatarUrl } from 'react-awesome-gravatar';
const profileUrl = getGravatarUrl('example@example.com');
// profileUrl has the profile url: https://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8
import { getGravatarUrl, GravatarOptions } from 'react-awesome-gravatar';
const options: GravatarOptions = {
size: 50,
}; // check below for all available options
const profileUrl = getGravatarUrl('example@example.com', options);
// profileUrl has the profile url: https://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?size=50
interface GravatarOptions {
size?: number;
default?: '404'|'mp'|'identicon'|'monsterid'|'wavatar'|'retro'|'robohash'|'blank';
defaultUrl?: string;
forcedefault?: 'y';
rating?: 'g'|'pg'|'r'|'x';
}
The options match 1:1 to the Gravatar API except for defaultUrl
which if present set the Gravatar default
to it.
const options: GravatarOptions = {
defaultUrl: 'http://example.com/image.png',
}
const profileUrl = getGravatarUrl('example@example.com', options);
// profileUrl has the profile url: https://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?default=http://example.com/image.png
Tests are configured with Jest, to run them use:
npm run test
FAQs
Just another react gravatar component
The npm package react-awesome-gravatar receives a total of 630 weekly downloads. As such, react-awesome-gravatar popularity was classified as not popular.
We found that react-awesome-gravatar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.