import './demo2.css';
import Overlay from '..';
import React from 'react';
import ReactDOM from 'react-dom';
import { Button } from '../..';

class Demo extends React.Component {
  btn: any;

  state = {
    visible: false,
  };

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

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

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

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