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

@florian_/react-simple-modal

v1.0.9

Published

<details> <summary>Table of Contents</summary> <ol> <li> <a href="#about-the-project">About The Project</a> <ul> <li><a href="#built-with">Built With</a></li> </ul> </li> <li> <a href="#getting-started">Gett

Downloads

20

Readme

React Simple Modal

About the project

This Modal component was initially created to meet a specific need in a personal project. However, aware of the value of component reusability, I designed it with the intention of making it adaptable and easily integrated into other projects.

Built with

React 18 Tailwind CSS Vite.js

Getting Started

Prerequisites

You need a package manager and React 17 or later.

  • npm

    npm install npm@latest -g
  • pnpm

    npm install -g pnpm

    Please refer to this documentation for more information.

Installation

npm

npm i @florian_/react-simple-modal

pnpm

pnpm add @florian_/react-simple-modal

Usage / Examples

The Modal component simply needs a state to indicate whether the modal window should be displayed or not, and a function to manage its closure.

import {
	Modal,
	ModalContent,
	ModalHeader,
	ModalTitle,
	ModalDescription,
	ModalClose,
	ModalFooter,
} from "@florian_/react-simple-modal";

function App() {
	const [isOpen, setIsOpen] = useState(false);

	const handleModal = () => setIsOpen(!isOpen);

	return (
		<>
			<button onClick={handleModal}>open</button>

			<Modal open={isOpen} onClose={handleModal}>
				<ModalContent>
					<ModalHeader>
						<ModalTitle>Login</ModalTitle>
						<ModalDescription>
							Lorem ipsum dolor sit amet consectetur adipisicing
							elit.
						</ModalDescription>
					</ModalHeader>

					<p>
						Lorem ipsum dolor sit amet consectetur, adipisicing
						elit. Quaerat explicabo dolor repellendus sed esse
						voluptatum velit. Voluptate at veniam corrupti nihil a
						aliquam omnis magnam, vitae aut expedita, earum illo!
					</p>

					<ModalFooter>
						<ModalClose>Close</ModalClose>
					</ModalFooter>
				</ModalContent>
			</Modal>
		</>
	);
}

export default App;

Props

| Name | Required | Default | Type | Example | | ------------ | -------- | --------- | --------------------------------- | ---------------------- | | open | yes | - | boolean | Click | | onClose | yes | - | function => void | Click | | onOpenChange | no | undefined | function(isOpen: boolean) => void | Click | | onCreate | no | undefined | function => void | Click | | autoFocus | no | true | boolean | Click | | restoreFocus | no | true | boolean | Click | | className | no | undefined | string | |

Props Examples

open

open the controlled open state of the dialog.

<Modal open={true}>...</Modal>

autoFocus

autoFocus focus the first focusable element in the modal.

<Modal open autoFocus>
	...
</Modal>

restoreFocus

restoreFocus restores focus on base element after closing modal.

<Modal open restoreFocus>
	...
</Modal>

onOpenChange

onOpenChange trigger when the open state of the dialog changes.

<Modal onOpenChange={(isOpen) => console.log(isOpen))}>...</Modal>

onClose

onClose triggers when the modal window closes.

<Modal onClose={() => console.log("onClose")}>...</Modal>

onCreate

onCreate trigger when component is create.

<Modal onCreate={() => console.log("onCreate")}>...</Modal>