Socket
Book a DemoInstallSign in
Socket

tbc-panda-confirmation-modal

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tbc-panda-confirmation-modal

Common Modal for all Trinidad Benham Panda React apps

latest
npmnpm
Version
0.2.5
Version published
Weekly downloads
1
-88.89%
Maintainers
1
Weekly downloads
 
Created
Source

TBC Common React App Confirmation Modal

Common Modal for all Trinidad Benham Panda React apps

Install

npm install --save tbc-panda-confirmation-modal

Styles

As of version 0.2.0, to use the component included in this module, the following style file will need to be imported/included into the main App.scss:

@import "tbc-panda-confirmation-modal/dist/styles/modals.scss";

Modal Component:

In component where you wish modal to be activated:

import ConfirmationModal from "tbc-panda-confirmation-modal/dist/ConfirmationModal";

<ConfirmationModal {...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-prime"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-main",
        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 ModalFoot that can be used in any other modal. It uses the same buttons prop as above.

import ModalFoot from "tbc-panda-confirmation-modal/dist/ModalFoot";

<ModalFoot 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-panda-confirmation-modal/dist/ConfirmationModal", () => "div"); jest.mock("tbc-panda-confirmation-modal/dist/ModalFoot", () => "div");

Change Log

  • 0.2.5 Moved from ConfirmationModalContainer to ConfirmationModal, and ModalFootContainer to ModalFoot component names

FAQs

Package last updated on 01 Jul 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.