import React from 'react';
import ReactDOM from 'react-dom';
import styles from './index.less';
styles;

const Popup = (reslove,options) => {
  let rootDom = document.createElement('div');
  rootDom.className='popup-box';
  if(options&&options.cantouch)rootDom.setAttribute('data-can-touch','1');
  if(options&&options.transparent)rootDom.setAttribute('data-transparent','1');

  let destory = (result) => {
    ReactDOM.unmountComponentAtNode(rootDom);
    rootDom.parentNode.removeChild(rootDom);
    if (reslove) reslove(result);
  };
  document.body.appendChild(rootDom);
  return { dom: rootDom, destory };
};


export default Popup;
