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

turtle601-modal-like-chakra-ui

v0.1.1

Published

This is Real Compound Component

Downloads

14

Readme

modal-like-chakra-ui

설명

Compound Component로 Chakra UI랑 비슷한 기능을 하도록 구현

설치

// js환경과 ts환경 둘 다 사용 가능합니다.

npm i -D styled-components  - 스타일 컴포넌트를 사용해야 합니다.
npm i -D react react-dom - react 환경이어야 합니다.

사용법

기본 스타일은 다음과 같이 사용할 수 있습니다.

const onChange = () => {};

const [isModal, closeModal, openModal] = useCardModal(true);

<Modal isModal={isModal} isOpen={isOpen} onClose={onClose}>
  <ModalOverlay />
  <ModalContent>
    <ModalHeader>대충 모달 타이틀이라는 내용</ModalHeader>
    <ModalBody>대충 모달 Body라는 내용</ModalBody>
    <ModalFooter>
      <ModalCloseButton />
    </ModalFooter>
  </ModalContent>
</Modal>;

해당 기능의 스타일을 주고 싶다면 다음과 같이 사용하세요 (ex) Modal body에 커스텀 스타일을 적용하고 싶을 때)

<Modal isModal={isModal} isOpen={isOpen} onClose={onClose}>
  <ModalOverlay />
  <ModalContent>
    <ModalHeader>대충 모달 타이틀이라는 내용</ModalHeader>
    <ModalBody isCustom>
      <StyledModalBody>대충 모달 Body라는 내용</StyledModalBody>
    </ModalBody>
    <ModalFooter>
      <ModalCloseButton />
    </ModalFooter>
  </ModalContent>
</Modal>;

const StyledModalBody = styled.div`
  /*
    커스텀 디자인 작성하기
  */
`;

그 외 props

  1. blockScrollOnMount
<Modal blockScrollOnMount={false}>{children}</Modal>
  • 해당 속성을 사용해서 Modal 창이 띄워졌을 시 scroll이 안되게 한다.
  1. isCenter
<Modal.Content isCenter={true}></Modal.Content>

// Modal 내의 속성에서는 어디서는 사용할 수 있다.
  • 해당 속성을 사용해서 해당 컨텐츠를 화면 가운데 띄울 수 있다.
  1. isBottom
<Modal.Content isBottom={true}></Modal.Content>
  • 해당 속성을 사용해서 해당 컨텐츠를 화면 하단에 띄울 수 있다.

컴포넌트 이해하기

  1. Modal
  • Modal에 props를 부여, 해당 기능을 넣어준다.
  1. Modal.Overlay
  • Modal의 뒷배경(어두운)을 나타낸다.
  • chilldren 및 별도의 props는 존재하지 않는다.
  • 커스텀 스타일링 불가능
  1. Modal.Content
  • Modal의 내용을 담는 컴포넌트를 나타낸다.
  • isCustom, isBottom, isCenter 속성을 넣을 수 있다.
  1. Modal.CloseButton
  • Modal을 닫는 기능을 가진 버튼을 나타낸다.
  • isCustom속성을 통해 커스텀 스타일링이 가능하다.
  1. Modal.Header
  • Modal Content 내부에 Header의 기능을 가진 컴포넌트를 나타낸다.
  • isCustom속성을 통해 커스텀 스타일링이 가능하다.
  1. Modal.Body
  • Modal Content 내부에 Body의 기능을 가진 컴포넌트를 나타낸다.
  • isCustom속성을 통해 커스텀 스타일링이 가능하다.
  1. Modal.Footer
  • Modal Content 내부에 Footer의 기능을 가진 컴포넌트를 나타낸다.
  • isCustom속성을 통해 커스텀 스타일링이 가능하다.