npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-quick-share

v1.0.3

Published

A lightweight and highly customizable React module for integrating social media sharing buttons. It supports a variety of platforms, including Facebook, WhatsApp, Twitter, LinkedIn, Pinterest, Telegram, and Email, with additional support for custom extens

Downloads

314

Readme

npm version example workflow GitHub Maintainability Coverage Status

React-Quick-Share

A simple but robust social media share module that facilitates sharing content on some of the world's most popular social networks.

Features

  • Ease of Use: Simple API for integrating social sharing buttons.
  • Customizable: Extensible styles and properties.
  • Support for Multiple Platforms: Includes support for multiple platforms.
  • Mobile Support: Detects mobile devices to optimize sharing links.

This module includes components for sharing via:

  • Facebook
  • WhatsApp
  • Twitter
  • LinkedIn
  • Pinterest
  • Telegram
  • Email
  • Print

The plan is to expand these components to accommodate other social media platforms. In the meantime, you can also extend the components yourself through a simple API.

Install

npm install react-quick-share

or if you prefer yarn,

yarn add  react-quick-share

Usage

Simply import the component you want and wrap your child node with it. This gives you the power to decide exactly how your share component should look. The child node could be a simple text - as in the examples used here, an icon component, or a custom component. You only need to pass in the url you want to share.

If you do not pass the url prop, the component will share the url of the page where you render it.

import { Facebook, Twitter, Whatsapp } from 'react-quick-share';

export const SocialMediaShare = () => {
    const url = 'www.the-url-you-want-to-share.com';

    return (
        <>
            <Facebook url={url}>
                <span className="up-to-you">Facebook</span>
            </Facebook>
            <Twitter url={url}>
                <span className="up-to-you">Twitter</span>
            </Twitter>
            <Whatsapp url={url}>
                <span className="up-to-you">Whatsapp</span>
            </Whatsapp>
        </>
    );
};

Extending Usage

If you need to share to a social media domain not already supported out-of-the-box, you will need the extendShare object and the createSocialShareButton function. The extendShare object accepts a key of the name of the new domain, and an object value that contains shareType set to link, and url set to the new domain's share endpoint.

The createSocialShareButton component takes the newDomain string as argument.

import { extendShare, createSocialShareButton } from 'react-quick-share';

extendShare.newDomain = {
    shareType: 'link',
    url: 'https://www.newDomain.com/sharing/?url=',
};

const MyCustomShareButton = createSocialShareButton('newDomain');

export const SocialMediaShare = () => {
    const url = 'www.the-url-you-want-to-share.com';

    return <MyCustomShareButton url={url}>Share on My Domain</MyCustomShareButton>;
};

Props

Each share button component accepts the following props along with regular ButtonHTMLAttributes:

| Prop | Type | Description | Default | | ---------- | -------- | -------------------------------------------- | ---------------------- | | url | string | The URL to be shared. | window.location.href | | domain | string | The social media platform. | None | | subject | string | Subject for the sharing link (email only). | "" | | style | object | Custom styles to apply to the button. | {} | | children | node | Custom label or element to render as button. | None |

Custom Styles

In some rare cases you may want to style these base components to achieve certain stylistic goals. In that case you will need to create and pass in your styles object as a style prop.

However, it is best to simply wrap the react-quick-share components with your own appropriately styled components. You can also pass your custom components as children to the react-quick-share components.

import { Facebook, Twitter } from 'react-quick-share';

const style = {
    borderRadius: '4px',
    boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
};

export const SocialMediaShare = () => {
    const url = 'www.the-url-you-want-to-share.com';

    return (
        <>
            <!-- wrap the share components with your own component -->
            <span className="up-to-you">
                <Twitter url={url} style={style}>
                Twitter
                </Twitter>
            </span>

            <!-- pass your own components as children -->
            <Facebook url={url} style={style}>
                <span className="up-to-you">Facebook</span>
            </Facebook>
        <>
    );
};

Contributing

You are welcome to contribute or suggest improvements via issues or pull requests.

License

MIT