You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

tbc-common-confirmation-modal

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tbc-common-confirmation-modal

Common Modal for all Trinidad Benham React apps

0.1.2
latest
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

TBC Common React App Confirmation Modal

Common Modal for all Trinidad Benham React apps

Install

npm install --save tbc-common-confirmation-modal

Modal Component:

In component where you wish modal to be activated:

import ConfirmationModalContainer from "tbc-common-confirmation-modal/dist/ConfirmationModalContainer";

<ConfirmationModalContainer {...props} />

Props

PropTypeRequiredDefaultDescription
isOpenBooleanRequiredfalseflag used to determine if modal is open or not
titleStringRecommended""modal's title
bodyStringOptional""modal's body text
largeBooleanOptionalfalseflag used if a large confirmation modal is desired
buttonsObjectRequiredsee belowsee below

Buttons

The buttons object prop is made of three optional sub-objects: left, center, and right, each representing an available button in the modal's footer (see below).

Each buttons sub-object has the following keys:

KeyTypeDefault: leftDefault: centerDefault: rightDescription
showBooleanfalsefalsefalseflag determining if button is displayed
styleString"btn-info""btn-warning""btn-primary"CSS style applied to button
textString"Cancel""Delete""Save"Text of button
iconString"far fa-times-circle""far fa-trash-alt""fas fa-upload"Icon (by CSS class) within button
disabledBooleanfalsefalsefalseflag determining if button is disabled
typeString""""""Type of button (used in forms): "", "submit", or "reset"
functionFunctionnonenonenonefunction fired when button is clicked

Example:

  <ConfirmationModal
    isOpen={toggleState.open.includes("this-modal")}
    title="Confirmation Modal"
    body="Do you confirm?"
    large
    buttons={{
      left: {
        show: true,
        function: () => {
          toggleToggle("this-modal");
        }
      },
      center: {
        show: false // unnecessary, as this is default value
      }
      right: {
        show: true,
        style: "btn-secondary",
        text: "Do Something Blue",
        icon: "fas fa-question-circle",
        disabled: {disabledFlag},
        function: () => {
          doSomethingBlue();
        }
      }
    }}
  />

Along with the Confirmation Modal itself, this module also has access to a separate ModalFooter that can be used in any other modal. It uses the same buttons prop as above.

import ModalFooterContainer from "tbc-common-confirmation-modal/dist/ModalFooterContainer";

<ModalFooterContainer buttons={buttons} />

Required NPM Packages

npm install --save bootstrap reactstrap @material-ui/core lodash

Testing

For any unit test file that deep renders ("mounts") this imported component, add the following:

jest.mock("tbc-common-confirmation-modal/dist/ConfirmationModalContainer", () => "div"); jest.mock("tbc-common-confirmation-modal/dist/ModalFooterContainer", () => "div");

FAQs

Package last updated on 23 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts