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

react-modal-component-eli-ca

v1.1.1

Published

A simple and accessible React modal component.

Downloads

4

Readme

React Modal Component

A simple and accessible React modal component.

Installation

You can install the package using npm or yarn:

npm install react-modal-component-eli-ca

# or via yarn:
yarn add react-modal-component-eli-ca

Usage:

import React, { useState } from 'react';
import Modal from 'react-modal-component-eli-ca'; 

const CreateEmployee = () => {
    const [isModalOpen, setIsModalOpen] = useState(false);

    const saveEmployee = () => {
        // Logic to save employee data (e.g., localStorage)
        setIsModalOpen(true);  // Open the modal after saving
    };

    const closeModal = () => {
        setIsModalOpen(false);  // Close the modal when needed
    };

    return (
        <div className="container">
            <h2>Create Employee</h2>
            <form>
                {/* Simplified form fields */}
                <label htmlFor="firstName">First Name</label>
                <input type="text" id="firstName" />

                <label htmlFor="lastName">Last Name</label>
                <input type="text" id="lastName" />

                <button type="button" onClick={saveEmployee}>Save</button>
            </form>

            {/* Modal */}
            <Modal isOpen={isModalOpen} onClose={closeModal}>
                <h2>Employee Created</h2>
                <p>The new employee has been successfully created.</p>
            </Modal>
        </div>
    );
};

export default CreateEmployee;

Props
isOpen (boolean): Controls whether the modal is open or closed. Required.
onClose (function): Function to call when the modal needs to be closed. Triggered when the user clicks the overlay or the close button. Required.
children (node): The content to be displayed inside the modal. Required.

Styles:

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    position: relative;
    max-width: 500px;
    width: 100%;
}

.modal-close {
    position: absolute;
    top: -30px;
    right: -15px;
    background: black;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.modal-close:hover {
    background: #444;
}
License
This project is licensed under the MIT License. See the LICENSE file for details.