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

@redq/reuse-modal

v2.0.0

Published

reuse-modal

Downloads

1,433

Readme

reuse-modal

SSR Friendly Draggable React Modal With react-rnd And react-spring Support.

Demo:

url: https://tarex.github.io/reuse-modal/

Prerequisite

"react": "17.0.1",
"react-dom": "17.0.1"

Installation

  1. yarn add react@next react-dom@next
  2. yarn add @redq/reuse-modal
  3. import { Modal, openModal, closeModal } from '@redq/reuse-modal';
  4. To trigger modal, use openModal and closeModal and use <Modal /> in you app in root level or in the parent component.
  5. pass modal configuration through openModal(config) like below.
  6. yarn start

Sample Config

{
  config: {
    className: 'customModal',
    disableDragging: false,
    enableResizing: {
      bottom: true,
      bottomLeft: true,
      bottomRight: true,
      left: true,
      right: true,
      top: true,
      topLeft: true,
      topRight: true,
    },
  },
  withRnd: false,
  overlayClassName: 'customeOverlayClass',
  closeOnClickOutside: true,
  component: BigModalComponent,
  componentProps: { customData: 'your custom props' },
  closeComponent: CloseComponent,
}

API Details

  • className: Modal Wrapper class name, default value customModal [type: string]
  • overlayClassName: Modal overlay class name, default value '' [type: string]
  • closeOnClickOutside: Enable/Disable click outside modal close [type: boolean]
  • withRnd: Enable/Disable React Rnd support. By default we added react spring for animation and if you needed dragging feature then simply use withRnd: true [type: boolean]
  • component: The component you want to render inside the Modal [type: component]
  • componentProps: pass the props you need in the Modal component [type: object]
  • closeComponent: Close component to close the Modal [type: Component]
  • config: Modal can be draggable and resizeble as we have provided support with react-rnd
  • config: to customize react spring config pass your props within the config parameter as shown in the Sample config section react-spring

Usage

import React, { Component, Fragment } from 'react';
import { render } from 'react-dom';
import { Modal, openModal, closeModal } from '@redq/reuse-modal';
import '@redq/reuse-modal/lib/index.css';

const CloseComponent = () => {
  return <button onClick={() => closeModal()}>close </button>;
};

const BigModalComponent = props => (
  <Fragment>
    <h1>Modal </h1>
    <p>{props.customData}</p>
  </Fragment>
);

const Basic = () => {
  return (
    <div>
      <button
        onClick={() =>
          openModal({
            config: {
              className: 'customModal',
              disableDragging: false,
              enableResizing: {
                bottom: true,
                bottomLeft: true,
                bottomRight: true,
                left: true,
                right: true,
                top: true,
                topLeft: true,
                topRight: true,
              },
              width: 480,
              height: 650,
              animationFrom: { transform: 'scale(0.3)' }, // react-spring <Spring from={}> props value
              animationTo: { transform: 'scale(1)' }, //  react-spring <Spring to={}> props value
              transition: {
                mass: 1,
                tension: 130,
                friction: 26,
              }, // react-spring config props
            },
            withRnd: false,
            overlayClassName: 'customeOverlayClass',
            closeOnClickOutside: false,
            component: BigModalComponent,
            componentProps: { customData: 'your custom props' },
          })
        }
      >
        Open Modal
      </button>
    </div>
  );
};

class Demo extends Component {
  render() {
    return (
      <div>
        <h1>reuse-modal Demo</h1>
        <Basic />
        <Modal />
      </div>
    );
  }
}

render(<Demo />, document.querySelector('#demo'));

Development.

  • npm i -g nwb
  • Check package.json command

Deployment

  1. To clean the project run yarn clean
  2. Publish to npm : npm publish --access public
  3. Host into github: npm run deploy