1.0.1 β€’ Published 3 years ago

dotoli-popup v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Dotoli-Popup Guide

πŸ₯³ 화면이 꽉찬 Modal / Popup을 μ’€ 더 νŽΈν•˜κ³  κΉ”λ”ν•˜κ²Œ μ“°κ³  μ‹Άμ–΄ λ§Œλ“  라이브러리

μ˜ˆμ‹œλŠ” example 폴더λ₯Ό 확인 λΆ€νƒλ“œλ¦½λ‹ˆλ‹€.

Install Guide

npm install dotoli-popup
# OR
yarn add dotoli-popup

Getting Started

The Gist

import { render } from 'react-dom';
import popup, { PopupContainer } from 'dotoli-popup';
import Popup from './Popup';  // React Component

const App = () => {
  const onClick = () => {
    // Popup Open 
    popup.open({
      id: 'popup',
      render: Popup,
      props: {
        header: 'Lorem ipsum',
        onCloseClick: () => {
          // Popup Close
          popup.close('popup');
        },
      },
      onClose: () => console.log('On Close Event'),
      backgroundCloseable: true,
      onOpen: () => console.log('On Open Event'),
    });
  };

  return (
    <div>
      <PopupContainer />
      <button onClick={onClick}>Open modal</button>
    </div>
  );
};

render(<App />, document.getElementById('root'));

Use NextJS

// pages/_app.tsx or pages/_app.js
import { AppProps } from 'next/app';
import { PopupContainer } from 'dotoli-popup';

const App = ({ Component, pageProps }: AppProps) => (
  <>
    <PopupContainer />
    <Component {...pageProps} />
  </>
);

export default App;

popup.open Props

keyrequireddefaultdescription
idβœ…νŒμ—… ID둜 μ’…λ£Œ 및 popup ꡬ뢄에 μ“°μž„
renderβœ…νŒμ—… Component
propsνŒμ—… Component 의 Props
onCloseνŒμ—… μ’…λ£Œ μ‹œ μ‹€ν–‰ 이벀트
onOpenνŒμ—… μ˜€ν”ˆ μ‹œ μ‹€ν–‰ 이벀트
backgroundClosealbefalseνŒμ—… Component λ°–μ˜ μ˜μ—­ 클릭 μ‹œ μ’…λ£Œ μ—¬λΆ€