mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 12:42:58 +08:00
Add react-share (#25446)
This commit is contained in:
205
types/react-share/index.d.ts
vendored
Normal file
205
types/react-share/index.d.ts
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
// Type definitions for react-share 2.1
|
||||
// Project: https://github.com/nygardk/react-share#readme
|
||||
// Definitions by: icopp <https://github.com/icopp>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
// =============================================================================
|
||||
// Share buttons
|
||||
// =============================================================================
|
||||
|
||||
export interface CommonShareButtonProps {
|
||||
/**
|
||||
* URL of the shared page
|
||||
*/
|
||||
url: string;
|
||||
/** Disables click action and adds `disabled` class */
|
||||
disabled?: boolean;
|
||||
/**
|
||||
* Style when button is disabled
|
||||
* @default { opacity: 0.6 }
|
||||
*/
|
||||
disabledStyle?: React.StyleHTMLAttributes<HTMLDivElement>;
|
||||
windowWidth?: number;
|
||||
windowHeight?: number;
|
||||
/**
|
||||
* Takes a function that returns a Promise to be fulfilled before calling
|
||||
* `onClick`. If you do not return promise, `onClick` is called immediately.
|
||||
*/
|
||||
beforeOnClick?: () => Promise<void>;
|
||||
/**
|
||||
* Takes a function to be called after closing share dialog.
|
||||
*/
|
||||
onShareWindowClose?: () => void;
|
||||
/**
|
||||
* An object to pass any additional properties, such as `aria-*` attributes.
|
||||
*/
|
||||
additionalProps?: React.HTMLAttributes<HTMLDivElement>;
|
||||
}
|
||||
|
||||
export const FacebookShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & {
|
||||
/** A quote to be shared along with the link. */
|
||||
quote?: string;
|
||||
/**
|
||||
* A hashtag specified by the developer to be added to the shared
|
||||
* content. People will still have the opportunity to remove this
|
||||
* hashtag in the dialog. The hashtag should include the hash symbol.
|
||||
*/
|
||||
hashtag?: string;
|
||||
}
|
||||
>;
|
||||
export const GooglePlusShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps
|
||||
>;
|
||||
export const LinkedinShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & {
|
||||
/** Title of the shared page */
|
||||
title?: string;
|
||||
/** Description of the shared page */
|
||||
description?: string;
|
||||
}
|
||||
>;
|
||||
export const TwitterShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & {
|
||||
/** Title of the shared page */
|
||||
title?: string;
|
||||
via?: string;
|
||||
hashtags?: string[];
|
||||
}
|
||||
>;
|
||||
export const TelegramShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & {
|
||||
/** Title of the shared page */
|
||||
title?: string;
|
||||
}
|
||||
>;
|
||||
export const WhatsappShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & {
|
||||
/** Title of the shared page */
|
||||
title?: string;
|
||||
/**
|
||||
* Separates title from the url
|
||||
* @default ' '
|
||||
*/
|
||||
separator?: string;
|
||||
}
|
||||
>;
|
||||
export const PinterestShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & {
|
||||
media: string;
|
||||
/** Description of the shared page */
|
||||
description?: string;
|
||||
}
|
||||
>;
|
||||
export const VKShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & {
|
||||
/** Title of the shared page */
|
||||
title?: string;
|
||||
/** Description of the shared page */
|
||||
description?: string;
|
||||
/** An absolute link to the image that will be shared */
|
||||
image?: string;
|
||||
}
|
||||
>;
|
||||
export const OKShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & {
|
||||
/** Title of the shared page */
|
||||
title?: string;
|
||||
/** Description of the shared page */
|
||||
description?: string;
|
||||
}
|
||||
>;
|
||||
export const RedditShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & {
|
||||
/** Title of the shared page */
|
||||
title?: string;
|
||||
}
|
||||
>;
|
||||
export const TumblrShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & {
|
||||
/** Title of the shared page */
|
||||
title?: string;
|
||||
tags?: string[];
|
||||
/** Description of the shared page */
|
||||
caption?: string;
|
||||
}
|
||||
>;
|
||||
export const LivejournalShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & { title?: string; description?: string }
|
||||
>;
|
||||
export const MalruShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & {
|
||||
/** Title of the shared page */
|
||||
title?: string;
|
||||
/** Description of the shared page */
|
||||
description?: string;
|
||||
/** An absolute link to the image that will be shared */
|
||||
image?: string;
|
||||
}
|
||||
>;
|
||||
export const EmailShareButton: React.StatelessComponent<
|
||||
CommonShareButtonProps & {
|
||||
/** Title of the shared page */
|
||||
subject?: string;
|
||||
/** Body of the email, defaults to shared url. */
|
||||
body?: string;
|
||||
}
|
||||
>;
|
||||
|
||||
// =============================================================================
|
||||
// Share counts
|
||||
// =============================================================================
|
||||
|
||||
export interface ShareCountComponentProps {
|
||||
/** The URL you are sharing */
|
||||
url: string;
|
||||
/** Classes to apply (if any) */
|
||||
className?: string;
|
||||
/** Supply a function as the child to render anything but the count */
|
||||
children?: (shareCount: number) => React.ReactNode;
|
||||
}
|
||||
|
||||
export const FacebookShareCount: React.StatelessComponent<ShareCountComponentProps>;
|
||||
export const GooglePlusShareCount: React.StatelessComponent<ShareCountComponentProps>;
|
||||
export const LinkedinShareCount: React.StatelessComponent<ShareCountComponentProps>;
|
||||
export const PinterestShareCount: React.StatelessComponent<ShareCountComponentProps>;
|
||||
export const VKShareCount: React.StatelessComponent<ShareCountComponentProps>;
|
||||
export const OKShareCount: React.StatelessComponent<ShareCountComponentProps>;
|
||||
export const RedditShareCount: React.StatelessComponent<ShareCountComponentProps>;
|
||||
export const TumblrShareCount: React.StatelessComponent<ShareCountComponentProps>;
|
||||
|
||||
// =============================================================================
|
||||
// Icons
|
||||
// =============================================================================
|
||||
|
||||
export interface IconComponentProps {
|
||||
/** Icon size in pixels */
|
||||
size?: number;
|
||||
/** Whether to show round or rect icons */
|
||||
round?: boolean;
|
||||
/** Customize background style, e.g. fill */
|
||||
iconBgStyle?: React.CSSProperties;
|
||||
/**
|
||||
* Customize logo's fill color
|
||||
* @default 'white'
|
||||
*/
|
||||
logoFillColor?: string;
|
||||
}
|
||||
|
||||
export const FacebookIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const TwitterIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const TelegramIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const WhatsappIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const GooglePlusIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const LinkedinIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const PinterestIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const VKIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const OKIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const RedditIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const TumblrIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const LivejournalIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const MailruIcon: React.StatelessComponent<IconComponentProps>;
|
||||
export const EmailIcon: React.StatelessComponent<IconComponentProps>;
|
||||
25
types/react-share/react-share-tests.ts
Normal file
25
types/react-share/react-share-tests.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
FacebookShareCount, // $ExpectType StatelessComponent<ShareCountComponentProps>
|
||||
GooglePlusShareCount, // $ExpectType StatelessComponent<ShareCountComponentProps>
|
||||
LinkedinShareCount, // $ExpectType StatelessComponent<ShareCountComponentProps>
|
||||
PinterestShareCount, // $ExpectType StatelessComponent<ShareCountComponentProps>
|
||||
VKShareCount, // $ExpectType StatelessComponent<ShareCountComponentProps>
|
||||
OKShareCount, // $ExpectType StatelessComponent<ShareCountComponentProps>
|
||||
RedditShareCount, // $ExpectType StatelessComponent<ShareCountComponentProps>
|
||||
TumblrShareCount, // $ExpectType StatelessComponent<ShareCountComponentProps>
|
||||
|
||||
FacebookIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
TwitterIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
TelegramIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
WhatsappIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
GooglePlusIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
LinkedinIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
PinterestIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
VKIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
OKIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
RedditIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
TumblrIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
LivejournalIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
MailruIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
EmailIcon, // $ExpectType StatelessComponent<IconComponentProps>
|
||||
} from 'react-share';
|
||||
23
types/react-share/tsconfig.json
Normal file
23
types/react-share/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-share-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/react-share/tslint.json
Normal file
1
types/react-share/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user