0.1.2 • Published 3 years ago

@bloomprotocol/waci-kit-react v0.1.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

WACI Kit React

Render a QR Code or button to initiate a WACI interaction

Installation

npm i @bloomprotocol/waci-kit-react

OR

yarn add @bloomprotocol/waci-kit-react

Usage

WACIElement will render a QR code or button based on the client's platform. By default it will render a button on mobile clients.

import { FC } from 'react';
import { WACIElement } from '@bloomprotocol/waci-kit-react';

const MyComp: FC = () => {
  return (
    <WACIElement
      data={{
        challengeTokenUrl:
          'https://example.com/api/v1/waci-challenge/9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
        version: '1',
      }}
      buttonProps={{
        size: 'lg',
        type: 'bloom',
      }}
    />
  );
};

QR Example Button Example

Props

NameDescriptionType
dataThe data to be rendered in the QR code or buttonSee below
modeWhether to render a QR code or button"qr" \| "button" \| (parsedResult: Bowser.Parser.ParsedResult) => ("qr" \| "button")
qrPropsProps for the rendered QR codeSee below
buttonPropsProps for the rendered buttonSee below

Data

This is the WACI payload.

NameDescriptionTypeRequired
challengeTokenUrlGET endpoint that returns a challengeTokenstringYes
versionThe version of the payload"1"Yes

QR Props

The QR props come from QR React, for more details look here.

Button Props

In addition to the custom props outlined below you can provide any extra <a> props.

NameDescriptionTypeRequired
sizeThe size of button to render"lg" \| "md" \| "sm"Yes
typeThe type of button to renderDependent on size, see belowYes
invertWhether the text and background colors should be switched (only applicable when size === "sm")booleanNo
import { FC } from 'react';
import { WACIElement } from '@bloomprotocol/waci-kit-react';

const MyComp: FC = () => {
  return (
    <WACIElement
      mode="button"
      data={{
        challengeTokenUrl:
          'https://example.com/api/v1/waci-challenge/9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
        version: '1',
      }}
      buttonProps={{
        size: 'md',
        type: 'connect',
      }}
    />
  );
};

Button Type

SizeType
"lg""log-in" \| "sign-up" \| "connect" \| "bloom" \| "verify"
"md""log-in" \| "sign-up" \| "connect" \| "bloom" \| "verify"
"sm""square" \| "rounded-square" \| "circle" \| "squircle"