0.2.4 • Published 4 years ago

react-easy-popup v0.2.4

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

🏠 Homepage

React Component based on ReactDOM.createPortal function for transportation element.

Install

yarn add react-easy-popup

# or

npm i react-easy-popup

Usage

import React, { useState } from 'react';
import { Popup } from 'react-easy-popup';
import 'react-easy-popup/dist/react-easy-popup.min.css';

export default () => {
  const [visible, setVisible] = useState(false);
  return (
    <>
      <button onClick={() => setVisible(true)}>click me</button>
      <Popup maskClosable visible={visible} onClose={() => setVisible(false)}>
        <div className="your-content">hello world</div>
      </Popup>
    </>
  );
};

API

PropertyDescriptionTypeDefault
visibleOptional,control content visibilitybooleanfalse
positionOptional,determines where the content will pop up'center' / 'top' / 'bottom' / 'left' / 'right''center'
maskOptional,decide whether to display the background layerbooleantrue
maskClosableOptional,if the value is true, clicking on the background layer will trigger onClose functionbooleanfalse
onCloseOptional,a function to set the visible to falsefunction()=>{}
nodeOptional,the mounted nodeHTMLElement-
destroyOnCloseOptional,whether content nodes are unloaded when closedbooleanfalse
wrapClassNameOptional,className for the container nodestring''

Contributions Welcome!

git clone git@github.com:worldzhao/react-easy-popup.git
cd react-easy-popup
yarn
yarn start

open another terminal tab

cd example
yarn
yarn start

Run tests

yarn test

Author

👤 海秋

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator