summaryrefslogtreecommitdiff
path: root/frontend/src/scenes/SplashScreen/index.js
blob: 022caf45d49814f05d05ff7a7473b9fca8ceec85 (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// @flow
import { Button, Classes, InputGroup, Intent } from '@blueprintjs/core';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Container } from 'rebass';
import { actions } from '../../redux/players';
import { HomeLayout } from './components/HomeLayout';

class SplashScreenPresenter extends Component {
  _username = '';

  play = e => {
    e.preventDefault();
    if (this._username !== undefined) {
      this.props.chooseUsername(this._username);
    }
  };

  render() {
    return (
      <HomeLayout>
        <Container>
          <form onSubmit={this.play}>
            <InputGroup
              placeholder="Username"
              onChange={e => (this._username = e.target.value)}
              rightElement={this.renderSubmit()}
            />
          </form>
        </Container>
      </HomeLayout>
    );
  }

  renderSubmit = () => (
    <Button className={Classes.MINIMAL} onClick={this.play} intent={Intent.PRIMARY} rightIconName="arrow-right" />
  );
}

const mapDispatchToProps = {
  chooseUsername: actions.chooseUsername,
};

export const SplashScreen = connect(null, mapDispatchToProps)(SplashScreenPresenter);
bgstack15