npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wil-react-modal

v1.5.2

Published

Modal Component For React

Downloads

9

Readme

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

| Prop | Type | Default | Description | | :--------- | :-------: | :-----: | :----------- | | displayName | string | - | Modal name | | placement | "center", "top", "right", "bottom", "left" | center | The position of the modal relative to the screen | | animationDuration | number | 300 | Modal animation duration ( milliseconds ) | | animationType | "none", "fade", "fadeUp", "fadeDown", "fadeLeft", "fadeRight", "slideUp", "slideDown", "slideLeft", "slideRight", "zoom" | none | animation for modal | | underlayEnabled | boolean | true | On / off modal underlay | | underlayColor | string | rgba(0, 0, 0, 0.5) | Set color for modal underlay | | fullScreen | boolean | false | Content width 100% height 100% | | scrollTarget | string | window | Toggle the scroll bar of the element. Example scrollTarget value: window, #root, ... | | scrollTargetEnabled | boolean | false | Allow toggle scroll bar | | openTimeout | boolean | false | Open modal timeout (second) | | autoCloseTimeout | boolean | false | Close modal timeout (second) | | children | React.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 | | isVisible | boolean | - | Set on / off modal. This attribute is needed when you want to open modal at the beginning without taking action | | modalContainerClassName | string | - | ClassName for Modal | | modalContainerStyle | Object | - | Style for Modal |

Methods

| Method | Params | Description | | :--------- | :-------: | :----------- | | open | displayName, { 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 ) | | close | displayName | Close modal with prop displayName Modal.close("displayName") |