0.0.2 • Published 2 years ago

lxw-react-popup v0.0.2

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

🏠 Homepage

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

React + TypeScript 从零开发 Popup 组件并发布到 npm

Install

yarn add lxw-react-popup

# or

npm i lxw-react-popup

Usage

import React, { useState } from 'react';
import { Popup } from 'lxw-react-popup';
import 'lxw-react-popup/dist/react-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:lvxiaowu/react-popup.git
cd react-popup
yarn
yarn start

open another terminal tab

cd example
yarn
yarn start

Run tests

yarn test

Author

👤 lvxiaowu

Show your support

Give a ⭐️ if this project helped you!


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