Bunlong / next-share

Social media share buttons and share counts for your next React apps.
https://next-share.js.org
MIT License
246 stars 35 forks source link

[Feature Request] -- Copy link to clipboard support #58

Open bde-maze opened 2 years ago

bde-maze commented 2 years ago

Hello there!

Would be coherent to have an option for copy to clipboard. It could have two forms, one just a button with a confirmation (may be a tooltip) to indicate "link copied". The other form could be an input text with the link inside and that copy when clicked.

What do you think ?

SaadBazaz commented 2 years ago

I don't know if this comes within the scope of next-share, being an external-sharing library.

Currently I solve this by creating a wrapper over next-share, and adding a separate button.

      <section>
          <FacebookShareButton url={shareData.url} quote={shareData.title} hashtag={shareData.text}
          >
            <FacebookIcon size={32} round />
            <FacebookShareCount url={shareData.url} />
          </FacebookShareButton>

          <TwitterShareButton url={shareData.url} quote={shareData.title} hashtag={shareData.text}
          >
            <TwitterIcon size={32} round />
          </TwitterShareButton>

          <WhatsappShareButton url={shareData.url} quote={shareData.title} hashtag={shareData.text}
          >
            <WhatsappIcon size={32} round />
            </WhatsappShareButton>
        </div>

        <button className="btn btn-primary modal-footer-button"
          onClick={() => {
            navigator.clipboard.writeText(shareData.url);
            toast.info('Copied to clipboard!', {
              position: "bottom-left",
              autoClose: 5000,
              hideProgressBar: true,
              draggable: true,
              progress: undefined,
            });
          }}
        >Copy Link</button>
      </section>

Would be interesting to see what the authors say.

red1 commented 1 year ago

up please ?