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

nested-modal

v2.0.1

Published

Manage nested modals

Downloads

8

Readme

nested-modal (React) · GitHub license PRs Welcome

⚡️ Code Sandbox Interactive Example ⚡️

Nested Modal is a component that helps manage lots of modals shown at the same time.

  • Easy to use: Very easy to create all the modals you need by just wrapping the content nodes with the Nested Modal wrapper.
  • Full Control: Abstracts only the main parts, you can fully control visiblity with ids and callbacks.

Installation

npm install nested-modal

Documentation

We are still working on some proper docs.

Examples

Main example:

  • Use a useState hook to control Visibility.
  • Each node added will be a modal.
  • Ids have to be unique.
import { NestedModal, ModalChild } from "nested-modal";

interface Props {
  currentOpenedModal: string;
  setCurrentOpenedModal: (modalId: string) => void;
}

export const NestedModalTest = ({
  currentOpenedModal,
  setCurrentOpenedModal
}: Props) => {
  return (
    <NestedModal
      currentOpenedModal={currentOpenedModal}
      setCurrentOpenedModal={setCurrentOpenedModal}
    >
      <ModalChild
        id="first-modal"
        title="Nice! This is the first modal in the row (and this is the title hihi)"
      >
        <button onClick={() => setCurrentOpenedModal("third-modal")}>
          Click here to launch the third modal
        </button>
      </ModalChild>
      <ModalChild
        id="second-modal"
        title="Second modal title hehe"
        onClose={async () => {
          if (
            window.confirm(
              "You won't be able to close the second one if you don't return true in the async callback. This is to prevent losing data such as form data. Confirm dialog if you want to close this modal."
            )
          ) {
            return true;
          }
          return false;
        }}
      >
        Now you are on the second modal. Try closing this one!
      </ModalChild>
      <ModalChild id="third-modal" title="Third modal title">
        The content of the third modal is here. If you hover on the left you
        will also see the second modal was opened because it was declared before
        the third one. Click on it to go there or close this one by hitting the
        back button.
      </ModalChild>
    </NestedModal>
  );
};

Contributing

I made this package just for fun. Anyone who would like to contribute is welcomed to open PR's or post suggestions/issues.

Development

In order to work on this package you need to follow these steps:

  1. Create a react project. e.g. with CRA
  2. In nested-modal create a link: npm link
  3. Go to your project and link nested-modal with your project: npm link nested-modal
  4. One last thing, you need to link your projects react copy in the nested-modal codebase: npm link ../path-to-my-cra-project/node_modules/react
  • Before opening a pr please undo the last step as it will break the packge release workflow. npm unlink ../path-to-my-cra-project/node_modules/react

Code of Conduct

We will be using Facebook code of conduct. Please read the full text so that you can understand what actions will and will not be tolerated.

License

Nested Modal is MIT licensed.