aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/LoginButton.js
blob: f35a932d29058d05d6bc772432362cc2b22034f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import React from 'react';
import PropTypes from 'prop-types';
import Icon from './Icon';


export default class LoginButton extends React.Component {
  constructor(props) {
    super(props);
    window.addEventListener('message', (event) => {
      this.props.onAuth(event.data);
    }, false);
  }
  login(event) {
    event.preventDefault();
    let loginWindow = window.open('https://juick.com/login?redirect=false', 'Login to Juick', 'width=400,height=300,resizeable=no,menubar=no,toolbar=no,scrollbars=no');
    loginWindow.window.focus();
  }

  render() {
    return (
      <a href="/login" onClick={this.login}><Icon name="ei-user" size="s"/>{this.props.title}</a>
    );
  }
}

LoginButton.propTypes = {
  title: PropTypes.string.isRequired,
  onAuth: PropTypes.func.isRequired
};