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

ngx-social-button

v1.0.4

Published

Social login/share buttons for Angular 6, 7, 8

Downloads

477

Readme

Social login/share buttons for Angular 6, 7, 8

Generic badge Generic badge+ AOT Compatible

Reference

Original project : sabyasachibiswal https://github.com/sabyasachibiswal/angular5-social-login

Last project: ng6-social-button https://www.npmjs.com/package/ng6-social-button

Built by using Angular6 ng generate library

Scope

  1. FaceBook Login/Share buttons
  2. Google Login button
  3. LinkedIn Login/Share buttons
  4. Other(weChat) buttons are coming soon
  5. ...

ezgif com-video-to-gif

screen shot 2018-08-15 at 9 15 21 pm

Get started

Install via npm

npm install --save ngx-social-button

Import the module

There are two ways to import the module

option 1

...
 
import {
    NgxSocialButtonModule,
    SocialServiceConfig
} from "ngx-social-button";

// Configs
export function getAuthServiceConfigs() {
    let config = new SocialServiceConfig()
        .addFacebook("Your-Facebook-app-id")
        .addGoogle("Your-Google-Client-Id")
        .addLinkedIn("Your-LinkedIn-Client-Id");
    return config;
}

@NgModule({
  imports: [
      ...
      NgxSocialButtonModule
  ],
  providers: [
      ...
      {
          provide: SocialServiceConfig,
          useFactory: getAuthServiceConfigs
      },
  ],
  bootstrap: [...]
})

option 2

...
 
import {
    NgxSocialButtonModule,
    FacebookLoginProvider,
    GoogleLoginProvid,
    SocialServiceConfig
} from "ngx-social-button";

// Configs
export function getAuthServiceConfigs() {
    let config = new SocialServiceConfig(
       [
           new FacebookLoginProvider("Your-Facebook-app-id"),
           new GoogleLoginProvid("Your-Google-Client-Id")
       ]
    );
    return config;
}

@NgModule({
  imports: [
      ...
      NgxSocialButtonModule
  ],
  providers: [
      ...
      {
          provide: SocialServiceConfig,
          useFactory: getAuthServiceConfigs
      },
  ],
  bootstrap: [...]
})

Usage

option 1: Use buttons

in social.component.ts

import { Component } from '@angular/core';
import {
    SocialService
} from "ngx-social-button";
@Component({
  selector: 'app-social',
  templateUrl: './social.component.html',
  styleUrls: ['./social.component.css']
})
export class SocialComponent {

    shareObj = {
        href: "FACEBOOK-SHARE-LINK",
        hashtag:"#FACEBOOK-SHARE-HASGTAG"
    };

  constructor(private socialAuthService: SocialService){}

    signOut(){
       if(this.socialAuthService.isSocialLoggedIn()){
           this.socialAuthService.signOut().catch((err)=>{

           });
       }
    }

    getSocialUser(socialUser){
        console.log(socialUser);
    }
 }

in social.component.html

...
<facebook-login-button  [style]="'round'" (socialUser)="getSocialUser($event)"></facebook-login-button>

<facebook-share-button [share]="shareObj" ></facebook-share-button>

<google-login-button (socialUser)="getSocialUser($event)"></google-login-button>

<linkedin-login-button (socialUser)="getSocialUser($event)"></linkedin-login-button>

<linkedin-share-button></linkedin-share-button>

<button (click)="signOut()">SOCIAL LOGOUT</button>
...

option 2: Use providers with custom button

in social.component.ts

import { Component } from '@angular/core';
import {
    SocialService,
    FacebookLoginProvider,
    GoogleLoginProvider
} from "ngx-social-button";
@Component({
  selector: 'app-social',
  templateUrl: './social.component.html',
  styleUrls: ['./social.component.css']
})
export class SocialComponent {

    shareObj = {
        href: "FACEBOOK-SHARE-LINK",
        hashtag:"#FACEBOOK-SHARE-HASGTAG"
    };

  constructor(private socialAuthService: SocialService){}

    signOut(){
       if(this.socialAuthService.isSocialLoggedIn()){
           this.socialAuthService.signOut().then(()=>{
               ...
           }).catch((err)=>{
              ...
           });
       }
    }

    public socialSignIn(socialPlatform : string) {
        let socialPlatformProvider;
        if(socialPlatform == "facebook"){
            socialPlatformProvider = FacebookLoginProvider.PROVIDER_TYPE;
        }else if(socialPlatform == "google"){
            socialPlatformProvider = GoogleLoginProvider.PROVIDER_TYPE;
        }
    
        this.socialAuthService.signIn(socialPlatformProvider).then(
        (socialUser) => {
            console.log(socialPlatform+" sign in data : " , socialUser);
            // Now sign-in with userData
            ...        
        });
    }

    public facebookSharing(shareObj: any){
        this.socialAuthService.facebookSharing(shareObj);
    }
 }

in social.component.html

...
<button (click)="socialSignIn('facebook')">Sign in with Facebook</button>

<button (click)="facebookSharing(shareObj)">Facebook Share</button>  

<button (click)="socialSignIn('google')">Signin in with Google</button>  
	
<button (click)="signOut()">SOCIAL LOGOUT</button>
...

Login Buttons API

| Property | Description | Type | Default | |-------------|:--------------------------------:|--------------------------:|------------------------:| | (socialUser)| trigger when signin done | EventEmitter<{SocialUser}>| - | | [scopes] | social custom scopes | [string] | facebook:['email', 'public_profile'] | | [style] ? | change button style if be:'round' | [string] | - |

Share Buttons API

| Property | Description | Type | Default | |-------------|:--------------------------------:|--------------------------:|------------------------:| | [share] | social share object | object | facebook:{href:Current_URL, hashtag: null} | | | | | linkedin:{href:Current_URL} |

SocialUser Object API

| Property | Description | Type | |-------------|:--------------------------------:|--------------------------:| | provider | social provider: facebook/google/wechat | string |
| id | user id | string |
| email | social user's email | string |
| name | social user's name | string |
| image | social profile image URL | string |
| accessToken?| return oauth2.0 accessToken if has | string |
| idToken? | return oauth2.0 idToken if has | string |


Social Client/App Id

Facebook App Id :

You need to create your own app by going to Facebook Developers page. Sign in and Add new app under My Apps and configure Valid OAuth redirect URIs.

Google Client Id :

Follow this official documentation on how to Create a Google API Console project and client ID.

Angular Twitter sharing, using API directly

<a class="share-btn share-btn-branded share-btn-twitter"
	   href="https://twitter.com/share"
	   [attr.data-text]="text" [attr.data-url]="url" 
	   title="Share on Twitter">
		<span class="share-btn-icon"></span>
		<span class="share-btn-text">Twitter</span>
</a>