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-tuv39

v1.1.7

Published

React modal component with customisable elements as title, description, button, fadeIn and fadeOut, and some more

Downloads

60

Readme

Getting Started with react-modal-tuv39

It's a customisable modal with different props.

This modal is an element displayed on top of the main content in the purpose of displaying additional information in reaction to previous action (button click, form submission validation,...)

You can customise content and style, including the title, description text, button text, button color, and duration of fadeIn/fadeOut animation. It also deals with links and could display some information from ID anchors, external links or data from an API. You can refer to the documention below to understand how to use the props.

This module was bootstrapped with Create React App.

Prerequisites

  • Node
  • Npm

remarkable dependencies

  • React in a badge
  • PropTypes in a badge

use of :

  • html
  • css
  • JS
  •  VS in a badge

Installation

npm install react-modal-tuv39

Importing

import { Modal } from 'react-modal-tuv39'

Usage

The react-modal-tuv39 component was originally created to replace a jquery modal in a global react project.

A modal is ran when an action is done

First example of usage:

The modal need a local state to be fired, this local state is boolean which open/close modal.

import React from 'react';
import { Modal } from 'react-modal-tuv39';

const test = () =>{
  const [appear, setAppear] = useState(false);

  return (
    <div>
      <button onclick={()=>{setAppear(true)}}>
      <Modal
        showModal={appear}
        onClose={()=>setAppear(false)}
        title="Here is a title"
        backDropClickAndClose
        closeAllModalsBefore
        fadeIn
        animationDuration="1"
        fadeOut
        closureButton="I'm closing"
        customButtonColor="orange"
      >{"Here is some description text that your modal displays"}</Modal>
    </div>
  )
}

Second example of usage: case of link button, to get and provide href attribute to component through props.

The datahref props expect a "event.target" that provide an object as bellow: eg : some text

const try =()=>{
    const [appear, setAppear] = useState(false)
    const [dataToGive, setDataToGive] = useState(null);
    return (
      <>
  <a
          href="https://www.npmjs.com/package/react-modal-tuv39"
          onClick={(event) => {
            setDataToGive(event.target);
            setAppear(true);
          }}
        />
        <Modal
        showModal={montre4}
        onClose={()=>setAppear(false)}
        dataHref={dataToGive}
        >
        Here is the link clicked:
        </Modal>
        </>
        )}

More?

Breakpoint

There is a breakpoint that change the modal display, in higher 600px screen width, the modal will fit to his content to adjust width. In lower case, the modal width is settle as '90vw'

Documentation

Here are modal component props. Some of those props are required (*). Some of those props work together for an action. (eg: fadeIn + animationDuration)

Props

| Name | Type | Default | Example | Description | | -------|------|------|------|------| | showModal * | bool | | true/false | If true, the component is shown.| | onClose * | func | | {()=>setAppear(false)} | Callback fired when the component requests to be closed. A local state could be used to open and close modal (eg: usage).| | title | string | | "Here is a title" | If added, the component displays a title in h3.| | children | string / number / element | | {"Here is some description text"} | If added, the component displays some description text.| | closureButton | string | element | "I'm closing" | If added, the component displays a basic blue button with this text inside. If not, then the component has a default blue crossed button | | backDropClickAndClose | bool | false | true/false | If true, the component can be closed with a backdrop click | | closeAllModalsBefore | bool | false | true/false | If true, the component closes all previous opened modals. | | fadeIn | bool | false | true/false |If true, the component adds a fadeIn animation on modal displaying. This animation has a default duration of 2sec that can be changed with animationDuration props| | animationDuration | string | 2 sec | "5" | This value should be a number in a string type. It will be the duration of the modal fade-in animation and fade-out in seconds.| | fadeOut | bool | false | true/false |If true, the component adds a fadeOut animation on modal closing. This animation has a default duration of 2sec that can be changed with animationDuration props| | customButtonColor | string | #1976d2 (blue hue) | "orange" | Controls colored part: the color of the close button and spinner. If added, the component changed his default color in the one chosen, can be in hexadecimal format, HSL and HSLA format, RGB and RGBA format and name format.| | dataHref | object | | "event.target" through a local state | To deal with link through , the component need to have the object 'event.target' from event which active the modal display. For instance, if the event is a click on a, then dataHref should be the 'event.target' from onClick action | | ajaxData | string | 'data.id' | "data.name" | If dataHref is an API, ajaxData is necessary to display some text or data from the API, It's the name of the data to be fetched from the URL. Note that it should began with "data.", as "data.city", or "data.phoneNumber". | | dataHrefIsAnAPI | bool | false | true/false | Boolean that determines if the extern link clicked is an API and allow to handle specifically the data displayed |

CSS

It is possible to customise some more of the style with the reference bellow: | Tag name |class name | Description | |-------|-------|-------| | root | :root (not a class) | styles applied to the root element, contained color variable. | | | .tUv39-modal-blocker-div | Styles applied to the back drop modal.| | | .tUv39-modal-container | Styles applied to modal container. | | | .tUv39-modalclose-h3 | Styles applied to modal title. | | | .tUv39-modalclose-p | Styles applied to modal parapgraph. | | | .tUv39-modalclose-button | Styles applied to modal button. | | | .tUv39-modalclose-button-default | Styles applied to modal default button. | | | .tUv39-modal-fadeIn | animation styles, when class called, animated the element (in this component, applied on .tUv39-modal-blocker-div ) | | | .tUv39-modal-fadeOu | Styles applied to modal button. |

Author

author