import Drawer from '..';
import React from 'react';
import ReactDOM from 'react-dom';
import { Button, Radio } from '../..';

class Demo extends React.Component {
  state = {
    visible: false,
    placement: 'right',
  };

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

  onClose = () => {

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

  onPlacementChange = dir => {
    this.setState({
      placement: dir,
    });
  };

  render() {
    return (
      <div>
        <Radio.Group
          dataSource={[ 'right', 'bottom', 'left', 'top' ]}
          defaultValue={'right'}
          onChange={this.onPlacementChange}
        />
        <br/>
        <br/>
        <Button type="primary" onClick={this.onOpen}> open </Button>
        <Drawer
          title="标题"
          footer
          footerAlign="center"
          visible={this.state.visible}
          // @ts-ignore
          placement={this.state.placement}
          onClose={this.onClose}>
                    Start your business here by searching a popular product
        </Drawer>
      </div>
    );
  }
}

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