0.0.26 • Published 11 months ago

@tusken-s/facebook-tools v0.0.26

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Facebook Tools

npm type definitions

The tool set is a comprehensive TypeScript and React-based client-side module that provides first-class functionality for adding Social Plugins and Facebook Login to your web application.

This module allows seamless integration of Facebook features into your React components. The following example demonstrates the usage of the components provided by Nom:

Installation

To install the tool set, use the following command:

npm install @tusken-s/facebook-tools
# OR
yarn add @tusken-s/facebook-tools

Usage

Import the required components from the Nom module as shown below:

import { Script, Chat, Button } from "@tusken-s/facebook-tools";

Script Component

The Script component enables you to load the necessary Facebook scripts and initialize the Social Plugins. Here is an example of how to use it:

import { Features, Script } from "@tusken-s/facebook-tools";
...
<Script
  cookie={false}
  nonce="xxxxxxx"
  features={[Features.LOGIN_BUTTON, Features.CHAT_PLUGIN]}
  appId={facebook_app_id}
  pageId={facebook_page_id}
/>

Make sure to replace your_theme_color, facebook_app_id and facebook_page_id with the actual values from your application's configuration.

Script Component Props

PropTypeDescription
appIdstringThe Facebook app ID.
pageIdstringThe Facebook page ID.
cookiebooleanSpecifies whether the cookie should be used. Default: false.
noncestringThe nonce value for script security.
languageISOLangCountryThe language for the script.
featuresArray\An array of Facebook features to enable.

Chat Component

The Chat component allows you to embed a Facebook Chat Plugin into your application. Here is an example of how to use it:

<Chat minimized={true} color={your_theme_color} pageId={facebook_page_id} />

Ensure to replace facebook_page_id with the appropriate Facebook page ID from your application's configuration. Additionally, you can customize the minimized and color props to fit your specific requirements.

Chat Component Props

PropTypeDescription
pageIdstringThe Facebook page ID.
colorstringThe color of the chat plugin.
minimizedbooleanSpecifies whether the chat plugin is minimized.

Login Button Component

The Button component provides an easy way to integrate Facebook Login into your application. Here is an example of how to use it:

import { Button } from "@tusken-s/facebook-tools";

<Button
  scope="public_profile,email"
  callback={loginFacebookCallback}
  width="100%"
>
  ...
</Button>;

Replace loginFacebookCallback with the function that will handle the Facebook login callback in your application. Customize the scope and width props as needed.

Button Component Props

PropTypeDescription
disabledbooleanSpecifies whether the button is disabled. Default: false.
widthstring | numberThe width of the button.
scopestringThe Facebook login permissions scope.
buttonType"continue_with" | "login_with"The type of the button.
callback(x: StatusResponse"authResponse") => voidThe callback function triggered on successful login.
styleCSSPropertiesCustom styles to be applied to the button.
languageISOLangCountryThe language for the button.
childrenReactNodeThe content to be displayed inside the button.

Facebook SDK Type Definitions

In addition to the React components and functionality mentioned above, this module also offers comprehensive type definitions for Facebook's SDK native methods, classes, and tools. By simply installing the module, you gain access to the full range of Facebook SDK features with TypeScript support.

For example, you can use the Facebook SDK methods and classes as follows:

// Access Facebook SDK methods and classes
window.FB.init({
  appId: "your_app_id",
  version: "v12.0",
});

window.FB.api("/me", (response) => {
  console.log(response);
});

and you won't get any type errors.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request on the GitHub repository.

Read the contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to MUI.

Notice that contributions go far beyond pull requests and commits. Although we love giving you the opportunity to put your stamp on the module, we also are thrilled to receive a variety of other contributions.

Changelog

The changelog is regularly updated to reflect what's changed in each new release.

Roadmap

Future plans and high-priority features and enhancements can be found soon in our roadmap page.

License

This project is licensed under the terms of the MIT license.

Sponsoring services

Our Sponsors push our Research, Development & Infrastructure:

Tuskens allow us to host the Git repository and coordinate contributions.

acornacorn-jsxajvansi-regexansi-stylesargparsearray-buffer-byte-lengtharray-includesarray-unionarray.prototype.flatmaparray.prototype.tosortedavailable-typed-arraysbalanced-matchbrace-expansionbracescall-bindcallsiteschalkcolor-convertcolor-nameconcat-mapcross-spawncsstypedebugdeep-isdefine-propertiesdir-globdoctrinees-abstractes-set-tostringtages-shim-unscopableses-to-primitiveescape-string-regexpeslint-scopeeslint-visitor-keysespreeesqueryesrecurseestraverseesutilsfast-deep-equalfast-difffast-globfast-json-stable-stringifyfast-levenshteinfastqfile-entry-cachefill-rangefind-upflat-cacheflattedfor-eachfs.realpathfunction-bindfunction.prototype.namefunctions-have-namesget-intrinsicget-symbol-descriptionglobglob-parentglobalsglobalthisglobbygopdgrapheme-splitterhashas-bigintshas-flaghas-property-descriptorshas-protohas-symbolshas-tostringtagignoreimport-freshimurmurhashinflightinheritsinternal-slotis-array-bufferis-bigintis-boolean-objectis-callableis-core-moduleis-date-objectis-extglobis-globis-negative-zerois-numberis-number-objectis-path-insideis-regexis-shared-array-bufferis-stringis-symbolis-typed-arrayis-weakrefisexejs-sdsljs-tokensjs-yamljson-schema-traversejson-stable-stringify-without-jsonifyjsx-ast-utilslevnlocate-pathlodash.mergeloose-envifylru-cachemerge2micromatchminimatchmsnatural-comparenatural-compare-liteobject-assignobject-inspectobject-keysobject.assignobject.entriesobject.fromentriesobject.hasownobject.valuesonceoptionatorp-limitp-locateparent-modulepath-existspath-is-absolutepath-keypath-parsepath-typepicomatchprelude-lsprettier-linter-helpersprop-typespunycodequeue-microtaskreact-isregexp.prototype.flagsresolveresolve-fromreusifyrimrafrun-parallelsafe-regex-testschedulersemvershebang-commandshebang-regexside-channelslashstring.prototype.matchallstring.prototype.trimstring.prototype.trimendstring.prototype.trimstartstrip-ansistrip-json-commentssupports-colorsupports-preserve-symlinks-flagtext-tableto-regex-rangetslibtsutilstype-checktype-festtyped-array-lengthunbox-primitiveuri-jswhichwhich-boxed-primitivewhich-typed-arrayword-wrapwrappyyallistyocto-queue
0.0.26

11 months ago

0.0.10

12 months ago

0.0.22

12 months ago

0.0.11

12 months ago

0.0.23

12 months ago

0.0.12

12 months ago

0.0.24

12 months ago

0.0.13

12 months ago

0.0.14

12 months ago

0.0.15

12 months ago

0.0.9

12 months ago

0.0.8

12 months ago

0.0.7

12 months ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago