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

@thomagotchi/react-modal-oc

v0.1.0

Published

A lightweight, dependency-free confirmation modal for React, built with createPortal (no third-party modal plugin).

Readme

@thomagotchi/react-modal-oc

A lightweight confirmation modal for React — built from scratch with createPortal, no third-party modal library (no react-modal, no jQuery). Zero runtime dependencies besides React.

This component was extracted from the HRnet React conversion project (OpenClassrooms), where it replaces the legacy jQuery jQuery.modal.js plugin used to confirm employee creation.

Features

  • No dependencies other than react / react-dom (peer dependencies only)
  • Renders through a portal into document.body, so it's never clipped by a parent's overflow: hidden or z-index stacking context
  • Closes on Escape, on backdrop click, or programmatically
  • Locks background scroll while open
  • Accessible by default: role="dialog", aria-modal="true", labelled heading
  • Fully themeable via CSS custom properties, with sensible defaults out of the box

Installation

npm install @thomagotchi/react-modal-oc

react and react-dom (v18 or later) are peer dependencies and must already be installed in your project.

Usage

import { useState } from 'react';
import ConfirmModal from '@thomagotchi/react-modal-oc';
import '@thomagotchi/react-modal-oc/style.css';

function App() {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <>
      <button onClick={() => setIsOpen(true)}>Save employee</button>

      <ConfirmModal
        isOpen={isOpen}
        onClose={() => setIsOpen(false)}
        title="Success"
      >
        Employee has been created!
      </ConfirmModal>
    </>
  );
}

A named export is also available if you prefer explicit imports:

import { ConfirmModal } from '@thomagotchi/react-modal-oc';

Props

| Prop | Type | Default | Required | Description | | ---------- | ----------------- | ---------------- | -------- | -------------------------------------------------------------------- | | isOpen | boolean | — | Yes | Controls whether the modal is rendered/visible. | | onClose | () => void | — | Yes | Called when the user closes the modal (Escape, backdrop click, or the OK/close buttons). | | title | string | 'Confirmation' | No | Heading text shown in the modal header. | | children | React.ReactNode | — | No | Content rendered inside the modal body. |

The component is intentionally uncontrolled beyond isOpen/onClose — it does not manage its own open state, so the parent stays in full control of when it renders.

Theming

Styles are shipped as plain, prefixed (rmo-*) CSS classes with CSS custom properties that fall back to a default look, so the modal renders correctly with zero configuration. Override any of the following on :root (or any ancestor of the modal) to theme it:

| Variable | Default | | -------------------------------- | --------------------------------- | | --rmo-color-primary | #1d4e89 | | --rmo-color-primary-dark | #163a66 | | --rmo-color-surface | #ffffff | | --rmo-color-text | #2c3e50 | | --rmo-color-on-primary | #ffffff | | --rmo-overlay-bg | rgba(0, 0, 0, 0.45) | | --rmo-radius-sm / -md / -lg| 4px / 8px / 12px | | --rmo-spacing-sm-2xl | 0.5rem3rem | | --rmo-font-size-base / -lg | 1rem / 1.125rem | | --rmo-max-width | 420px | | --rmo-z-index | 999 |

Example — theming to a dark surface:

:root {
  --rmo-color-surface: #1e1e1e;
  --rmo-color-text: #f0f0f0;
  --rmo-color-primary: #7c3aed;
  --rmo-color-primary-dark: #6025c2;
}

Why a custom component instead of a plugin?

This package intentionally avoids wrapping an existing modal library. It only implements the actual UI behavior of a modal dialog (open/close, focus trapping via the portal, Escape/backdrop dismissal) — matching the scope of what it replaces: jQuery.modal.js's UI plugin, not any application/business logic that used to sit alongside it.

Local development

npm install
npm run dev     # serves the example/ app for manual testing
npm run build   # builds dist/ (ESM + CJS + style.css)

License

MIT © Thomagotchi