Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-chained-modals

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-chained-modals

You can create one popup or few chained modals using this plugin

  • 1.0.10
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
18
increased by80%
Maintainers
1
Weekly downloads
 
Created
Source

React chained modals Tweet

React version

Allow you to add few chained modals or just single popup in your react app. Easy to use and customizing. Check the demo page

screencast-amodin github io-2018 12 09-21-00-37

Getting Started

Installation

Get the package from npm

npm i react-chained-modals

Usage

Import:

import ChainedModal from "react-chained-modals";
import "react-chained-modals/src/modal.css"
import "animate.css"

then place:

<ChainedModal
  animationNext="fadeInRight"
  animationPrev="fadeInLeft"
  visible={this.state.showModal}
  onRequestClose={this.toggleModal}
  closeOnBackground
  animationSpeed="faster"
  elements={[
   {
     component: Modal1,
     props: { title: "First modal" }
   },
   {
     component: Modal2,
     props: { title: "Second modal" }
   },
   {
     component: Modal3,
     props: { title: "Third modal" }
   }
 ]}
/>

Methods and options

NameTypeDescriptionDefault
animationNextstringTransition animation on showNext method call. View full list here Animate.css. This method will call also on popup first view.none
animationPrevstringTransition animation on showPrev method call. View full list here Animate.cssnone
visibleboolIs modals visible. Options: true, falsefalse
onRequestClosefunctionMethod that should set visible to false
closeOnBackgroundboolShould popup close on click at background. Options: true, falsefalse
animationSpeedstringDefine it if you want to change the animation speed. Options: "slow", "slower", "fast", "faster"none
elementsarrayEach item in the array should have the component that will show and optional parameter props which put all 'props' you want to use in this componentnone

Methods and options for each modal

In each component, that you added in elements you can get next next properties and methods from props:

NameTypeDescription
closeChainedModalfunctionThe onRequestClose function will be called
totalModalsnumberNumber of modals, length of array
showNextfunctionShow next modal function
showPrevfunctionShow prev modal function
currentModalnumberCurrent modal, index in array

Example of Modal1 component:

const Modal1 = props => {
  return (
    <div>
      {props.title} {props.currentModal}
      <div>{props.totalModals}</div>
      <div>
        <span onClick={props.showPrev()}>Go prev </span>
        <span onClick={props.showNext()}>Go next</span>
      </div>
      <button onClick={() => props.closeChainedModal()}>close modal</button>
    </div>
  );
};

Customizing:

Just replace your styles with styles from the module

Built With

  • Animate.css - Animations for transition between modals
  • React portals - Used for display modal
  • Classnames - For combining few classNames

Keywords

FAQs

Package last updated on 09 Dec 2018

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc