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

woowacourse-6th-react-modal-component

v0.0.27

Published

Simple Modal for custom content

Downloads

32

Readme

React Modal Component Library

Description

This library provides an easy way to create and customize modals in your React application. It offers a set of reusable components for building different types of modals, including 'alert,' 'confirm', and 'prompt' modals. The library is built with styled-components, allowing for easy customization of styles.

There are two methods to close the modal: clicking on a button or a close icon. The modal can be positioned at the center of the screen (center option) or at the bottom edge of the screen (bottom option).

Also, you can place children components inside the Modal component. Feel free to utilize the modal by adding events to your children components!

Installation

npm i woowacourse-6th-react-modal-component

Components

Modal

The base container component for the modal.

| Prop | Description | Default | | -------------- | -------------------------------------------------------- | ---------- | | $size | The size of the modal ('small', 'medium', 'large') | 'medium' | | $position | The position of the modal ('center', 'bottom') | 'center' | | onCloseModal | A function called when the modal is closed | Required |

Modal.Header

The header component for the modal.

| Prop | Description | Default | | -------------- | ------------------------------------------------ | -------- | | title | The title of the header | Required | | isCloseIcon | Whether to show a close icon or not | false | | onCloseModal | A function called when the close icon is clicked | Required |

Modal.Content

The content component for the modal.

| Prop | Description | Default | | ------------------ | -------------------------------------------------- | ----------- | | basicDescription | The basicDescription to display in the content | undefined | | $direction | The direction of the content ('row', 'column') | 'column' |

Modal.Footer

The footer component for the modal.

| Prop | Description | Default | | ------------ | ------------------------------------------------------------ | ------- | | $direction | The direction of the footer ('row', 'column') | 'row' | | $align | The alignment of the footer ('start', 'center', 'end') | 'end' |

Modal.Button

The button component for the modal.

| Prop | Description | Default | | ------------------ | --------------------------------------------------------- | ----------- | | $size | The size of the button ('small', 'medium', 'large') | 'medium' | | $backgroundColor | The background color of the button | undefined | | $color | The text color of the button | undefined | | onButtonClick | A function called when the button is clicked | Required |

Modal.Input

The input component for the modal.

| Prop | Description | Default | | ---------- | ---------------------------------------------- | ----------- | | label | The label for the input field | undefined | | onChange | A function called when the input value changes | Required |

Example Modals

AlertModal

A simple alert modal.

import { AlertModal } from 'woowacourse-6th-react-modal-component';

function App() {
  const handleConfirm = () => {
    console.log('Confirmed');
  };

  const handleClose = () => {
    console.log('Modal closed');
  };

  return (
    <AlertModal
      title="Alert"
      basicDescription="This is an alert modal."
      onConfirmButtonClick={handleConfirm}
      onModalClose={handleClose}
    />
  );
}

export default App;

ConfirmModal

A confirm/cancel modal.

import { ConfirmModal } from 'woowacourse-6th-react-modal-component';

function App() {
  const handleConfirm = () => {
    console.log('Confirmed');
  };

  const handleCancel = () => {
    console.log('Canceled');
  };

  const handleClose = () => {
    console.log('Modal closed');
  };

  return (
    <ConfirmModal
      title="Confirm"
      basicDescription="Are you sure you want to proceed?"
      onConfirmButtonClick={handleConfirm}
      onCancelButtonClick={handleCancel}
      onModalClose={handleClose}
    />
  );
}

export default App;

PromptModal

A modal that prompts for user input.

import { PromptModal } from 'woowacourse-6th-react-modal-component';

function App() {
  const handleConfirm = () => {
    console.log('Confirmed');
  };

  const handleCancel = () => {
    console.log('Canceled');
  };

  const handleClose = () => {
    console.log('Modal closed');
  };

  const handleInputChange = (e) => {
    console.log('Input value:', e.target.value);
  };

  return (
    <PromptModal
      title="Prompt"
      basicDescription="Please enter your name:"
      label="Name"
      onConfirmButtonClick={handleConfirm}
      onCancelButtonClick={handleCancel}
      onModalClose={handleClose}
      onInputChange={handleInputChange}
    />
  );
}

export default App;