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

rc-dialog-native

v1.0.9

Published

Render a dialog html tag with react

Downloads

8

Readme

rc-dialog-native

Render a modal with the dialog html tag and take advantage of the native features of this tag

Description

  • Allow press ESC key to close modal (native)
  • Allow click outside the modal to close (native)
  • Allow disable tabindex the elements on the back of the modal
  • Allow close the modal on any moment programatically

Installation

Use npm to install this library

npm i rc-dialog-native

Props

Made with ts and jsdoc. Props autocomplete should be on the code editor.

| Prop name | Description | Type | Required | | ------------- | ------------------------------------------------------------------------------------------------------------------- | -------------------------------- | -------- | | forwardRef | Reference of the dialog tag. | React.MutableRefObject | Yes | | title | Title label to display on the modal once it's open | JSX.Element|JSX.Element[]|null | No | | footer | Elements to render on the footer of the modal | JSX.Element|JSX.Element[]|null | No | | children | Content of the modal once it's open | JSX.Element|JSX.Element[]|null | No | | closeCallback | Function that will allow to close the modal. If it's provided, will render an "X" icon in order to close the modal | (()=>void)|null | No | | width | Width size (on viewport scale) for the modal on desktop and laptops devices | number | No |

Examples

React (No frameworks)

import { Dialog, useDialog } from "rc-dialog-native";

function App() {
  const dialog = useDialog();

  return (
    <main>
      <p onClick={dialog.showModal}>Read terms and conditions</p>

      <Dialog
        closeCallback={dialog.close}
        forwardRef={dialog.forwardRef}
        title={<p>Terms and conditions</p>}
        width={25}
        footer={<button onClick={dialog.close}>I'm agree</button>}
      >
        <ol>
          <li>Do not be agressive</li>
          <li>Do not disturbe on the community</li>
          <li>Not allow to sell any kind of product or service</li>
        </ol>
      </Dialog>
    </main>
  );
}

export default App;

Nextjs (v^13.4.2)

  1. Create a Client Component. Like the next below
"use client";

import React from "react";
import { Dialog, useDialog } from "rc-dialog-native";

export default function TermsAndConditions() {
  const dialog = useDialog();
  return (
    <>
      <button type="button" onClick={dialog.showModal}>
        TermsAndConditions
      </button>

      <Dialog forwardRef={dialog.forwardRef}>
        <p>
          Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut, quidem
          quos? Nobis, et iure eaque ipsum quae eveniet totam magnam asperiores
          suscipit autem delectus dolorum perferendis nostrum! Animi officia eum
        </p>
      </Dialog>
    </>
  );
}
  1. Import the component into a server or client component.
import TermsAndConditions from "./pages/TermsAndConditions";

// This is a server component
export default function Home() {
  return (
    <form>
      <label htmlFor="">Email</label>
      <input type="email" />
      <TermsAndConditions />
    </form>
  );
}
```.