social-share-web
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Social Share

Social Share plugin is made from new UI perspective. Also for angular it takes care of SSR as it takes document as input. It can be used for all frameworks which uses typescript.

Features

  • Buffer
  • DSCVR
  • Email
  • Facebook
  • Hacker News
  • Line
  • LinkedIn
  • Open Chat
  • Pinterest
  • Pocket
  • Reddit
  • Telegram
  • Tumbler
  • Twitter
  • WhatsApp

Instalation

npm install social-share-web

Getting Started

Both show, hide and share methods are published. So that you can directly share with the help of specified attributes.

show(options)

Triggers the modal and needs to provide options for dynamic usage.

hide(document)

Clears the modal from the DOM

share(document, type, attributes)

Execute directly

Example

import { SocialMedia, SocialShare } from 'social-share-web';

private readonly shareObj = new SocialShare();

openShareModal() {
        this.shareObj.show({
            doc: document,
            title: "Social Modal",
            message: "Share this link via",
            socials: {
                [SocialMedia.Facebook]: {
                        type: 'feed'
                },
                [SocialMedia.LinkedIn]: {
                    url: window.location.href
                },
                [SocialMedia.Whatsapp]: {
                    url: window.location.href,
                    text: "Hi Sage Savas"
                },
                [SocialMedia.Pinterest]: {
                    url: window.location.href
                },
                [SocialMedia.Reddit]: {
                    url: window.location.href
                },
                [SocialMedia.Twitter]: {
                    url: window.location.href
                },
                [SocialMedia.Dscvr]: {
                    url: window.location.href
                },
                [SocialMedia.HackerNews]: {
                    url: window.location.href
                },
                [SocialMedia.OpenChat]: {
                    url: window.location.href
                },
                [SocialMedia.Telegram]: {
                    url: window.location.href
                },
                [SocialMedia.Email]: {
                    to: 'example@domain.com'
                },
                [SocialMedia.Pocket]: {
                    url: window.location.href
                },
                [SocialMedia.Buffer]: {
                    url: window.location.href,
                    text: 'Something'
                }
            },
            copy: {
                url: 'https://www.domain.com',
                text: 'Domain'
            }
        });
    }

directShare(doc: Document, type: SocialMedia, attributes: any) {
    this.shareObj.share(doc, type, attributes);
}

close() {
    this.shareObj.hide(doc: Document);
}

DOCUMENTs

Package Sidebar

Install

npm i social-share-web

Weekly Downloads

17

Version

0.0.1

License

MIT

Unpacked Size

52.3 kB

Total Files

44

Last publish

Collaborators

  • sanjib-kumar-mandal