mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add declarations for react-gravatar. (#13147)
This commit is contained in:
parent
227b936636
commit
7898c0be89
80
react-gravatar/index.d.ts
vendored
Normal file
80
react-gravatar/index.d.ts
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
// Type definitions for react-gravatar 2.6
|
||||
// Project: http://kyleamathews.github.io/react-gravatar/
|
||||
// Definitions by: invliD <https://github.com/invliD>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
export as namespace Gravatar;
|
||||
|
||||
export = Gravatar;
|
||||
|
||||
/**
|
||||
* React component for rendering a gravatar profile image. Adjusts automatically to HiDPI displays.
|
||||
*/
|
||||
declare class Gravatar extends React.Component<Gravatar.Props, void> {
|
||||
static readonly displayName: string;
|
||||
|
||||
static readonly defaultProps: Gravatar.Props;
|
||||
|
||||
render(): JSX.Element | null;
|
||||
}
|
||||
|
||||
declare namespace Gravatar {
|
||||
export type DefaultImage = "404" | "mm" | "identicon" | "monsterid" | "wavatar" | "retro" | "blank";
|
||||
export type Rating = "g" | "pg" | "r" | "x";
|
||||
|
||||
export interface Props {
|
||||
/**
|
||||
* The email address used to look up the Gravatar image.
|
||||
* If you wish to avoid sending an email address to the client, you can compute the md5 hash on the server and
|
||||
* pass the hash to the component using the `md5` prop instead of the `email` prop.
|
||||
*/
|
||||
email?: string;
|
||||
|
||||
/**
|
||||
* The md5 hash of the email address used to look up the Gravatar image.
|
||||
* If you wish to avoid sending an email address to the client, you can compute the md5 hash on the server and
|
||||
* pass the hash to the component using the `md5` prop instead of the `email` prop.
|
||||
*/
|
||||
md5?: string;
|
||||
|
||||
/**
|
||||
* By default, images are presented at 50px by 50px if no size prop is supplied.
|
||||
*
|
||||
* @default 50
|
||||
* @see https://gravatar.com/site/implement/images/#size
|
||||
*/
|
||||
size?: number;
|
||||
|
||||
/**
|
||||
* Gravatar allows users to self-rate their images so that they can indicate if an image is appropriate for a
|
||||
* certain audience. By default, only `g` rated images are displayed unless you indicate that you would like
|
||||
* to see higher ratings.
|
||||
*
|
||||
* @default "g"
|
||||
* @see https://gravatar.com/site/implement/images/#rating
|
||||
*/
|
||||
rating?: Rating;
|
||||
|
||||
/**
|
||||
* Gravatar has a number of built in options which you can use as defaults when an email address has no
|
||||
* matching Gravatar image.
|
||||
*
|
||||
* @default "retro"
|
||||
* @see https://gravatar.com/site/implement/images/#default-image
|
||||
*/
|
||||
default?: DefaultImage;
|
||||
|
||||
/**
|
||||
* The protocol used to fetch the Gravatar image. Should be one of `http://`, `https://` or `//` (default).
|
||||
*
|
||||
* @default "//"
|
||||
* @see https://gravatar.com/site/implement/images/#secure-images
|
||||
*/
|
||||
protocol?: string;
|
||||
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
}
|
||||
40
react-gravatar/react-gravatar-tests.tsx
Normal file
40
react-gravatar/react-gravatar-tests.tsx
Normal file
@ -0,0 +1,40 @@
|
||||
import * as React from "react";
|
||||
import * as Gravatar from "react-gravatar";
|
||||
|
||||
class GravatarEmailTest extends React.Component<void, void> {
|
||||
public render() {
|
||||
return (
|
||||
<Gravatar
|
||||
email="test@example.com"
|
||||
size={100}
|
||||
rating="x"
|
||||
default="retro"
|
||||
protocol="https://"
|
||||
className="image"
|
||||
style={{borderWidth: "1px"}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class GravatarHashTest extends React.Component<void, void> {
|
||||
public render() {
|
||||
return (
|
||||
<Gravatar
|
||||
md5="55502f40dc8b7c769880b10874abc9d0"
|
||||
size={100}
|
||||
rating="x"
|
||||
default="retro"
|
||||
protocol="https://"
|
||||
className="image"
|
||||
style={{borderWidth: "1px"}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class GravatarMinimalTest extends React.Component<void, void> {
|
||||
public render() {
|
||||
return <Gravatar email="test@example.com" />;
|
||||
}
|
||||
}
|
||||
20
react-gravatar/tsconfig.json
Normal file
20
react-gravatar/tsconfig.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"jsx": "react",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-gravatar-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
react-gravatar/tslint.json
Normal file
1
react-gravatar/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Loading…
Reference in New Issue
Block a user