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

pcln-modal

v6.0.51

Published

React component for modal

Downloads

3,400

Readme

pcln-modal

React modal component

npm i pcln-modal
import Modal from 'pcln-modal'

Modal Component

import { Modal } from 'pcln-modal'
;<Modal
  ariaLabel='This is an example Modal' //sets the aria-label of the DialogContent
  isOpen={true} //boolean for control this status of modal
  onClose={someFunc} //func function for handle close the modal while click on the overlay
  bg='white' //modal background color
  zIndex={5} //zIndex
  imgMode={false} //default false, will add padding to the modal, if true, then there will be no padding
  width={['100px', '200px']} //responsive width the modal
  header={<SomeHeaderComponent />} //Component for header, could import predefined ones too
  disableCloseButton={true} //there will be a floating close button, when enabledOverflow = true, it's there by default
  enableOverflow={false} //when enabled, the modal will extend over the screen based on content, otherwise it will follow height
  height={['100px', '200px']} //responsive height, when enableOverflow={true}, it's not in use
  verticalAlignment='middle' // Aligns dialog body vertically - options = ['middle', 'top', 'bottom']
  overlayAnimation={null} // Accepts a function which overwrites default animation
  dialogAnimation={null} // Accepts a function which overwrites default animation
  timeout={500} // Accepts a number which overwrites the default delay for the open animation to begin, default is 500ms
>
  <SomeChildComponent />
</Modal>

Note: <Modal> relies on values from theme, so it must be a descendent of <ThemeProvider> in order to work properly. Otherwise, you might experience errors like this:

Uncaught TypeError: Cannot read property '3' of undefined

ScrollLock helper

This helper class will prevent background scroll when modal is open. However, there can be only one instance of this helper is working in a page since it messes with body style

import { ScrollLock } from 'pcln-modal'

class SomeWrapper extends React.component {
  constructor(props) {
    super(props)
    this.scrollLock = new ScrollLock()
  }

  openModalFunc() {
    this.scrollLock.on()
    this.setState({
      modalOpen: true,
    })
  }

  closeModalFunc() {
    this.scrollLock.off()
    this.setState({
      modalOpen: false,
    })
  }
}

Overwriting Animations

For its animations, this Modal currently uses react-transition-group. This means that the following hooks are exposed during the animation life cycle: [ entering, entered, exiting, exited]

We can then use these states to write custom animations, like so:

const MY_ANIMATION = (transitionState) => `
  transform: scale(0.5);
  transition: transform .5s cubic-bezier(0.50, 0.00, 0.25, 1.00);
  ${transitionState === 'entering' ? `transform: scale(0.5);` : ''}
  ${transitionState === 'entered' ? `transform: scale(1);` : ''}
  ${transitionState === 'exiting' ? `transform: scale(0.5);` : ''}
  ${transitionState === 'exited' ? `transform: scale(0.5);` : ''}
`