All Projects → greglobinski → react-custom-share

greglobinski / react-custom-share

Licence: MIT license
Social media share buttons for ReactJS. Use one of the built-in button themes or create a custom one from scratch.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to react-custom-share

aboutmeinfo-telegram-bot
ℹ️ About Me Info Bot: Share your social media and links on Telegram
Stars: ✭ 20 (-57.45%)
Mutual labels:  social, share, facebook, linkedin
CwsShareCount
PHP class to get social share count for Delicious, Facebook, Google+, Linkedin, Pinterest, Reddit, StumbleUpon and Twitter.
Stars: ✭ 13 (-72.34%)
Mutual labels:  share, facebook, linkedin, pinterest
sharon
A lightweight and modular social sharing library
Stars: ✭ 16 (-65.96%)
Mutual labels:  facebook, linkedin, pinterest
Social Login Helper Deprecated
A simple android library to easily implement social login into your android project
Stars: ✭ 81 (+72.34%)
Mutual labels:  social, facebook, linkedin
vue-socials
💬 Social media share buttons and counts for Vue.js
Stars: ✭ 32 (-31.91%)
Mutual labels:  social, share, linkedin
Keyring
Keyring is an authentication framework for WordPress. It comes with definitions for a variety of HTTP Basic, OAuth1 and OAuth2 web services. Use it as a common foundation for working with other web services from within WordPress code.
Stars: ✭ 52 (+10.64%)
Mutual labels:  facebook, linkedin, pinterest
Vuepress Plugin Social Share
📣 Social sharing plugin for VuePress
Stars: ✭ 27 (-42.55%)
Mutual labels:  social, share, facebook
Ultimate Metatags
A large snippet for your page's <head> that includes all the meta tags you'll need for OPTIMAL sharing and SEO. Extensive work has been put into ensuring you have the optimal images for the most important social media platforms.
Stars: ✭ 24 (-48.94%)
Mutual labels:  facebook, sharing, pinterest
Simplesharingbuttons
Share to Facebook, Twitter, Google+ and other social networks using simple HTML buttons.
Stars: ✭ 147 (+212.77%)
Mutual labels:  share, facebook, sharing
Angular Socialshare
Angular social share module, share urls and content on social networks such as facebook, google+, twitter, pinterest and more ... - http://720kb.github.io/angular-socialshare
Stars: ✭ 508 (+980.85%)
Mutual labels:  social, share, sharing
React Native Really Awesome Button
React Native button component. Awesome Button is a 3D at 60fps, progress enabled, social ready, extendable, production ready component that renders an awesome animated set of UI buttons. 📱
Stars: ✭ 988 (+2002.13%)
Mutual labels:  social, share
React Awesome Button
React button component. Awesome button is a 3D UI, progress, social and share enabled, animated at 60fps, light weight, performant, production ready react UI button component. 🖥️ 📱
Stars: ✭ 943 (+1906.38%)
Mutual labels:  social, share
Svelte Social Auth
Social Auth for Svelte v3
Stars: ✭ 86 (+82.98%)
Mutual labels:  social, facebook
Socialblocklists
Blocklists to block the communication to social networking sites and privacy harming services
Stars: ✭ 161 (+242.55%)
Mutual labels:  social, facebook
Vue Social Share
A Vue 2.x social share component
Stars: ✭ 136 (+189.36%)
Mutual labels:  social, share
Static Social Buttons
Static Social Buttons for Sharing and Tweeting
Stars: ✭ 18 (-61.7%)
Mutual labels:  social, share
shared-react-components-example
An example of a mono-repository of shared React components libraries!
Stars: ✭ 85 (+80.85%)
Mutual labels:  share, sharing
Skeleton
Skeleton is a Social Engineering tool attack switcher
Stars: ✭ 44 (-6.38%)
Mutual labels:  facebook, pinterest
dbt ad reporting
Fivetran's ad reporting dbt package. Combine your Facebook, Google, Pinterest, Linkedin, Twitter, Snapchat and Microsoft advertising spend using this package.
Stars: ✭ 68 (+44.68%)
Mutual labels:  linkedin, pinterest
LinkedIn Scraper
🙋 A Selenium based automated program that scrapes profiles data,stores in CSV,follows them and saves their profile in PDF.
Stars: ✭ 25 (-46.81%)
Mutual labels:  social, linkedin

react-custom-share

Social media share buttons for ReactJS. Use one of the built-in button themes or create a custom one from scratch.

npm packgage Codecov npm GitHub stars GitHub license contributors PRs Welcome Code of Conduct travis-badge Tweet


react-custom-share

Docs & Demos

Table of Content

Features

  • opens a share-window popup
  • built-in share scripts for:
    • Facebook
    • Twitter
    • Google+
    • Linkedin
    • Pinterest
    • email
  • flexibility to add share buttons for unsupported networks
  • built-in styled for buttons:
    • Rectangle
    • RoundSquare
    • Circle
    • IconOnly
    • Outline
  • build-in styled blocks:
    • Standard

Installation

Install npm package

yarn add react-custom-share

If you prefer you can equally use npm.

Install icons

yarn add react-icons

The examples use icons provided by the react-icons package, but you can use any icons. However, if you want to use built-in styled buttons you have to provide svg icons.

Install CSS-in-JS library

The styled buttons use the Emotion library to add CSS styles to the components.

yarn add emotion

Usage

// import emotion
import { css } from 'emotion';

// import icons
import FaTwitter from 'react-icons/lib/fa/twitter';
import FaFacebook from 'react-icons/lib/fa/facebook';
import FaGooglePlus from 'react-icons/lib/fa/google-plus';
import FaEnvelope from 'react-icons/lib/fa/envelope';
import FaPinterest from 'react-icons/lib/fa/pinterest';
import FaLinkedin from 'react-icons/lib/fa/linkedin';

// import react-custom-share components
import { ShareButtonRectangle, ShareBlockStandard } from 'react-custom-share';

const ShareComponent = props => {
  // create object with props for shareBlock
  const shareBlockProps = {
    url: 'https://mywebsite.com/page-to-share/',
    button: ShareButtonRectangle,
    buttons: [
      { network: 'Twitter', icon: FaTwitter },
      { network: 'Facebook', icon: FaFacebook },
      { network: 'GooglePlus', icon: FaGooglePlus },
      { network: 'Email', icon: FaEnvelope },
      { network: 'Pinterest', icon: FaPinterest, media: 'https://mywebsite.com/image-to-share.jpg' },
      { network: 'Linkedin', icon: FaLinkedin },
    ],
    text: `Give it a try - mywebsite.com `,
    longtext: `Take a look at this super website I have just found.`,
  };

  return <ShareBlockStandard {...shareBlockProps} />;
};

API

import {
  // base components (unstyled)
  ShareButton,
  ShareBlock,

  // styled button components
  ShareButtonRoundSquare,
  ShareButtonRectangle,
  ShareButtonCircle,
  ShareButtonIconOnly,
  ShareButtonOutline,

  // styled block components
  ShareBlockStandard,
} from 'react-custom-share';

ShareButton props

ShareButton.propTypes = {
  /* REQUIRED props */

  // network: social network name, one of the list: Twitter, Facebook, GooglePlus, Pinterest, Linkedin or Email
  network: PropTypes.string.isRequired,
  // url: the address of the page you want to share, 'https://mywebpage.com/'
  url: PropTypes.string.isRequired,
  // children: for the styled components it must be a svg icon, in other case it could be anything
  children: PropTypes.node.isRequired,

  /* SPECIAL props */

  // media: this is a special 'prop' it's required is network's value is 'Pinterest'
  media: function(props, propName, componentName) {
    const key = props['network'].toLowerCase();
    if (key === 'pinterest' && props[propName] === undefined) {
      return new Error(
        `The prop '${propName}' is marked as required in '${componentName}' for the 'Pinterest' network, but it's value is 'undefined'.`
      );
    }
  },

  /* OPTIONAL props */

  // text: short version of message you want to share with the url
  text: PropTypes.string,
  // longtext: additional text message, if it's possible and set it's concatenated to the `text` and serve as a comment with the shared url
  longtext: PropTypes.string,
  // className: CSS style class applied to the button
  className: PropTypes.string,
  // link: 'share link' for not built-in networks
  link: PropTypes.string,
};

ShareBlock props

ShareBlock.propTypes = {

  /* BUTTON's props */

  // props applied to each one of the buttons rendered by the block, explained already above
  url: PropTypes.string.isRequired,
  button: PropTypes.func.isRequired,
  buttons: PropTypes.array.isRequired,
  text: PropTypes.string,
  longtext: PropTypes.string,

  /* BLOCK's own props */

  // CSS style class applied to the block's outer div element
  className: PropTypes.string,
};

Built-in styled components

Styled components have the same api as its base versions. They work as wrappers for the base components and set the value of the className prop of the inner component they wrap.

Below is the simplified code of ShareButtonCircle, one of the built-in styled buttons.

import { css } from 'emotion';

const ShareButtonCircle = props => {
  return (
    <ShareButton
      className={css`
        border-radius: 50%;
        /* ... for the clarity most of the real CSS code was removed */
      `}
      {...props}
    />
  );
};

export default ShareButtonCircle;

Repository

To run DEMO on localhost

1. Clone react-custom-share repository.

git clone https://github.com/greglobinski/react-custom-share.git

2. Move into newly created folder and install dependencies.

cd react-custom-share
yarn install

3. After installation run the develop npm script.

yarn develop

4. Open the http://localhost:3001/ address in your browser.

Tutorials

License

The MIT License (MIT)

Copyright (c) 2018 greg lobinski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].