diff --git a/package-lock.json b/package-lock.json index ed444293..d54bd528 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2769,8 +2769,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -2788,13 +2787,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2807,18 +2804,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -2921,8 +2915,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -2932,7 +2925,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2945,20 +2937,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.3.5", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2975,7 +2964,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3048,8 +3036,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -3059,7 +3046,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3135,8 +3121,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -3166,7 +3151,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3184,7 +3168,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3223,13 +3206,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.3", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -6767,8 +6748,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -6786,13 +6766,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -6805,18 +6783,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -6919,8 +6894,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -6930,7 +6904,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -6943,20 +6916,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.3.5", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -6973,7 +6943,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -7046,8 +7015,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -7057,7 +7025,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -7133,8 +7100,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -7164,7 +7130,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7182,7 +7147,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7221,13 +7185,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.3", - "bundled": true, - "optional": true + "bundled": true } } } diff --git a/src/components/FinalPoem.js b/src/components/FinalPoem.js index d516184e..8d081437 100644 --- a/src/components/FinalPoem.js +++ b/src/components/FinalPoem.js @@ -1,20 +1,31 @@ -import React from 'react'; +import React, { Component } from 'react'; import './FinalPoem.css'; -const FinalPoem = (props) => { - return ( -
-
-

Final Poem

-
+class FinalPoem extends Component { + + reveal = () => { + this.props.submitCallBack() + } + + render() { + const revealButton =
+ + let finalPoem = this.props.poem.map(function(line, i){ + return

{line}

+ }) -
- -
+ let finalContent =

Final Poem

{finalPoem}
+ + const content = this.props.isSubmitted ? finalContent : revealButton + + return ( +
+ {content}
); + } } export default FinalPoem; diff --git a/src/components/Game.js b/src/components/Game.js index e99f985a..862a8e48 100644 --- a/src/components/Game.js +++ b/src/components/Game.js @@ -8,6 +8,27 @@ class Game extends Component { constructor(props) { super(props); + this.state = { + currentPlayer: 1, + poem: [], + updateTurnCallBack: this.updateTurn, + lastLine: "", + isSubmitted: false, + submitCallBack: this.submit + }; + } + + updateTurn = (line) => { + let updatedPlayer = this.state.currentPlayer + 1 + this.setState({ currentPlayer: updatedPlayer }); + this.state.poem.push(line) + const newPoem = this.state.poem + this.setState({poem: newPoem}) + this.setState({lastLine: line}) + } + + submit = () => { + this.setState({isSubmitted: true }) } render() { @@ -20,6 +41,10 @@ class Game extends Component { } }).join(" "); + const recentSubmission = this.state.isSubmitted === false && this.state.currentPlayer > 1 ? : "" + const form = this.state.isSubmitted ? "" : + + return (

Game

@@ -32,11 +57,10 @@ class Game extends Component { { exampleFormat }

- - - + {recentSubmission} + {form} - +
); diff --git a/src/components/PlayerSubmissionForm.js b/src/components/PlayerSubmissionForm.js index 1de05095..09216c4c 100644 --- a/src/components/PlayerSubmissionForm.js +++ b/src/components/PlayerSubmissionForm.js @@ -5,29 +5,111 @@ class PlayerSubmissionForm extends Component { constructor(props) { super(props); + this.state = { + adj1: '', + noun1: '', + adv: '', + verb: '', + adj2: '', + noun2: '' + } + } + + onInputChange = (event) => { + const updatedState = {}; + + const field = event.target.name; + const value = event.target.value; + + if(value !== ""){ + event.target.className = "test" + } + else{ + event.target.className = "PlayerSubmissionFormt__input--invalid" + } + + updatedState[field] = value; + this.setState(updatedState); + + } + + onFormSubmit = (event) => { + event.preventDefault(); + const newLine = `${this.state.adj1} ${this.state.noun1} ${this.state.adv} ${this.state.verb} ${this.state.adj2} ${this.state.noun2}` + this.props.updateTurnCallBack(newLine); + + this.setState({ + adj1: '', + noun1: '', + adv: '', + verb: '', + adj2: '', + noun2: '' + }); } render() { + const initialClass = "PlayerSubmissionFormt__input--invalid" return (
-

Player Submission Form for Player #{ }

+

Player Submission Form for Player #{this.props.id}

-
+
{ // Put your form inputs here... We've put in one below as an example } + The - + className={initialClass} + placeholder="adjective" + name="adj1" + type="text" + value={this.state.adj1} + onChange={this.onInputChange}/> + + + + the + +
- +
diff --git a/src/components/RecentSubmission.js b/src/components/RecentSubmission.js index 663da34b..5464e61b 100644 --- a/src/components/RecentSubmission.js +++ b/src/components/RecentSubmission.js @@ -2,9 +2,11 @@ import React from 'react'; import './RecentSubmission.css'; const RecentSubmission = (props) => { + const lastLine = props.lastLine return (

The Most Recent Submission

+ {lastLine}

{ }

);