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

v1.0.5

Published

A react modal component

Downloads

19

Readme

react-modal-jkf

Un composant modal React

NPM JavaScript Style Guide

Installation

npm install --save react-modal-jkf

Utilisation

import React from 'react'
import { Modal, useModal } from 'react-modal-jkf'
import 'react-modal-jkf/dist/index.css'

function Example() {
  const { isShowing, toggle, openModal, closeModal } = useModal()

  return (
    <div>
      <button onClick={toggle}>Ouvrir la fenêtre modale</button>
      <Modal
        isShowing={isShowing}
        toggle={toggle}
        closeModal={closeModal}
        btnChildren={btnChildren}
        overlayClass='your-overlay-class'
        modalClass='your-modal-class'
        bodyClass='your-modal-body-class'
        btnClass='your-modal-btn-class'
      >
        Contenu de la fenêtre modale
      </Modal>
    </div>
  )
}

Modal

Modal est un composant React qui affiche une fenêtre modale.

Props

  • overlayClass : La classe CSS à appliquer à l'overlay de la fenêtre modale. Par défaut, c'est la classe .modalOverlay dans styles.module.css.
  • modalClass : La classe CSS à appliquer à la fenêtre modale. Par défaut, c'est la classe .modal dans styles.module.css.
  • btnClass : La classe CSS à appliquer au bouton de l'en-tête. Par défaut, c'est la classe .modalBtn dans styles.module.css.
  • bodyClass : La classe CSS à appliquer au corps de la fenêtre modale. Par défaut, c'est la classe .modalBody dans styles.module.css.

useModal

useModal est un hook personnalisé pour gérer l'état d'affichage d'une fenêtre modale.

Retour

  • isShowing : Un booléen indiquant si la fenêtre modale est actuellement affichée.
  • toggle : Une fonction qui permet de basculer l'affichage de la fenêtre modale.
  • openModal : Une fonction qui permet d'activer l'affichage la fenêtre modale.
  • closeModal : Une fonction qui permet de désactiver l'affichage de la fenêtre modale.

styles.module.css

Ce fichier contient les styles par défaut pour le composant Modal. Vous pouvez les surcharger en passant vos propres classes CSS (string) aux props correspondantes du composant Modal.

Classes par défaut CSS du fichier styles.module.css:

.modalOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10;
  box-sizing: border-box;
  background-color: rgba(0, 0, 0, 0.75);
}

.modal {
  position: relative;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  max-width: 500px;
  box-sizing: border-box;
  width: 90%;
  background: #fff;
  padding: 15px 30px;
  text-align: left;
  scrollbar-width: none;
  border-radius: 5px;
  max-height: 300px;
}
.modalBody {
  overflow-y: auto;
  max-height: 300px;
}

.modalBtn {
  position: absolute;
  top: -12.5px;
  right: -12.5px;
  display: block;
  width: 30px;
  height: 30px;
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAA3hJREFUaAXlm8+K00Acx7MiCIJH/yw+gA9g25O49SL4AO3Bp1jw5NvktC+wF88qevK4BU97EmzxUBCEolK/n5gp3W6TTJPfpNPNF37MNsl85/vN/DaTmU6PknC4K+pniqeKJ3k8UnkvDxXJzzy+q/yaxxeVHxW/FNHjgRSeK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
  background-position: center center;
  color: #fff;
  background-color: black;
  border: 1px solid #000;
  border-radius: 50%;
  font-size: 16px;
  padding: 10px;
}
.modalBtn:hover {
  cursor: pointer;
}

.modalBody::-webkit-scrollbar {
  display: none;
}

License

MIT © ThomasJSimpson