# react-yt-modal

> Yeopto's Basic Modal

Latest version **0.0.5** (published 2023-05-08) · 0 weekly downloads

## Install

```sh
npm install react-yt-modal
pnpm add react-yt-modal
yarn add react-yt-modal
bun add react-yt-modal
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2023-05-08 |
| First published | 2023-05-05 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | yeopto |
| Keywords | react, component, modal, backsheet |

## Links

- npm: https://www.npmjs.com/package/react-yt-modal
- Repository: https://github.com/yeopto/react-yt-modal
- Homepage: https://github.com/yeopto/react-yt-modal#readme
- Issues: https://github.com/yeopto/react-yt-modal/issues
- npm.io page: https://npm.io/package/react-yt-modal

## Dependencies (13)

- [react](https://npm.io/package/react.md) ^18.2.0
- [react-dom](https://npm.io/package/react-dom.md) ^18.2.0
- [typescript](https://npm.io/package/typescript.md) ^4.9.5
- [web-vitals](https://npm.io/package/web-vitals.md) ^2.1.4
- [@types/jest](https://npm.io/package/@types/jest.md) ^27.5.2
- [@types/node](https://npm.io/package/@types/node.md) ^16.18.25
- [@types/react](https://npm.io/package/@types/react.md) ^18.2.5
- [react-scripts](https://npm.io/package/react-scripts.md) 5.0.1
- [@types/react-dom](https://npm.io/package/@types/react-dom.md) ^18.2.3
- [@testing-library/react](https://npm.io/package/@testing-library/react.md) ^13.4.0
- [@types/styled-components](https://npm.io/package/@types/styled-components.md) ^5.1.26
- [@testing-library/jest-dom](https://npm.io/package/@testing-library/jest-dom.md) ^5.16.5
- [@testing-library/user-event](https://npm.io/package/@testing-library/user-event.md) ^13.5.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2023-05-08
- 0.0.4 — 2023-05-07
- 0.0.3 — 2023-05-05
- 0.0.2 — 2023-05-05
- 0.0.1 — 2023-05-05

## README

# Yeopto's Modal Libarary

This is a library that enables you to use a modal that appears from the bottom. You can close the modal by clicking on the background, and you can also close it by pressing the 'ESC' key.

## Installation

### npm

```
npm install react-yt-modal
```

### yarn

```
yarn add react-yt-modal
```

## Props

### isOpen

- A status value of type boolean indicating whether the modal is open or closed.
- This modal library displays the modal when isOpen is true, and does not display it when it is false

### closeModal

- A custom function that closes the modal.
- To close the modal in this modal library, isOpen needs to be set to false since the modal is displayed when isOpen is true. So, Should contain the logic to change `isOpen` to `false` in this function.

### portalNode

- Pass the DOM node where the modal will be rendered (optional).

## User Guide

### Import Library

```tsx
import Modal from "react-yt-modal";
```

### Use Library

```tsx
<Modal
  isOpen={/* Modal State */}
  closeModal={/* Close Modal Function */}
  portalNode={/* DOM node(optional) */}
>
  {/* Modal Contents(ReactNode) */}
</Modal>
```

### Using Example Code

```tsx
import Modal from "react-yt-modal";
import { useState } from "react";
import styled from "styled-components";

function App() {
  const [isModalOpen, setIsModalOpen] = useState(false);

  const openModal = () => {
    setIsModalOpen(true);
  };

  const closeModal = () => {
    setIsModalOpen(false);
  };

  const root = document.querySelector("#root");

  return (
    <Container>
      <Button onClick={openModal}>Open Modal</Button>
      <Modal isOpen={isModalOpen} closeModal={closeModal} portalNode={root}>
        <Caption>
          Hi there, I'm a modal that you can open and close. Now you can close
          me by clicking on the close button on my window.
        </Caption>
        <Button onClick={closeModal}>Close Modal</Button>
      </Modal>
    </Container>
  );
}

export default App;

const Container = styled.div`
  display: flex;
  justify-content: center;
  align-items: center;

  font-family: monospace;
  width: 100vw;
  height: 100vh;
`;

const Button = styled.button`
  color: white;
  font-weight: bold;
  font-size: 15px;
  border: none;
  border-radius: 10px;
  width: 130px;
  height: 50px;
  background-color: #14428d;
  padding: 10px;

  cursor: pointer;
`;

const Caption = styled.p`
  text-align: justify;
  margin-bottom: 20px;
`;
```

## Development Environment

- React(Create-React-App)
- TypeScript
- Styled-Components

## Browser Support

<table>
  <tr>
    <td align="center" width="150px">
      <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e1/Google_Chrome_icon_%28February_2022%29.svg/1200px-Google_Chrome_icon_%28February_2022%29.svg.png" alt="Chrome icon" />
    </td>
    <td align="center" width="150px">
      <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Safari_browser_logo.svg/2057px-Safari_browser_logo.svg.png" alt="Safari icon" />
    </td>
  </tr>
  <tr>
    <td align="center">
      Latest ✓
    </td>
    <td align="center">
      Latest ✓
    </td>
  </tr>
</table>

## Version

- 0.0.4 (latest)

---
_Source: https://npm.io/package/react-yt-modal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
