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

npm-react-popup-info-modal

v0.2.6

Published

An user-friendly, lightweight and customisable pop up which display your message in a modal

Downloads

2

Readme

Modal - React Component

GitHub repo size

General information

An user-friendly, lightweight and customizable pop up which display your message in a modal

Install & Setup

Step 1 (required) :

To install, you can use npm or yarn:

$ npm install --save info-modal-component
$ yarn add info-modal-component

Step 2 (required) :

To import the component, add :

import { InfoModal } from 'info-modal-component'

Step 3 (required) :

To setup the component's state, add :

const [isModalOpen, setIsModalOpen] = useState(false)

Step 4 (required) :

To use the component's state, pass it as prop :

<InfoModal setIsModalOpen={setIsModalOpen} />

Step 5 (optional):

To custom the composant (...or not), take a look below and add what you need with props :

<InfoModal
  setIsModalOpen={setIsModalOpen}
  // Customization //
  TitleTextAlign={'center'}
  InformationTextAlign={'center'}
/>

Usage

You can use it like a simple React component in your React project

import { InfoModal } from 'info-modal-component'

const [isModalOpen, setIsModalOpen] = useState(false)

{
  isModalOpen ? (
    <InfoModal
      setIsModalOpen={setIsModalOpen}
      // Set your Props here to custom the component //
    />
  ) : null
}

Props

| Props | Type | Description | | :--------------------- | :------- | :-------------------------------------------------------------------------- | | title | string | title of your modal (i.e 'Hello world') | | information | string | message of your modal (i.e 'Welcome') | | modalBg | string | colour value of your modal's background (i.e '#ffffff') | | TitleTextAlign | string | position of your text (i.e 'left', 'center' or 'right') | | TitleTextColor | string | colour value of your modal's title (i.e '#0000FF') | | InformationTextAlign | string | position of your text (i.e 'left', 'center' or 'right') | | InformationTextColor | string | colour value of your modal's message (i.e ' #0000FF') | | ValidationBtnBgColor | string | colour value of your modal's validation button background (i.e '#ffffff') | | ValidationBtnColor | string | colour value of your modal's validation button (i.e ' #0000FF') |

Exemple

import React from 'react'
import { useState } from 'react'
import { InfoModal } from 'info-modal-component'

function App() {
  const [isModalOpen, setIsModalOpen] = useState(false)

  const handleOpenModalClick = () => {
    setIsModalOpen(true)
  }

  return (
    <main
      style={{
        width: '100vw',
        height: '100vh',
        position: 'absolute',
        zIndex: '5',
        top: '50%',
        left: '50%',
        background: 'rgba(0, 0, 0, 0.2)',
        transform: 'translate(-50%, -50%)',
      }}
    >
      <button
        style={{
          width: 200,
          height: 100,
          padding: 5,
          position: 'fixed',
          top: '50%',
          left: '50%',
          transform: 'translate(-50%, -50%)',
          borderRadius: 25,
          fontSize: 20,
          background: 'rgba(255, 246, 235, 1)',
        }}
        onClick={() => {
          handleOpenModalClick()
        }}
      >
        Open Modal
      </button>
      {isModalOpen ? (
        <InfoModal
          setIsModalOpen={setIsModalOpen}
          /// Props ///
          title={'Hello World'}
          information={'Welcome !!!'}
          modalBg={
            'radial-gradient(circle, rgba(255, 246, 235, 1) 0%, rgba(255, 228, 196, 1) 70%)'
          }
          TitleTextAlign={'center'}
          TitleTextColor={'#00bc77'}
          InformationTextAlign={'center'}
          InformationTextColor={'#257b5a'}
          ValidationBtnBgColor={'transparent'}
          ValidationBtnColor={'#257b5a'}
        />
      ) : null}
    </main>
  )
}

export default App

Screenshot

Custom

Default

License

License MIT