summaryrefslogtreecommitdiff
path: root/frontend/src/components/home/ChooseNameForm.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/components/home/ChooseNameForm.jsx')
-rw-r--r--frontend/src/components/home/ChooseNameForm.jsx42
1 files changed, 42 insertions, 0 deletions
diff --git a/frontend/src/components/home/ChooseNameForm.jsx b/frontend/src/components/home/ChooseNameForm.jsx
new file mode 100644
index 00000000..119fc851
--- /dev/null
+++ b/frontend/src/components/home/ChooseNameForm.jsx
@@ -0,0 +1,42 @@
+// @flow
+import { Button, Classes, InputGroup, Intent } from '@blueprintjs/core';
+import React, { Component } from 'react';
+import { connect } from 'react-redux';
+import { actions } from '../../redux/players';
+
+export type ChooseNameFormPresenterProps = {
+ chooseUsername: (username: string) => void,
+}
+
+class ChooseNameFormPresenter extends Component<ChooseNameFormPresenterProps> {
+ _username = '';
+
+ play = e => {
+ e.preventDefault();
+ if (this._username !== undefined) {
+ this.props.chooseUsername(this._username);
+ }
+ };
+
+ render() {
+ return (
+ <form onSubmit={this.play}>
+ <InputGroup
+ placeholder="Username"
+ onChange={e => (this._username = e.target.value)}
+ rightElement={this.renderSubmit()}
+ />
+ </form>
+ );
+ }
+
+ renderSubmit = () => (
+ <Button className={Classes.MINIMAL} onClick={this.play} intent={Intent.PRIMARY} rightIcon="arrow-right" />
+ );
+}
+
+const mapDispatchToProps = {
+ chooseUsername: actions.chooseUsername,
+};
+
+export const ChooseNameForm = connect(null, mapDispatchToProps)(ChooseNameFormPresenter);
bgstack15