import React, { Component } from 'react';
import './index.less';

export default class ShowImage extends Component {
  constructor(props) {
    super(props);
    this.state = { show: false };
  }

  render() {
    return (
      <div className="show-image">
        <img className="image" src={this.props.src} onClick={() => this.props.src && this.setState({ show: true })} />
        {this.state.show ? (
          <div className="show-image-full" onClick={() => this.setState({ show: false })}>
            <img src={this.props.src} />
          </div>
        ) : (
          ''
        )}
      </div>
    );
  }
}
