import React from 'react'; import ReactDOM from 'react-dom'; import Popup from '../lib/react-custom-popup.js'; const CUSTOM_DIMENSION = 500; class App extends React.Component { constructor (props) { super(props); this.onCustomLayoutCheckboxClick = this.onCustomLayoutCheckboxClick.bind(this); this.onHideOverlayCheckboxClick = this.onHideOverlayCheckboxClick.bind(this); this.onShowPopupButtonClick = this.onShowPopupButtonClick.bind(this); this.onPopupOverlayClick = this.onPopupOverlayClick.bind(this); this.refButton = React.createRef(); this.state = { customLayout: false, hideOverlay: false, popupVisible: false }; } onHideOverlayCheckboxClick (event) { this.setState({hideOverlay: !this.state.hideOverlay}); } onCustomLayoutCheckboxClick (event) { this.setState({customLayout: !this.state.customLayout}); } onShowPopupButtonClick (event) { event.stopPropagation(); event.preventDefault(); this.setState({popupVisible: true}); } onPopupOverlayClick (event) { event.stopPropagation(); event.preventDefault(); this.setState({popupVisible: false}); } onPopupLayout (currentLayout) { return [ (window.innerWidth - CUSTOM_DIMENSION) / 2, (window.innerHeight - CUSTOM_DIMENSION) / 2, CUSTOM_DIMENSION, CUSTOM_DIMENSION ]; } render () { return (

React Custom Popup Example

Configure

); } } window.addEventListener('load', () => { ReactDOM.render( , document.getElementById('main') ); });