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-relax-modal

v0.2.3

Published

A easy Modal system for Web React Apps

Downloads

3

Readme

react-relax-modal

A easy Modal system for Web React Apps

Table of Contents

Installation

To install, you can use npm or yarn:

$ npm install --save react-relax-modal
$ yarn add react-relax-modal

Examples

Here is a simple example of react-relax-modal being used in an app

import {RelaxModalProvider, useRelaxModal} from "react-relax-modal";

const modalStyle = {
  width: 200,
  height: 200,
  display: "flex",
  borderRadius: "5px",
  alignItems: "center",
  justifyContent: "center",
  backgroundColor: "white",
};

const MyModal = () => {
    return (
        <div style={modalStyle}>
            <span>Hello World!</span>
        </div>
    );
};

const Screen = () => {
    const {openModal} = useRelaxModal();
    return <button onClick={() => openModal(<MyModal />)}>Open My Modal</button>;
};

function App() {
    return (
        <RelaxModalProvider>
            <Screen />
        </RelaxModalProvider>
    );
}

export default App;

You can find examples in the examples directory, which you can run in a local development server using npm start or yarn run start.

RelaxModalProvider Props

RelaxModalProvider accepts props to set a global configuration and/or get a debug helper for your development process

function App() {
    return (
        <RelaxModalProvider {/**props */}>
            {...}
        </RelaxModalProvider>
    );
}

| Attributes | Type | Default | Description | | :------------------ | :------------------------- | :-------------- | :------------------------------------------------------------------------------------------------ | | debug | boolean | false | If debug is true you will see on console the stack of modals and the active one | | children | JSX.Element or JSX.Element[] | JSX.Element (required) | The components that you want to get access to the Relax Modal Provider API | | rootConfig | RelaxModalConfig | default Config | Set an initial configuration for all your Modals |

Modal Config

Each time that you call openModal to open a new modal component you can add configuration object that only will affect that Modal

<button onClick={() => openModal(<YourModalComponent />, {/**config */})}>
    Open Modal
</button>

| Attributes | Type | Default | Description | | :------------------ | :------------------------- | :-------------- | :--------------------------------------------------------------------------------------------------------------------------------------- | | alignment | Alignment | center | Set the screen location of your component that you are providing to the openModal() function | | backgroundColor | string | rgba(0,0,0, .6) | The background color | | closeOnBackdrop | boolean | true | Set if user can close the modal when click on the backdrop | | autoCloseMS | number or undefined | undefined | Set auto-close duration for your Modal | | style | CSSProperties or undefined | undefined | Set styling for Modal container | | closeKey | string or undefined | Escape | Set what keyboard key you want to use to close the Modal | | onClosed | function | undefined | Set a callback when user close the Modal | | onBackdrop | function | undefined | Set a callback when user clicks on the backdrop | | closeButton | CloseButton | {show: false, icon: undefined, style: undefined, defaultIconColor: "#fff"} | Personalize the Modal close Button | | animation | Animation | {initial: {transform: "translateY(4rem)", opacity: 0}, animate: {transform: "translateY(0)", opacity: 1}} | Set animation when Modal is open |