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

react-fb-login-btn

v1.0.1

Published

A login with Facebook react component

Downloads

142

Readme

npm version

react-fb-login-btn Component Documentation

A customizable, reusable, and type-safe React component for integrating Facebook login functionality into your applications. The react-fb-login-btn component is built with TypeScript and Tailwind CSS, supports theming, different button shapes, left-to-right and right-to-left text directions, and handles Facebook login flow internally using the Facebook SDK.

Table of Contents


Installation

Install the package via npm:

npm install react-fb-login-btn

Or using yarn:

yarn add react-fb-login-btn

Features

  • TypeScript Support: Built with TypeScript for type safety and IntelliSense support.
  • Theming: Supports predefined themes (blue, dark, light) and custom themes.
  • Shapes: Offers rectangular and circle button shapes.
  • Directionality: Handles both left-to-right (ltr) and right-to-left (rtl) text directions.
  • Customization: Allows custom text, styles, themes, and permissions (scope).
  • Facebook SDK Integration: Manages the Facebook login flow internally.
  • Event Handling: Provides onSuccess and onFail callbacks to handle login outcomes.
  • Tailwind CSS: Utilizes Tailwind CSS for styling.

Basic Usage

First, import the FacebookLoginButton component into your project:

import React from 'react';
import { FacebookLoginButton } from 'react-fb-login-btn';

const App = () => {
  const handleSuccess = (response: fb.StatusResponse) => {
    console.log('Login successful:', response);
    // Handle successful login here
  };

  const handleFailure = (error: any) => {
    console.error('Login failed:', error);
    // Handle login failure here
  };

  return (
    <div>
      <FacebookLoginButton
        appId="YOUR_FACEBOOK_APP_ID"
        onSuccess={handleSuccess}
        onFail={handleFailure}
      />
    </div>
  );
};

export default App;

Note: Replace "YOUR_FACEBOOK_APP_ID" with your actual Facebook App ID obtained from the Facebook Developers website.


Props

The FacebookLoginButton component accepts the following props:

| Prop | Type | Default | Description | | ------------- | ---------------------------------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | appId | string | Required | Your Facebook App ID. | | shape | 'rectangular' | 'circle' | 'rectangular' | The shape of the button. | | direction | 'ltr' | 'rtl' | 'ltr' | The text direction of the button. | | text | string | 'Login with Facebook' | Custom text to display on the button. | | style | React.CSSProperties | {} | Custom inline styles to apply to the button. | | theme | 'blue' | 'dark' | 'light' | 'custom' | 'blue' | The theme of the button. Use 'custom' to provide custom theme colors via customTheme. | | customTheme | Partial<Theme> | {} | Custom theme colors used when theme is set to 'custom'. | | onSuccess | (response: fb.StatusResponse) => void | undefined | Function to call on successful login. | | onFail | (error: any) => void | undefined | Function to call on login failure. | | scope | string | 'public_profile,email' | Permissions to request during login. |

Theme Type Definition

The Theme interface defines the shape of the customTheme prop:

interface Theme {
  backgroundColor: string;       // Tailwind CSS class for background color
  textColor: string;             // Tailwind CSS class for text color
  hoverBackgroundColor: string;  // Tailwind CSS class for hover background color
}

Examples

For detailed and interactive examples, please visit our Storybook documentation.


Contributing

Contributions are welcome! If you have ideas for improvements or find bugs, please feel free to contribute.

Getting Started

  1. Clone the Repository:

    git clone https://github.com/yourusername/react-fb-login-btn.git
    cd react-fb-login-btn
  2. Install Dependencies:

    npm install
  3. Run Storybook:

    Start Storybook to develop and test components interactively.

    npm run storybook
  4. Run Tests:

    Execute unit tests to ensure your changes do not break existing functionality.

    npm run test
  5. Run Linting:

    Ensure code quality and consistency by running the linter.

    npm run lint
  6. Build the Package:

    Build the package before publishing or testing in other projects.

    npm run build

Guidelines

  • Branching: Create a new branch for your feature or bugfix.

    git checkout -b feature/your-feature-name
  • Commit Messages: Write clear and descriptive commit messages.

  • Pull Requests: Submit a pull request with a detailed description of your changes.

Code Quality

  • TypeScript: Ensure all code is type-safe.

  • Linting: Follow the coding style and conventions. Run linting before committing.

    npm run lint
  • Testing: Write unit tests for new features or bug fixes.

Reporting Issues

If you encounter any issues or have questions, please open an issue on the GitHub repository.


License

This project is licensed under the MIT License.


Note: By providing a link to your Storybook documentation, users can explore interactive examples and see all the different configurations of your component. This approach keeps your README concise and focused while still offering users access to detailed usage examples.


Would you like me to help update any specific parts of the README or assist with setting up the Storybook link?