1.5.2 • Published 4 years ago

wil-react-modal v1.5.2

Weekly downloads
65
License
MIT
Repository
github
Last release
4 years ago

Wil React Modal

Modal Component For React

Installation

npm

npm install wil-react-modal --save

yarn

yarn add wil-react-modal

Example

1. Basic

2. Open Modal from other file and send payload

3. Animation

4. Placement

5. Fullscreen

6. Nested

7. Auto visible

8. Open modal and auto close modal after 5s

9. Router Modal

import React from "react";
import Modal from "wil-react-modal";

class App extends React.Component {
  render() {
    return (
      <div>
        <button
          onClick={() => {
            Modal.open("basic", {
              payload: { name: "Wil React Modal", author: "Wiloke" }
            })
          }}
        >Modal Basic</button>

        <Modal
          displayName="basic"
          animationType="zoom"
          onOpen={payload => {
            // payload: { name: "Wil React Modal", author: "Wiloke" }
            console.log(payload);
          }}
        >
          <div style={{ backgroundColor: "#fff", padding: 30 }}>
            <h2>Modal Basic</h2>
            <button onClick={() => Modal.close("basic")}>Close</button>
          </div>
        </Modal>
      </div>
    )
  }

API

PropTypeDefaultDescription
displayNamestring-Modal name
placement"center", "top", "right", "bottom", "left"centerThe position of the modal relative to the screen
animationDurationnumber300Modal animation duration ( milliseconds )
animationType"none", "fade", "fadeUp", "fadeDown", "fadeLeft", "fadeRight", "slideUp", "slideDown", "slideLeft", "slideRight", "zoom"noneanimation for modal
underlayEnabledbooleantrueOn / off modal underlay
underlayColorstringrgba(0, 0, 0, 0.5)Set color for modal underlay
fullScreenbooleanfalseContent width 100% height 100%
scrollTargetstringwindowToggle the scroll bar of the element. Example scrollTarget value: window, #root, ...
scrollTargetEnabledbooleanfalseAllow toggle scroll bar
openTimeoutbooleanfalseOpen modal timeout (second)
autoCloseTimeoutbooleanfalseClose modal timeout (second)
childrenReact.Node or (({ payload: any, countDown: number }) => React.Node)-ReactNode or Function return ReactNode (payload received from method open and countDown from prop autoCloseTimeout)
onOpen(payload: any) => void-Callback executed when modal open. Payload received from method open
onOpenEnd(payload: any) => void-Callback executed when modal open stop. Payload received from method open
onCloseEnd() => void-Callback executed when modal close
isVisibleboolean-Set on / off modal. This attribute is needed when you want to open modal at the beginning without taking action
modalContainerClassNamestring-ClassName for Modal
modalContainerStyleObject-Style for Modal

Methods

MethodParamsDescription
opendisplayName, { historyPushTitle, historyPushUrl, payload }Open modal with prop displayName. You can using historyPushTitle and historyPushUrl for Modal Router and send data with payload ( historyPushUrl could be http://localhost:3000/foo.html or /foo.html or foo.html. Example: Router Modal )
closedisplayNameClose modal with prop displayName Modal.close("displayName")
1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.8

4 years ago

1.4.7

4 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago