From 03817b09c923fd0aa7167f1704b493a2d9dd929e Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 28 Jan 2018 06:46:47 -0500 Subject: [PATCH] Submit from Client works Does what it says on the tin, need to add progression to next round next. --- googletrendsgame/src/App.js | 2 +- googletrendsgame/src/components/GameScreen.js | 6 ++++- .../src/components/RoomListItem.js | 2 +- .../src/components/activeButton.js | 10 +++++++ .../src/components/createRoomInput.js | 2 +- googletrendsgame/src/components/wordInput.js | 27 +++++++++++++++++-- 6 files changed, 43 insertions(+), 6 deletions(-) diff --git a/googletrendsgame/src/App.js b/googletrendsgame/src/App.js index a29e512..0e7b311 100644 --- a/googletrendsgame/src/App.js +++ b/googletrendsgame/src/App.js @@ -72,7 +72,7 @@ class App extends Component { ) } else if (this.state.progression === 'gameScreen') { return( - + ) } } diff --git a/googletrendsgame/src/components/GameScreen.js b/googletrendsgame/src/components/GameScreen.js index e4bf34d..53841f0 100644 --- a/googletrendsgame/src/components/GameScreen.js +++ b/googletrendsgame/src/components/GameScreen.js @@ -1,5 +1,6 @@ import React, {Component} from 'react'; import UserList from './UserList'; +import WordInput from './wordInput'; export default class GameScreen extends Component{ constructor(props){ @@ -23,7 +24,10 @@ export default class GameScreen extends Component{ render(){ return( - +
+ + +
) }; } diff --git a/googletrendsgame/src/components/RoomListItem.js b/googletrendsgame/src/components/RoomListItem.js index d47a65f..b39ae8b 100644 --- a/googletrendsgame/src/components/RoomListItem.js +++ b/googletrendsgame/src/components/RoomListItem.js @@ -39,7 +39,7 @@ render(){

{this.props.occupancy}/{this.props.capacity}

Private
- + ) } diff --git a/googletrendsgame/src/components/activeButton.js b/googletrendsgame/src/components/activeButton.js index e4577d9..fcafd12 100644 --- a/googletrendsgame/src/components/activeButton.js +++ b/googletrendsgame/src/components/activeButton.js @@ -26,6 +26,16 @@ export default class activeButton extends Component { ) } + case 'inputWord': + if(this.props.input != '' && this.props.input <= 20){ + return( + + ) + } else { + return( + + ) + } } } diff --git a/googletrendsgame/src/components/createRoomInput.js b/googletrendsgame/src/components/createRoomInput.js index 0e1c296..dcc90be 100644 --- a/googletrendsgame/src/components/createRoomInput.js +++ b/googletrendsgame/src/components/createRoomInput.js @@ -25,7 +25,7 @@ export default class CreateRoomInput extends Component { sendRoomData(event){ event.preventDefault(); - + console.log("sendRoomData called"); this.props.socket.emit('createRoom', {password: this.state.passwordFieldValue, capacity: this.state.capacityFieldValue}); this.setState({ passwordFieldValue: '', capacityFieldValue: '' }); this.props.socket.emit('joinRoom', {}) diff --git a/googletrendsgame/src/components/wordInput.js b/googletrendsgame/src/components/wordInput.js index 4a72751..30451db 100644 --- a/googletrendsgame/src/components/wordInput.js +++ b/googletrendsgame/src/components/wordInput.js @@ -1,12 +1,35 @@ import React, {Component} from 'react'; +import ActiveButton from './activeButton'; -class wordInput extends Component { +export default class wordInput extends Component { constructor(props){ super(props); this.state={fieldValue:''} this.onInputChange = this.onInputChange.bind(this); - this.onInputChange + this.onSubmit = this.onSubmit.bind(this); + } + + onInputChange(event){ + console.log(event.target.value) + this.setState({ fieldValue: event.target.value }); + } + + onSubmit(event){ + event.preventDefault(); + console.log(this.state.fieldValue); + this.props.socket.emit('submitWord', this.state.fieldValue); + } + + render() { + return( +
+ + + + +
+ ) } }