import * as React from "react"; import { EmailShareButton, FacebookShareButton, InstapaperShareButton, LineShareButton, LinkedinShareButton, LivejournalShareButton, MailruShareButton, OKShareButton, PinterestShareButton, PocketShareButton, RedditShareButton, TelegramShareButton, TumblrShareButton, TwitterShareButton, VKShareButton, ViberShareButton, WhatsappShareButton, WorkplaceShareButton, } from "react-share"; import { FacebookShareCount, OKShareCount, PinterestShareCount, RedditShareCount, TumblrShareCount, VKShareCount, } from "react-share"; import { ShareButtonProps, ShareButtonTypes } from "./types"; export const ShareButton: React.FC = ({ url, children, onClick, onComplete, shareButtonType, subject, content, hashtags, showShareCount, }) => { return (
{shareButtonType === ShareButtonTypes.EMAIL && ( {children(false)} )} {shareButtonType === ShareButtonTypes.FACEBOOK && ( {(shareCount) => showShareCount ? children(shareCount) : children(false) } )} {shareButtonType === ShareButtonTypes.INSTAPAPER && ( {children(false)} )} {shareButtonType === ShareButtonTypes.LINE && ( {children(false)} )} {shareButtonType === ShareButtonTypes.LINKEDIN && ( {children(false)} )} {shareButtonType === ShareButtonTypes.LIVEJOURNAL && ( {children(false)} )} {shareButtonType === ShareButtonTypes.MAILRU && ( {children(false)} )} {shareButtonType === ShareButtonTypes.OK && ( {(shareCount) => showShareCount ? children(shareCount) : children(false) } )} {shareButtonType === ShareButtonTypes.PINTEREST && ( {(shareCount) => showShareCount ? children(shareCount) : children(false) } )} {shareButtonType === ShareButtonTypes.POCKET && ( {children(false)} )} {shareButtonType === ShareButtonTypes.REDDIT && ( {(shareCount) => showShareCount ? children(shareCount) : children(false) } )} {shareButtonType === ShareButtonTypes.TELEGRAM && ( {children(false)} )} {shareButtonType === ShareButtonTypes.TUMBLR && ( {(shareCount) => showShareCount ? children(shareCount) : children(false) } )} {shareButtonType === ShareButtonTypes.TWITTER && ( {children(false)} )} {shareButtonType === ShareButtonTypes.VIBER && ( {children(false)} )} {shareButtonType === ShareButtonTypes.VK && ( {(shareCount) => showShareCount ? children(shareCount) : children(false) } )} {shareButtonType === ShareButtonTypes.WHATSAPP && ( {children(false)} )} {shareButtonType === ShareButtonTypes.WORKPLACE && ( {children(false)} )}
); }; ShareButton.defaultProps = { children: () =>
Share Now
, subject: "", content: "", url: "", showShareCount: false, type: ShareButtonTypes.FACEBOOK, }; export default ShareButton;