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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-overlay-controller

v0.1.2

Published

Singleton react component that manages presentation of overlays.

Readme

React Overlay Controller

React singleton component that manages presentation of overlays. An overlay is a customizable lightbox with any react component. The component might be a loading indicator, a modal dialog, an error popup, etc. The Overlay Controller can present several overlays on top of each other as a stack. Then, stacked overlays can be dismissed in the reverse order of their presentation.

Setting Up

The OverlayController should be placed close to the top of your component hierarchy. Most important, it should not have any ancestor elements with css transform applied. Otherwise, it will not cover the entire screen.

import React from 'react';
import OverlayController from 'react-overlay-controller';

class App extends React.Component {

    render() {
        return (
            <div>
                <div>... app content ...</div>
                <OverlayController/>
            </div>
        );
    }

}

Presenting an Overlay

import React from 'react';
import OverlayController from 'react-overlay-controller';
import MyModal from './somewhere/MyModal';

class MyComponent extends React.Component {

    showModal() {
        OverlayController.showOverlay({
            component: <MyModal/>
        });
    }

}

Dismissing an Overlay

import React from 'react';
import OverlayController from 'react-overlay-controller';

class MyModal extends React.Component {

    onClose = () => {
        OverlayController.hideOverlay();
    };

    render() {
        return (
            <div>
                <div>... modal content ...</div>
                <button onClick={this.onClose}>Close</button>
            </div>
        );
    }

}

API

OverlayController.showOverlay(options)

Shows an overlay. If another overlay is already presented, then it shows the new overlay on top of the old one.

Returns overlayId which can be used to update overlay content.

Available options:

  • component (React component) - The component that should be rendered as the overlay content, on top of the curtain. Required.
  • hideOnCurtainClick (boolean) - A flag indicating if the overlay should be closed when user clicks on the curtain. Optional, default: true.
  • hideOnEscape (boolean) - A flag indicating if the overlay should be closed when user presses escape. Optional, default: true.
  • animate (boolean) - A flag indicating if the overlay should be shown and hidden with fade-in and fade-out animation. Optional, default: true.
  • onDidHide (function) - A callback that is called when the overlay was hidden by clicking on curtain or pressing escape. This callback is not called when overlay was hidden by calling OverlayController.hideOverlay() method. Optional, default: null.
  • className (string) - The class name that will be added to the div.overlayComponentContent. See overlay hierarchy for more info. Optional, default: null.
  • curtainOpacity (string|number) - Inline opacity of the div.overlayComponentCurtain. See overlay hierarchy for more info. Optional, default: null.
  • curtainColor (string) - Inline background-color (e.g.: "#000000" or "rgba(0, 0, 0, 0.25)") of the div.overlayComponentCurtain. See overlay hierarchy for more info. Optional, default: null (default background-color rgba(0, 0, 0, 0.25) is set through CSS style).

OverlayController.hideOverlay(options)

Hides an overlay. If multiple overlays presented, the topmost overlay is dismissed. If no overlays presented, this method does nothing.

OverlayController.updateComponent(overlayId, component)

Updates the component of a shown overlay.

Overlay Hierarchy

The div#overlayContainer element is the root element of the <OverlayController/> component. Each presented overlay will be appended to the root element and rendered inside div.overlayComponentContainer element:

<div id="overlayContainer">
    <div class="overlayCurtain"></div>
    <div class="overlayComponentContainer">
        <div class="overlayComponentCurtain" style={{opacity: options.curtainOpacity, backgroundColor: options.curtainColor}}/>
        <div class={"overlayComponentContent " + options.className}>{options.component}</div>
    </div>
    <div class="overlayComponentContainer">
        <div class="overlayComponentCurtain"/>
        <div class="overlayComponentContent">...</div>
    </div>
</div>

When overlays are hidden, they are removed from the hierarchy. When no overlays presented, the root element is removed as well.

The div.overlayComponentContainer uses CSS flex box to center the div.overlayComponentContent.