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

custom-modal-react-component

v1.0.1

Published

React component which allows to display a customizable modal with different themes and parameters.

Downloads

133

Readme

Custom Modal React Component

React component which allows to display a customizable modal with different themes and parameters.

Table of content

Installation

npm install custom-modal-react-component

Version

This package is in version 1.0.1

Technologies

  • JavaScript
  • SASS: 1.80.5
  • React: 18.3.1
  • React DOM: 18.3.1
  • Node: 18.16.1

Usage

import React, { useRef } from "react"
import Modal from "custom-modal-react-component"
import "custom-modal-react-component/dist/styles/modal-component.css"
import closeIcon from "custom-modal-react-component/dist/icons/close.svg" /* You can change the closeIcon path if it is different */

function App() {
	const modalRef = useRef() 

	/* Call modalRef.current.open() when you want the modal to open, for example after a form submission.
	   Only "if(modalRef.current)" and its content are mandatory, you can adapt this example for your own needs.
	*/
	const handleSubmit = (e) => {
		e.preventDefault()
		if (modalRef.current) {
			modalRef.current.open()
		}
	}

	return (
		<>
			{/* Only the <Modal /> component with its required props is mandatory here, you can adapt this example for your own needs. */}
			<Modal ref={modalRef} icon={Your icon path} title="Your title" message="Your message" theme="light" closeIconPath={closeIcon} />
			<form onSubmit={handleSubmit}>
			<label htmlFor="Field">Field</label>
				<input type="text" />
				<button>Submit</button>
			</form>	
		</>
	)
}

Props

Modal preview

A background is added behind the modal, preventing to interact with the back of the page.

Modal preview

Global settings

The modal is designed with a maximum height and width of 75% of its container.

A scrollbar appears if the content exceeds the modal height.

Customization

To apply default styles, import the component's CSS:

import "custom-modal-react-component/dist/styles/modal-component.css"

Several preset themes are available, go to the next section to check.

Available Classes for Custom Styling

  • .modal : Style the modal container (e.g., background, border)
  • .modal-title : Style the title text
  • .modal-message : Style the message content

Themes

Choose from multiple themes by setting the theme prop with one of the theme names below.

How to use it with the candy theme, for example :

<Modal ref={modalRef} title="Your title" message="Your message" theme="candy" closeIconPath={closeIcon} />

Light theme

Modal with light theme

Dark theme

Modal with dark theme

Minimal theme

Modal with minimal theme

Mystic theme

Modal with mystic theme

Candy theme

Modal with candy theme

Organic theme

Modal with organic theme

Coffee theme

Modal with coffee theme

Tech theme

Modal with tech theme

Urban theme

Modal with urban theme

Success theme

Modal with success theme

Warning theme

Modal with warning theme

Information theme

Modal with information theme

Contribution

This project was conducted as part of a training course and is not open to external contributions at this time.

Author

Mégane Navarro ([email protected])

Changelog

[1.0.1] - 2024-11-15

  • First stable version
  • Adding a declaration file
  • Documentation improvement

[0.0.0] - 2024-11-10

  • First Beta Version

Licensing

This project was built under the ISC licence.