UNPKG

2.86 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../src/generic-view/Overlay.js"],"names":["CloseButton","div","props","dart","Overlay","container","document","createElement","body","appendChild","removeChild","style","className","onClose","render","children","createPortal","Component","propTypes","func","DefaultOverlay","dark"],"mappings":";;;;;;;;;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;;;;;;;;;kJAJA;;;AAMA,IAAMA,cAAc,2BAAOC,GAArB,kBAMK;AAAA,SAAUC,MAAMC,IAAN,GAAa,SAAb,GAAyB,MAAnC;AAAA,CANL,CAAN;;AASA;;IAEaC,O,WAAAA,O;;;AAIX,mBAAYF,KAAZ,EAAmB;AAAA;;AAAA,kHACXA,KADW;;AAEjB,UAAKG,SAAL,GAAiBC,SAASC,aAAT,CAAuB,KAAvB,CAAjB;AACAD,aAASE,IAAT,CAAcC,WAAd,CAA0B,MAAKJ,SAA/B;AAHiB;AAIlB;;;;2CAEsB;AACrBC,eAASE,IAAT,CAAcE,WAAd,CAA0B,KAAKL,SAA/B;AACD;;;6BAEQ;AAAA,mBACiD,KAAKH,KADtD;AAAA,UACCS,KADD,UACCA,KADD;AAAA,UACQC,SADR,UACQA,SADR;AAAA,UACmBC,OADnB,UACmBA,OADnB;AAAA,UAC4BC,MAD5B,UAC4BA,MAD5B;AAAA,UACoCC,QADpC,UACoCA,QADpC;;AAEP,aAAO,mBAASC,YAAT,CACL;AAAA;AAAA,UAAK,WAAWJ,SAAhB,EAA2B,OAAOD,KAAlC;AACGG,iBAASA,OAAO,EAAED,gBAAF,EAAP,CAAT,GAA+BE,QADlC;AAEGF,mBAAW;AAAC,qBAAD;AAAA,YAAa,SAASA,OAAtB;AAAA;AAAA;AAFd,OADK,EAKL,KAAKR,SALA,CAAP;AAOD;;;;EAvB0B,gBAAMY,S;;AAAtBb,O,CACJc,S,GAAY;AACjBJ,UAAQ,oBAAUK;AADD,C;;;AAyBrB,IAAMC,iBAAiB,gCAAOhB,OAAP,CAAjB,mBAGgB;AAAA,SAAUF,MAAMmB,IAAN,GAAa,oBAAb,GAAoC,0BAA9C;AAAA,CAHhB,CAAN;;kBAgBeD,c","file":"Overlay.js","sourcesContent":["/** warning compatible only with react 16 and later **/\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport styled from 'styled-components'\nimport PropTypes from 'prop-types'\n\nconst CloseButton = styled.div`\n position: fixed;\n top: 20px;\n right: 20px;\n cursor: pointer;\n font-size: 24px;\n color: ${props => (props.dart ? '#efefef' : '#444')};\n`\n\n// THIS requires react 16\n\nexport class Overlay extends React.Component {\n static propTypes = {\n render: PropTypes.func,\n }\n constructor(props) {\n super(props)\n this.container = document.createElement('div')\n document.body.appendChild(this.container)\n }\n\n componentWillUnmount() {\n document.body.removeChild(this.container)\n }\n\n render() {\n const { style, className, onClose, render, children } = this.props\n return ReactDOM.createPortal(\n <div className={className} style={style}>\n {render ? render({ onClose }) : children}\n {onClose && <CloseButton onClick={onClose}>&#10006;</CloseButton>}\n </div>,\n this.container\n )\n }\n}\n\nconst DefaultOverlay = styled(Overlay)`\n position: fixed;\n display: flex;\n background-color: ${props => (props.dark ? 'rgba(0, 0, 0, 0.3)' : 'rgba(255, 255, 255, 0.8)')};\n width: 100vw;\n height: 100vh;\n max-height: 100vh;\n max-width: 100vw;\n left: 0px;\n top: 0px;\n align-items: center;\n justify-content: center;\n overflow: auto;\n z-index: 1000000;\n`\n\nexport default DefaultOverlay\n"]}
\No newline at end of file