3.0.12 • Published 2 years ago

@tap-payments/js-connect v3.0.12

Weekly downloads
116
License
ISC
Repository
-
Last release
2 years ago

Table of Contents

Purpose

  • Connect is Tap's Auth Package which gives user the ability to Sign up, Sign in and Forgot Password.
  • It is exported as npm package and also as js library.
  • It is shipped with two built-in themes dark/light which can be overridden by user.
  • It can be used for single purpose (Sign up, Sign in, Forgot Password) or with full functionality (Connect).

Demo

Demonstrating different modes with multiple animation types and languages.

Installation

NPM

npm i @tap-payments/js-connect

JS

<link rel="stylesheet" href="https://tap-connecet.b-cdn.net/build/css/Connect.css" />
<script type="text/javascript" src="https://tap-connecet.b-cdn.net/build/js/Connect.js.map"></script>
<script type="text/javascript" src="https://tap-connecet.b-cdn.net/build/js/Connect.js"></script>

Usage

After installing the package by cmd/terminal, add the following line to your project to import the required files. The package includes ConnectPackage, TapAuthButton, DialogMode, AnimationType, PageMode. (you can import one or all components based on your target).

DialogMode used to change the dialog mode (POPUP, FULLPAGE). AnimationType used to change the dialog animation (FADE, SLIDEUP, SLIDEDOWN, SLIDELEFT, SLIDERIGHT). PageMode used to changes the page Languages used to the change the direction of the dialog (EN, AR).

Usage as js library

<html>
  <head>
    <title>Tap Connect Demo JS Element</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
  </head>
  <body>
    <div id="TapConnect"></div>
    <link rel="stylesheet" href="https://tap-connecet.b-cdn.net/build/css/Connect.css" />
    <script type="text/javascript" src="https://tap-connecet.b-cdn.net/build/js/Connect.js"></script>
    <script>
      Connect.renderConnectElement({
        publicKey: 'pk_test_OxCj0DhX9EyTLpGqsu2wHMon',
        scopes: ['API_ACCESS_KEY'],
        liveMode: false,
        buttonText: 'Login',
        pageMode: Connect.PageMode.LOGIN,
        language: 'en',
        containerID: 'TapConnect',
        dialogMode: Connect.DialogMode.POPUP,
        animationType: Connect.AnimationType.SLIDEDOWN,
        animationDuration: 500,
        enableBackdropClick: false,
        theme: {
          direction: 'ltr',
        },
        onSuccess: (data) => {
          alert(JSON.stringify(data));
        },
      });
    </script>
  </body>
</html>

Usage as npm package

If you want to use connect or login or signup need to import below one.

import { ConnectPackage, DialogMode, AnimationType } from '@tap-payments/js-connect';

Example Login

import React, { Fragment } from 'react';
import { useVm, useAppCtx } from '../../hooks';
import LoginVM from './LoginVM';
import { observer } from 'mobx-react-lite';
import { ConnectPackage, DialogMode, AnimationType } from '@tap-payments/js-connect';

function Login(props) {
  if (props.isAuthorized) return <Fragment />;
  const vm = useVm(LoginVM, [useAppCtx(), props]);
  return (
    <ConnectPackage
      publicKey="pk_test_OxCj0DhX9EyTLpGqsu2wHMon"
      scopes={['API_ACCESS_KEY']}
      onSuccess={vm.onSuccess}
      initialAuthType={vm.initialAuthType}
      dialogMode={DialogMode.POPUP}
      countryCode={'965'}
      pageMode={PageMode.LOGIN}
      animationType={AnimationType.SLIDEDOWN}
      animationDuration={500}
      enableBackdropClick={false}
      defaultEmailOrMobile={null}
      hideInitialLoader={props.hideInitialLoader}
      theme={{
        direction: vm.appDirection,
      }}
      moveToSignup={vm.moveToSignup}
    />
  );
}

export default Login;

Example Signup

import React, { Fragment } from 'react';
import { useVm, useAppCtx } from '../../hooks';
import SignupVM from './SignupVM';
import { observer } from 'mobx-react-lite';
import { ConnectPackage, DialogMode, AnimationType, PageMode } from '@tap-payments/js-connect';

function Signup(props) {
  const vm = useVm(SignupVM, [useAppCtx(), props]);
  return (
    <ConnectPackage
      publicKey="pk_test_OxCj0DhX9EyTLpGqsu2wHMon"
      scopes={['API_ACCESS_KEY']}
      onSuccess={vm.onSuccess}
      pageMode={PageMode.SIGNUP}
      initialAuthType={vm.initialAuthType}
      dialogMode={DialogMode.POPUP}
      countryCode={'965'}
      removeAuthType={removeAuthType}
      animationType={AnimationType.SLIDEDOWN}
      animationDuration={500}
      enableBackdropClick={false}
      defaultEmailOrMobile={null}
      hideInitialLoader={props.hideInitialLoader}
      theme={{
        direction: vm.appDirection,
      }}
    />
  );
}

export default Signup;

Example Connect

import React, { Fragment } from 'react';
import { useVm, useAppCtx } from '../../hooks';
import ConnectVM from './ConnectVM';
import { observer } from 'mobx-react-lite';
import { removeAuthType } from '../../utils/LocalStorage/authType';
import { ConnectPackage, DialogMode, AnimationType } from '@tap-payments/js-connect';

function Connect(props) {
  if (props.isAuthorized) return <Fragment />;
  const vm = useVm(ConnectVM, [useAppCtx(), props]);
  return (
    <ConnectPackage
      publicKey="pk_test_OxCj0DhX9EyTLpGqsu2wHMon"
      scopes={['API_ACCESS_KEY']}
      onSuccess={vm.onSuccess}
      pageMode={PageMode.CONNECT}
      initialAuthType={vm.initialAuthType}
      dialogMode={DialogMode.POPUP}
      countryCode={'965'}
      removeAuthType={removeAuthType}
      animationType={AnimationType.SLIDEDOWN}
      animationDuration={500}
      enableBackdropClick={false}
      defaultEmailOrMobile={null}
      hideInitialLoader={props.hideInitialLoader}
      theme={{
        direction: vm.appDirection,
      }}
    />
  );
}

export default Connect;

If you want to use TapAuthButton need to import below one.

import { TapAuthButton, DialogMode, AnimationType, PageMode } from '../../src/index';

Example TapAuthButton

TapAuthButton will automatically control open and close functionality inside.

We have another option user can control open/close popup outside also,

import { ConnectPackage } from '@tap-payments/js-connect';

To open popup => ConnectPackage.open(params);

To close popup => ConnectPackage.close();

import { TapAuthButton, DialogMode, AnimationType } from '@tap-payments/js-connect';

<TapAuthButton
  publicKey="pk_test_OxCj0DhX9EyTLpGqsu2wHMon"
  scopes={['API_ACCESS_KEY']}
  dialogMode={DialogMode.POPUP}
  pageMode={PageMode.CONNECT}
  buttonText={'Connect'}
  countryCode={'965'}
  animationType={AnimationType.SLIDEUP}
  animationDuration={500}
  enableBackdropClick={true}
  hideInitialLoader={props.hideInitialLoader}
  onSuccess={props.handleSuccess}
  theme={{
    direction: 'ltr',
  }}
/>

Technical Overview

TapAuthButton Properties

property nameTypeStatusDefault valueDescription
publicKeystringpublic key.
scopesArray of stringsapi access key.
buttonTextstringloginbutton text.
pageModePageModePageMode.LOGINbutton text.
languagestringenlanguage ar or en.
variantstringcontainedbutton variant.
showLogobooltrueto show the button logo.
liveModeboolfalseit will decide live/sandbox mode.
signinDirectorystringloginto set directory for login incase of show connect through url.
signupDirectorystringsignupto set directory for signup incase of show connect through url.
forgotDirectorystringforgotto set directory for forgot incase of show connect through url.
footerstringsignup_powered_byfooter text by default its key it will take the text through key from firebase.
companyNamestringsignup_tap_paymentscompany name.
showHeaderLogostringtrueto show/hide header logo.
directionstringltrdirection of the dialog.
pageModePageModePageMode.LOGINdialog page mode.
hideInitialLoaderboolfalseto open dailog drirectly instead of show loader.
dialogModeDialogModeDialogMode.FULLPAGEhow to show the dialog popup or fullpage.
animationTypeAnimationTypeAnimationType.SLIDEUPto change the animation behaviour .
animationDurationint500animation duaration.
enableBackdropClickboolfalsethis is enabled only for dialogmode is popup to restrict close popup on outside click.
themeobjecttheme: {direction: 'ltr'}theme of the package.
openPopupbooltrueshow or hide the popup .
onSuccessFunctionon successfull case will trigger that function.
onFailureFunctionon any failure case will trigger that function.
onCancelFunctionif we cancel the process will trigger this function.
onUpdateFunctionevery on update will trigger this function.
moveToLoginFunctionto move to login will trigger it.
moveToSignupFunctionto move to signup will trigger it.
initialAuthTypeanyto know the initial auth type.
removeAuthTypeFunctionto remove authtype.
countryCodestring'965'initial country code.
defaultEmailOrMobilestringto know the initial username.
to show or hide the signup section.

ConnectPackage Properties

property nameTypeStatusDefault valueDescription
publicKeystringpublic key.
scopesArray of stringsapi access key.
liveModeboolfalseit will decide live/sandbox mode.
signinDirectorystringloginto set directory for login incase of show connect through url.
signupDirectorystringsignupto set directory for signup incase of show connect through url.
forgotDirectorystringforgotto set directory for forgot incase of show connect through url.
footerstringsignup_powered_byfooter text by default its key it will take the text through key from firebase.
companyNamestringsignup_tap_paymentscompany name.
showHeaderLogostringtrueto show/hide header logo.
directionstringltrdirection of the dialog.
pageModePageModePageMode.LOGINdialog page mode.
hideInitialLoaderboolfalseto open dailog drirectly instead of show loader.
dialogModeDialogModeDialogMode.FULLPAGEhow to show the dialog popup or fullpage.
animationTypeAnimationTypeAnimationType.SLIDEUPto change the animation behaviour .
animationDurationint500animation duaration.
enableBackdropClickboolfalsethis is enabled only for dialogmode is popup to restrict close popup on outside click.
themeobjecttheme: {direction: 'ltr'}theme of the package.
openPopupbooltrueshow or hide the popup .
onSuccessFunctionon successfull case will trigger that function.
onFailureFunctionon any failure case will trigger that function.
onCancelFunctionif we cancel the process will trigger this function.
onUpdateFunctionevery on update will trigger this function.
moveToLoginFunctionto move to login will trigger it.
moveToSignupFunctionto move to signup will trigger it.
initialAuthTypeanyto know the initial auth type.
removeAuthTypeFunctionto remove authtype.
countryCodestring'965'initial country code.
defaultEmailOrMobilestringto know the initial username.
to show or hide the signup section.

Theme

Create Custom Theme

To override the theme, create customized theme using createMuiTheme() then wrap Connect with a <ThemeProvider/> that is using the customized theme.

Theme Overriding Demo

Sample implementation from the demo project:

Default Theme Properties

The following objects are used in the package and can be overridden:

Author

3.0.12

2 years ago

3.0.10

2 years ago

3.0.11

2 years ago

3.0.9

2 years ago

3.0.8

2 years ago

3.0.7

2 years ago

3.0.6-beta.1

2 years ago

3.0.6-beta.4

2 years ago

3.0.6-beta.5

2 years ago

3.0.6-beta.2

2 years ago

3.0.6-beta.3

2 years ago

3.0.4

3 years ago

3.0.5

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.0-alpha.11

3 years ago

2.0.0-alpha.10

3 years ago

2.0.0-alpha.9

3 years ago

2.0.0-alpha.7

3 years ago

2.0.0-alpha.8

3 years ago

2.0.0-alpha.3

3 years ago

2.0.0-alpha.4

3 years ago

2.0.0-alpha.5

3 years ago

2.0.0-alpha.6

3 years ago

2.0.0-alpha.1

3 years ago

2.0.0-alpha.2

3 years ago

1.0.4

3 years ago

1.0.4-alpha.1

3 years ago

1.0.3

3 years ago

1.0.3-alpha.8

3 years ago

1.0.3-alpha.7

3 years ago

1.0.3-alpha.5

3 years ago

1.0.3-alpha.6

3 years ago

1.0.3-alpha.4

3 years ago

1.0.3-alpha.3

3 years ago

1.0.3-alpha.2

3 years ago

1.0.3-alpha.1

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.1-beta.36

3 years ago

0.0.1-beta.35

3 years ago

0.0.1-beta.34

3 years ago

0.0.1-beta.33

3 years ago

0.0.1-beta.32

4 years ago

0.0.1-beta.31

4 years ago

0.0.1-beta.30

4 years ago

0.0.1-beta.29

4 years ago

0.0.1-beta.28

4 years ago

0.0.1-beta.27

4 years ago

0.0.1-beta.25

4 years ago

0.0.1-beta.26

4 years ago

0.0.1-beta.24

4 years ago

0.0.1-beta.23

4 years ago

0.0.1-beta.21

4 years ago

0.0.1-beta.20

4 years ago

0.0.1-beta.12

4 years ago

0.0.1-beta.22

4 years ago

0.0.1-beta.18

4 years ago

0.0.1-beta.19

4 years ago

0.0.1-beta.14

4 years ago

0.0.1-beta.13

4 years ago

0.0.1-beta.16

4 years ago

0.0.1-beta.15

4 years ago

0.0.1-beta.10

4 years ago

0.0.1-beta.11

4 years ago

0.0.1-beta.9

4 years ago

0.0.1-beta.8

4 years ago

0.0.1-beta.7

4 years ago

0.0.1-beta.6

4 years ago

0.0.1-beta.5

4 years ago

0.0.1-beta.4

4 years ago

0.0.1-beta.3

4 years ago

0.0.1-beta.2

4 years ago

0.0.1-beta.1

4 years ago