{"size": 1198, "ext": "js", "max_stars_repo_path": "src/components/LinkedIn/buttons/LoginButton.js", "max_stars_repo_name": "chihungyu1116/perk-saga", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/LinkedIn/buttons/LoginButton.js", "max_issues_repo_name": "chihungyu1116/perk-saga", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/LinkedIn/buttons/LoginButton.js", "max_forks_repo_name": "chihungyu1116/perk-saga", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.1851851852, "max_line_length": 94, "alphanum_fraction": 0.6068447412}
import React, { Component, PropTypes } from 'react';

const BUTTON_IMAGE_DEFAULT = require('../../../../static/images/linkedin/signin_default.png');
const BUTTON_IMAGE_HOVER = require('../../../../static/images/linkedin/signin_hover.png');

export default class LinkedInLoginButton extends Component {
  constructor(props) {
    super(props);
    this.state = {
      src: BUTTON_IMAGE_DEFAULT
    };
    this.onClick = this.onClick.bind(this);
    this.onMouseEnter = this.onMouseEnter.bind(this);
    this.onMouseLeave = this.onMouseLeave.bind(this);
  }

  onClick() {
    window.IN.User.authorize((res) => {
      console.log('res', res);
    }, window);
  }

  onMouseEnter() {
    this.setState({
      src: BUTTON_IMAGE_HOVER,
    });
  }

  onMouseLeave() {
    this.setState({
      src: BUTTON_IMAGE_DEFAULT,
    });
  }

  render() {
    return (
      <div>
        <img
          {...this.props}
          src={this.state.src}
          onClick={this.onClick}
          onMouseEnter={this.onMouseEnter}
          onMouseLeave={this.onMouseLeave}
          alt="Linkedin Signin"
        />
      </div>
    );
  }
}

LinkedInLoginButton.propTypes = {
  classNames: PropTypes.string,
};
