1.0.2 • Published 4 years ago

vue-facebook-login-component-cm v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Install

npm install --save vue-facebook-login-component

Usage

To use the component in your template, simply import and register with your component.

Script

import VFacebookLogin from 'vue-facebook-login-component'

// OR, use cherry-pick export (better consistency)
import { VFBLogin as VFacebookLogin } from 'vue-facebook-login-component'

export default {
  components: {
    VFacebookLogin
  }
}

Template

<v-facebook-login app-id="966242223397117"></v-facebook-login>

Props

NameTypeDefaultNote
valueObject{ connected: false }Used for one-way V-Model. ***
app-idStringNoneRequired. ***
versionString'v3.1' **, ***
optionsObject{} *, **, ***
login-optionsObject{ scope: 'email' } *, **, ***
button-styleObject{} *
loader-styleObject{} *
token-styleObject{} *
text-styleObject{} *
transitionArray[]Array of CSS transition values. Example:[ 'background-color 0.15s ease-in-out', 'padding 0.15s ease-in-out', ... ].

* - Properties should be camel-case. ** - See Facebook for available values. *** - Scope-component property.

Slots

NameDefaultDescription
login'Sign in with Facebook'
logout'Sign out with Facebook'
working'Please wait...'
beforeNONEBefore all nested elements.
afterNONEAfter all nested elements.
error'⛔ Network Error'Shown on SDK load failure.

Events

NamePayloadDescriptionNote
sdk-init(sdkObject)Returns an object with a Facebook SDK instance. *
login(responseObject)User attempted login. *
logout(responseObject)User attempted logout. *
connectBooleanUser is connected. *
clickNone  *

* - Scope-component event.

Scope component (Advanced Customization)

If props, slots and events do not satisfy your customization needs, you can use an underlying component called v-fb-login-scope. This component uses the render prop (known as "scoped-slot" in Vue) approach for composition. This means, it does not render any html or css, hence it has no added-value on its own. It only exposes a scoped-slot with attributes and methods that are committed as API.

Props/Events

Refer to the tables above for scope-component specific props/events.

Scoped-Slot Scope (Attributes and Methods)

NameTypeDescription
loginFunctionLogin handler.
logoutFunctionLogout handler.
toggleLoginFunctionToggles login/logout.
workingBooleanSDK-initialization/login/logout is currently taking place.
connectedBooleanUser is logged in.
disconnectedBooleanUser is logged out.
enabledBooleanButton is enabled.
disabledBooleanButton is disabled.

Scope component example (for a full example see source).

<template>
  <v-facebook-login-scope>
    <!-- Compose HTML/CSS here, otherwise nothing will be rendered -->
    <button slot-scope="scope">
      <!-- Compose with `scope` here -->
    </button>
  </v-facebook-login-scope>
</template>

<script>
  import { VFBLoginScope } from 'vue-facebook-login-component'

  export default {
    components: {
      VFBLoginScope
    }
  }
</script>

Loading Facebook SDK

This component embeds the Facebook SDK snippet, so you don't have to do it yourself. However, if you want to embed it yourself, you can do so and the component will pick up the SDK instance instead.

IE support

Add babel-polyfill to your app dependencies.

Development

Fork, clone and use the following scripts.

For component:

npm start

For documentation (includes a demo):

npm run docs

Support

Please open an issue for support.

License

Copyright (c) 2018 by MIT