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

@goodhood/modals

v3.0.0

Published

Modal components

Downloads

798

Readme

@goodhood/modals

React modal components

Install

npm i @goodhood/modals

Install peer dependencies

npm i react // v16.x.x
npm i prop-types // v15.x.x
npm i @babel/runtime // v7.x.x
npm i @goodhood/components // >= v6.x.x
npm i nebenan-ui-kit // >= v5.x.x
npm i nebenan-helpers // >= v5.x.x

Configurate module

import { configure } from '@goodhood/modals';

configure({
  track: // track function which will be called on modal open and close event
});

Import:

import Modal, { Alert, configure } from '@goodhood/modals';

API

Modal

import { ModalProvider } from '@goodhood/modals';

const App = () => (
  /* Imperative API:
  - setModal(modalComponent): support legacy API for showing modals via function call
  - lock(): locks window scroll
  - unlock(): unlocks window scroll */
  <ModalProvider ref={ref}>
    {/* All modals should be placed inside modal provider */}
  </ModalProvider>
);

Modal

import { ModalProvider, Modal } from '@goodhood/modals';

const App = () => {
  const [isActive, setAcive] = useState();

  return (
    <ModalProvider>
      <span onClick={() => setAcive(true)}>Open modal</span>

      {isActive && (
        <Modal
          {/* Overlay class attribute */}
          className="string"

          {/* Content class attribute */}
          bodyClassName=""

          {/* Prevent modal from closing */}
          persist={true/false}

          {/* Stick modal to the top */}
          staticPosition={true/false}

          {/* Handler to close modal */}
          onClose={() => setAcive(false)}

          {/* Called on unmount */}
          onUnmount={() => {}}
        >
          {/* Modal content */}
        </Modal>
      )}
    </ModalProvider>
  );
};

Alert

import { ModalProvider, Alert } from '@goodhood/modals';

const App = () => (
  <ModalProvider>
    <Alert
      {/* Inherits props from <Modal /> */}

      {/* Title in the header */}
      title="string"

      {/* Content, supports markdown syntax */}
      content="string"

      {/* Text for close link in the footer */}
      closeLabel="string"
    >
      {/* Alert content */}
    </Alert>
  </ModalProvider>
);

Confirm

import { ModalProvider, Confirm } from '@goodhood/modals';

const App = () => (
  <ModalProvider>
    <Confirm
      {/* Inherits props from <Modal /> */}

      {/* Title in the header */}
      title="string"

      {/* Content, supports markdown syntax */}
      content="string"

      {/* Text for decline button */}
      cancelLabel="string"

      {/* Text for confirm button */}
      confirmLabel="string"

      {/* Lock buttons */}
      locked={true/false}

      {/* Invert buttons */}
      inverted={true/false}

      {/* Called on decline, DO NOT CONFUSE WITH onClose */}
      onCancel={() => {}}

      {/* Called on confirm */}
      onConfirm={() => {}}
    >
      {/* Confirm content */}
    </Confirm>
  </ModalProvider>
);

IllustrationModal

import { ModalProvider, IllustrationModal } from '@goodhood/modals';

const App = () => (
  <ModalProvider>
    <IllustrationModal
      {/* Inherits props from <Modal /> */}

      {/* Title in the header */}
      title="string"

      {/* Content, supports markdown syntax */}
      content="string"

      {/* Text for close link in the footer */}
      closeLabel="string"

      {/* Image url */}
      image="https://images.com/image.jpg"

      {/* Button node in the footer */}
      button={<button>Hello</button>}
    >
      {/* IllustrationModal content */}
    </IllustrationModal>
  </ModalProvider>
);

ScrollableModal

import { ModalProvider, ScrollableModal } from '@goodhood/modals';

const App = () => (
  <ModalProvider>
    <ScrollableModal
      {/* Inherits props from <Modal /> */}

      {/* Header node */}
      header={<header class="ui-card-section">Title</header>}

      {/* Footer node */}
      footer={<footer class="ui-card-section">Footer</footer>}
    >
      {/* ScrollableModal content */}
    </ScrollableModal>
  </ModalProvider>
);

Development

Preview

  • yarn start
  • Visit http://localhost:3000

Add a new component

  • Create src/*/index.jsx
    • Default exports will be re-exported with the map name
    • Named exports will be re-exported as they are (watch out for collisions)
        // src/map/index.jsx
        export const ModalType = 123;
        export Modal 666;
      
        // usage
        import { Modal, ModalType } from '@goodhood/modals';
  • Create src/*/index.stories.jsx
    • Preview will take it up automatically