• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    JavaScript
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple plugin to include a custom Facebook sign-in button into your web app.

vue-facebook-signin-button

A simple Vue plugin to include a custom Facebook sign-in button into your web app.

Screenshot

Install

This plugin can be installed as a module

$ npm install vue-facebook-signin-button

or, if you're not in a modular environment, just include it as a <script>.

Usage

Important: The Facebook SDK must first be loaded asynchronously for the plugin to work. Something like this will do:

  window.fbAsyncInit = function() {
    FB.init({
      appId      : '{your-app-id}',
      cookie     : true,  // enable cookies to allow the server to access the session
      xfbml      : true,  // parse social plugins on this page
      version    : 'v2.8' // use graph api version 2.8
    });
  };
  (function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));

Step 1: import and use the plugin if you're in a modular environment (you don't need this step otherwise, as the plugin will register itself).

import FBSignInButton from 'vue-facebook-signin-button'
Vue.use(FBSignInButton)

Step 2: Now you have a fb-signin-button global component, ready for use. It's best to demonstrate the usage with an example:

<template>
  <fb-signin-button
    :params="fbSignInParams"
    @success="onSignInSuccess"
    @error="onSignInError">
    Sign in with Facebook
  </fb-signin-button>
</template>

<script>
export default {
  data () {
    return {
      fbSignInParams: {
        scope: 'email,user_likes',
        return_scopes: true
      }
    }
  },
  methods: {
    onSignInSuccess (response) {
      FB.api('/me', dude => {
        console.log(`Good to see you, ${dude.name}.`)
      })
    },
    onSignInError (error) {
      console.log('OH NOES', error)
    }
  }
}
</script>

<style>
.fb-signin-button {
  /* This is where you control how the button looks. Be creative! */
  display: inline-block;
  padding: 4px 8px;
  border-radius: 3px;
  background-color: #4267b2;
  color: #fff;
}
</style>

That's it!

Looking for the Google counterpart?

License

MIT © Phan An

More Repositories

1

htaccess

✂A collection of useful .htaccess snippets.
12,497
star
2

kupo

✅ Simple site launch checklist checker/validator.
PHP
382
star
3

vue-google-signin-button

🔐 A simple Vue plugin to include a Google sign-in button into your web app.
JavaScript
288
star
4

vue-linkify

A simple Vue directive to turn URL's and emails into clickable links
JavaScript
81
star
5

vue-snippets

✂️A collection of Vue snippets
CSS
81
star
6

tieqviet

A trivial module to convert Vietnamese into the new, experimental, IPA
JavaScript
74
star
7

cascading-config

Bringing the cascading configuration system back to Laravel 5 and its sister project, Lumen.
PHP
55
star
8

factoria

Simplistic model factory for Node/JavaScript
TypeScript
51
star
9

slider-puzzle

A simple slider puzzle built with Vue
JavaScript
49
star
10

vuequery

Traverse Vue's component tree with ease.
TypeScript
40
star
11

remote

Simple remote connection / SFTP / SSH for Laravel 5
PHP
31
star
12

vue-fractal

An attempt to port https://github.com/Swizec/react-fractals/ into Vue
JavaScript
30
star
13

vue-test-helpers

Some helpers for vue-test-utils
JavaScript
30
star
14

tieqviet-demo

Demo for tieqviet module
Vue
28
star
15

phanan.net

🏡 My homepage, built on Nuxt.js
Vue
9
star
16

redmine_webhook

A Redmine plugin posts webhook on creating and updating tickets, originally forked from @sue
Ruby
8
star
17

vuebus

A simple event bus in Vue 2.x
TypeScript
8
star
18

til

The source code for https://til.phanan.net
HTML
7
star
19

laravel-5-cascading-config

Re-enable cascading configuration system in Laravel 5
PHP
7
star
20

smart-playlist-creator

A PoC smart playlist creator (à la iTunes / Winamp)
Vue
6
star
21

log

A minimal WordPress theme
PHP
6
star
22

virtualmin-nginx-config-hook

A Virtualmin hook to generate a nginx server config file post Apache server setup
Shell
4
star
23

unit-test-async-component

A demo on how to unit test Vue async components with Vue Test Utils
Vue
4
star
24

vite-playground

Vue
2
star
25

counter-meetup

The repo for the first Vue meetup
JavaScript
2
star
26

vue-jquery-mask

A demo repo for Vue+jquery-mask
JavaScript
2
star
27

translation-sample

2
star
28

laravel-attr-bug

PHP
1
star