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

easy-peasy-modal-react

v1.0.6

Published

Enhance your React application with a customizable modal component for seamless display of interactive content. Easy to integrate and highly configurable, our component provides a user-friendly experience with advanced customization options.

Downloads

7

Readme

easy-peasy-modal-react

Description

Enhance your React application with a customizable modal component for seamless display of interactive content. Easy to integrate and highly configurable, our component provides a user-friendly experience with advanced customization options.

Installation

npm install easy-peasy-modal-react

Usage

  1. Use the Modal component in your React component:
import Modal from 'easy-peasy-modal-react'

const YourComponentModal({isModalOpen, setIsModalOpen}) {
  const closeModal = () => {
    setIsModalOpen(false)
  }

  const content = <theContentYouWantInTheModal />

  return (
    <Modal isOpen={isModalOpen} onClose={closeModal} >
      {content}
    </Modal>
  )
}
  1. Declare a useState in the file where you want your modal to appear and trigger an event to make it appear. In this example, I'm using a button:
const [isModalOpen, setIsModalOpen] = useState(false)

<button onClick={() => setIsModalOpen(true)}>
  Press me
</button>

{isModalOpen && (
    <YourComponentModal
      isModalOpen={isModalOpen}
      setIsModalOpen={setIsModalOpen}
    />
  )}

Styling

Now, let's have some fun and stylize everything!

[!NOTE]

The Modal component comes with easy styling options. You can customize three objects: background,container, and closeButton.

  1. To apply styling, declare an object with the name of your choice:
const styledModal = {
	className: {
		background: 'modal-section',
		container: ['content', 'content--form-body'],
	},
}


const MyModal = {
	styledComponent: {
		background: {
			'background-color': 'rgba(0, 0, 0, 0.75)',
		},
		closeButton: {
			'background-color': 'transparent',
			'box-shadow': 'none',
		},
		container: {
			width: '65vw',
			height: '85vh',
			'max-height': '900px',
			padding: '20px',
			overflow: 'hidden',
			'border-radius': '25px',
		},
	},
}

[!IMPORTANT]

The key of your styling object must be either styledComponent or className.

className

If you prefer using classes for styling, use className and add a string for the class name. You can even use an array to add more classes for a single element.

styledComponent

If you enjoy using styled-components, you can easily integrate it:

const MyStyledModal = {
  styledComponent: {
    background: {
      'background-color': 'rgba(0, 0, 0, 0.75)';
    },
    container: {
      width: '500px';
      height: '200px';
      'max-height': '900px';
      padding: '20px';
      overflow: hidden;
      'border-radius': 2'5px';
    },
  },
};

Props

Props

  • isOpen (required): A boolean indicating if the modal is open or not
  • onClose (required): The function that will close the modal
  • children (required): The components that will appear in the modal
  • style: The styling object for the modal
  • closingButton: A boolean (default: true) to indicate whether the default closing button should be displayed. Set it to false if you want to use your own custom closing button.

Example

Discover usage examples for easy-peasy-modal-react in the provided example files, accessible in the library's GitHub directory. GitHub easy-peasy-modal-react Examples