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

amv-modals

v1.0.1

Published

Modal management using reactJS

Downloads

1

Readme

amv-modals

A simple and customizable modal management library for ReactJS application.


Installation

npm i --save amv-modals or yarn add amv-modals

Docs

The library uses Javascript custom events, React Portals and hooks. You can take a look from here.

1. Instantiate the Modal Manager component

This library provides a component named ModalManager. This component is the responsible to get the existing DOM element, or create it in case it does not exist, from where the modals will be rendered.

| Prop | Type | Description | |----------|-------------|------| | portalId | String | The id of the DOM element to use as a root element of the modals | | backgroundColor | String | The background color of the modal backdrop | | zIndex | Number(1 by default) | Customize the z-order of the modals to overlap the rest of the elements.

2. Modal actions

You can create a modal through the modalEventEmitter provided object. It is a singleton that allows you to perform the following actions:

AddModal (creates a modal):

| Parameters | Type | Description | |----------|-------------|------| | id | String | Identifier of the modal | | content | React component | Instance of a React component that represents the modal itself | | settings | Object | Additional props used for the management of the modal. Actually it is supporting an onClose field which is a method called when user clicks on the modal background |

RemoveModal (removes an existing modal):

| Parameters | Type | Description | |----------|-------------|------| | id | String | Identifier of the modal |

UpdateModal (replaces an existing modal by the new one):

| Parameters | Type | Description | |----------|-------------|------| | id | String | Identifier of the modal | | content | React component | Instance of a React component that represents the modal itself | | settings | Object | Additional props used for the management of the modal. Actually it is supporting an onClose field which is a method called when user clicks on the modal background |

UpdateModalSettings (updates the settings of an existing modal):

| Parameters | Type | Description | |----------|-------------|------| | id | String | Identifier of the modal | | settings | Object | Additional props used for the management of the modal. Actually it is supporting an onClose field which is a method called when user clicks on the modal background |

Example:

import {
  ModalManager,
  modalEventEmitter,
} from 'amv-modals';
import CustomModal from '../components/custom-modal';

const Component = () => {
  useEffect(() => {
    modalEventEmitter.addModal('modal-1', <CustomModal />);
  }, []);

  return (<div>
    <p>This is an example</p>
    <ModalManager
      portalId="modal-portal"
      zIndex={10}
      backgroundColor="pink"
    />
  </div>);
};

Considerations

The library is smart enough to avoid closing the modal when the click event has been triggered from the modal but propagated to the modal wrapper that renders the background. But it is recommended that any click interation implemented in the modal includes the prevention of the propagation of the event.

CI/CD [WIP]

This project is configured using:

  • Semantic Release to automate the versioning of the package.
  • GitHub actions to perform the required steps (build and upload to repository) to publish the resulting package.
  • Npmjs as a repository where we can download all the versions of this library.