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

@solo5star/react-modal

v0.1.5

Published

A minimal modal implementation for React

Downloads

4

Readme

@solo5star/react-modal

@solo5star/react-modal은 React를 위한 가장 간단한 모달 구현을 제공해주는 라이브러리입니다.

이 라이브러리를 사용하기 위해선 react@^18.0.0, react-dom@^18.0.0, styled-components@^6.0.0 이 필요합니다.

Table of Contents

Features

  • ESM과 CJS 모두 지원합니다.
  • styled-components를 사용한 스타일 주입을 지원합니다.

Installation

npm 혹은 yarn, pnpm 을 사용할 수 있습니다.

For npm:

$ npm install react react-dom styled-components
$ npm install @solo5star/react-modal

For yarn:

$ yarn add react react-dom styled-components
$ yarn add @solo5star/react-modal

For pnpm:

$ pnpm add react react-dom styled-components
$ pnpm add @solo5star/react-modal

Basic Example

import { useState } from 'react';
import { Modal } from 'react-modal';

const App = () => {
  const [modalOpen, setModalOpen] = useState(false);

  const handleModalOpen = () => setModalOpen(true);
  const handleModalClose = () => setModalOpen(false);

  return (
    <>
      <button onClick={handleModalOpen}>Open Modal</button>

      <Modal.Root open={modalOpen} onClose={handleModalClose}>
        <Modal.Backdrop onClick={handleModalClose}>
        <Modal.Content>
          <h1>Hello! 👋 Welcome to Modal</h1>

          <button onClick={handleModalClose}>Close</button>
        </Modal.Content>
      </Modal.Root>
    </>
  )
}

Inject style using styled-components

styled-components 라이브러리를 사용하여 스타일을 주입하여 사용할 수 있습니다.

Example Styled Modal

import { useState } from 'react';
import styled from 'styled-components';
import { Modal } from 'react-modal';

const MyModal = {
  ...Modal,
  Backdrop: styled(Modal.Backdrop)`
    background: linear-gradient(
      to top,
      rgba(68, 207, 163, 0.8),
      rgba(68, 207, 163, 0.2),
      transparent 80%
    );
    opacity: 0.4;
  `,
  Content: styled(Modal.Content)`
    padding: 24px;

    background: hsl(0, 0%, 16%);
    border-radius: 24px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;

    @media (prefers-color-scheme: light) {
      background: hsl(0, 0%, 100%);
    }
  `,
};

const App = () => {
  const [modalOpen, setModalOpen] = useState(false);

  const handleModalOpen = () => setModalOpen(true);
  const handleModalClose = () => setModalOpen(false);

  return (
    <>
      <button onClick={handleModalOpen}>Open Modal</button>

      <MyModal.Root open={modalOpen} onClose={handleModalClose}>
        <MyModal.Backdrop onClick={handleModalClose} />
        <MyModal.Content placement={modalPlacement}>
          <h1>Sample Modal!</h1>
        </MyModal.Content>
      </MyModal.Root>
    </>
  )
}