import './demo1.css';
import Overlay from '..';
import React from 'react';
import ReactDOM from 'react-dom';
import { Button } from '../..';
class Demo extends React.Component {
  state = {
    visible: false,
  };

  btn: any;

  onClick = () => {
    this.setState({
      visible: !this.state.visible,
    });
  };

  onClose = () => {
    this.setState({
      visible: false,
    });
  };

  render() {
    return (
      <div>
        <Button
          onClick={this.onClick}
          ref={ref => {
            this.btn = ref;
          }}
        >
          Toggle visible
        </Button>
        <Overlay
          visible={this.state.visible}
          target={() => this.btn}
          safeNode={() => this.btn}
          onRequestClose={this.onClose}
        >
          <span className="overlay-demo">Hello World From Overlay!</span>
        </Overlay>
      </div>
    );
  }
}

ReactDOM.render(<Demo />, document.getElementById('overlay-demo-1'));
