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

@alaaessam/custom-popup

v1.0.1

Published

This project was bootstrapped with [Create React Library](https://github.com/dimimikadze/create-react-library).

Downloads

7

Readme

Custom PopUp

Wanna Easy PopUp Form Responsive for Creating and Updating your database, Voila you're in the right place.

Mob

Web

How it works ?

Installation

install the package

$ npm i @alaaessam/custom-popup

import the package to your desiered page

import PopUp from '@alaaessam/custom-popup';

In Order to make the component work we're gonna do a simple react hook State Mangement to display the form or not see the code below if you want to add a user to your users database

import PopUp from '@alaaessam/custom-popup';
export default function Users(){
    {< /* We will toggle newUser to Show/Hide the form*/>}
    const[newUser,toggleNewUser]=useState(false);
     return(
        <React.Fragment>
        {< /*action goes down here by default we want the form to be closed*/>}
            {
                newUser?<PopUp
                /*Here we will add the inputs,
                buttons and primaryStyle */
                />:null
            }
            {< /*a Button for adding a New User
            and toggling the Form state*/>}
            <button 
            onClick={()=>{toggleNewUser(!newUser);}
            >Add User</button>
            //Some other Components in your code
        </React.Fragment>
    );
}

now if you try the code above you will get a blank pop up so that means it's working.. let's dive in how to populate the form, it's pretty simple.

From the above example we need inputs for the following: username ,password ,email and permission all should be required you cant submit the form without filling them two button for submit and cancel

For the inputs we need an array of objects like this

const newUserInputs= [{
        title:"username",
        type: "text",
        required:true,
        props:{
            placeholder: "username",
        }
    },{
        title:"password",
        type: "password",
        required:true,
        props:{
            placeholder: "Password",
        }
    },{
        title:"email",
        type: "email",
        required:true,
        props:{
            placeholder: "E-mail address",
        }
    },]

and selectors for permissions

  const newUserSelectors=[{
        title:"permissions",
        options:[{value:'admin',label:"Admin"},{value:'secretery',label:"Secretery"}],
        props:{

        }
    }]

and two buttons with each button pass the required function

 const newUserButtons=[
        {
            name:"Submit",
            backgroundColor:"#ff4e50",
            action:(data)=>{handleNewUser(data)}
        }, 
        {
            name:"Cancel",
            backgroundColor:"#4a4a4a",
            action:()=>{toggleNewUser(!newUser)},
            exitButton:true
        }
    ]

the component should look like this and we are good to go

<PopUp 
    content={userInput}
    selectors={SelectorsUser}
    buttons={userButtons}
    primaryColor="#ff4e50"
/>

and for auto populate make sure dataValues are a JSON Object with same name of your input and selector

<PopUp 
    content={userInput}
    selectors={SelectorsUser}
    buttons={userButtons}
    dataValues={editUserDataValues}
    populateDataValues={true}
    primaryColor="#ff4e50"
/>

When Submitting the Form the function that's passed to the submit button will get params as a JSON Object holding all info about the form.

Waiting for you FeedBack for more fearures Web