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

@josephine-dujardin/hrnet_modal

v1.0.9

Published

## Description The modal dialog created with React component, to confirm when new employee records are created.

Downloads

22

Readme

Modal Component for HRnet Application

Description

The modal dialog created with React component, to confirm when new employee records are created.

Prerequisites:

Installation

  • Install the package: $ npm i @josephine-dujardin/hrnet_modal

Usage

This component is designed for use within a React application (it comes from the [HRnet application] (https://github.com/josephine-dujardin/hrnet)). You can use it in your own application and add functions and styling for further customization.

Components

Modal

A component that represents a simple modal window.

import React from 'react';

/**
 * A modal component for creating an employee profile.
 *
 * @param {Object} props - The component's props.
 * @param {boolean} props.isOpen - Indicates whether the modal is open or closed.
 * @param {function} props.openClose - A callback function to toggle the modal's open/close state.
 * @param {string} props.content - The content to display within the modal.
 *
 * @returns {JSX.Element} - The rendered modal component.
 */
function Modal({ isOpen, openClose, content }) {

    /**
     * Opens the modal.
     *
     * @function
     * @returns {void}
     */
    const toggleModal = () => {
        openClose();
    };

    return (
        React.createElement('div', { className: 'modal-container' },
            isOpen && (
                React.createElement('div', { className: 'modal' },
                    React.createElement('div', { className: 'modal-content' },
                        React.createElement('span', { className: 'close', onClick: toggleModal }, '\u00D7'), // \u00D7' represents the '×' character
                        React.createElement('p', { className: 'modal-text' }, content)
                    )
                )
            )
        ));
}

export default Modal;

Usage

Import the Modal component on your project

import { Modal } from '@josephine-dujardin/hrnet_modal';

You can then use it within your project, as in the following example:

import React, { useState } from 'react';
import { Modal } from '@josephine-dujardin/hrnet_modal';

function Home() {
    const [openModal, setOpenModal] = useState(false);

    const handleModalClose = () => {
        setOpenModal(false);
    };

    return (
        <div className="container">
            <h2 className="home-title">Create Employee</h2>
            <form action="#" id="create-employee">
                <label htmlFor="first-name">First Name</label>
                <input
                    id="first-name"
                    type="text"
                />

                <label htmlFor="last-name">Last Name</label>
                <input
                    id="last-name"
                    type="text"
                />

                <button
                    className="modal-btn"
                    type="button"
                    onClick={() => setOpenModal(true)}
                >
                    Save
                </button>
            </form>

            {/* Modal component */}
            <Modal
                isOpen={openModal}
                openClose={handleModalClose}
                content={"Employee created"}
            />
        </div>
    );
}

export default Home;