From 40b51de6e5662ad2aff57527f41660f6826f1316 Mon Sep 17 00:00:00 2001
From: Jessica Stone
Date: Tue, 21 Apr 2020 17:38:55 -0700
Subject: [PATCH 01/23] add inputs and event listeners
---
src/components/PlayerSubmissionForm.js | 103 +++++++++++++++++++++++--
1 file changed, 97 insertions(+), 6 deletions(-)
diff --git a/src/components/PlayerSubmissionForm.js b/src/components/PlayerSubmissionForm.js
index ba19e6ef..80df696f 100644
--- a/src/components/PlayerSubmissionForm.js
+++ b/src/components/PlayerSubmissionForm.js
@@ -1,21 +1,112 @@
import React, { useState } from 'react';
import './PlayerSubmissionForm.css';
-const PlayerSubmissionForm = () => {
- return (
+const PlayerSubmissionForm = (props) => {
+
+ // User Stories
+ // Game component has the data of my submission, so that the Game component keeps track of all of the submissions
+ // As a player going after the first player, I want to have a cleared, reset form with no text in the input elements
+ // As the third player, I want to see that the header for the submission form is "Player Submission Form for Player #3"
+
+ // Don't be shy about making all of the pieces of props or state that you've determined you need!
+
+ const [sentence, setSentence] = useState({
+ adjective1: '',
+ noun1: '',
+ adverb: '',
+ verb: '',
+ adjective2: '',
+ noun2: '',
+ });
+
+ const onInputChange = (event) => {
+ console.log(`Changing field ${ event.target.name } to ${ event.target.value }`);
+ // Duplicate user into new object
+ const newSentence = {
+ ...sentence,
+ }
+
+ newSentence[event.target.name] = event.target.value;
+ setSentence(newSentence);
+ }
+
+ const onSubmitLine = (event) => {
+ // prevents form from submitting by default
+ event.preventDefault();
+
+ // prevent user from submitting empty fields
+ if (sentence.adjective1 !== '') {
+ //send that data back up to App
+ props.onSubmit(sentence);
+
+ setSentence({
+ adjective1: '',
+ noun1: '',
+ adverb: '',
+ verb: '',
+ adjective2: '',
+ noun2: '',
+ })
+ }
+ }
+
+
+ return (
-
Player Submission Form for Player #{ }
+
Player Submission Form for Player #{ props.player }
-
+
-
+
);
From e6ab498611b02ffddfef893d1d384a6acdf12968 Mon Sep 17 00:00:00 2001
From: Jessica Stone
Date: Tue, 21 Apr 2020 18:06:53 -0700
Subject: [PATCH 08/23] remove wave 1 comments
---
src/components/PlayerSubmissionForm.js | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/src/components/PlayerSubmissionForm.js b/src/components/PlayerSubmissionForm.js
index 11521e87..5f173f68 100644
--- a/src/components/PlayerSubmissionForm.js
+++ b/src/components/PlayerSubmissionForm.js
@@ -3,13 +3,6 @@ import './PlayerSubmissionForm.css';
const PlayerSubmissionForm = (props) => {
- // User Stories
- // Game component has the data of my submission, so that the Game component keeps track of all of the submissions
- // As a player going after the first player, I want to have a cleared, reset form with no text in the input elements
- // As the third player, I want to see that the header for the submission form is "Player Submission Form for Player #3"
-
- // Don't be shy about making all of the pieces of props or state that you've determined you need!
-
const [sentence, setSentence] = useState({
adjective1: '',
noun1: '',
@@ -20,8 +13,6 @@ const PlayerSubmissionForm = (props) => {
});
const onInputChange = (event) => {
- console.log(`Changing field ${ event.target.name } to ${ event.target.value }`);
- // Duplicate user into new object
const newSentence = {
...sentence,
}
@@ -59,9 +50,6 @@ const PlayerSubmissionForm = (props) => {
- {
- // Put your form inputs here... We've put in one below as an example
- }
The
Date: Tue, 21 Apr 2020 18:42:55 -0700
Subject: [PATCH 09/23] change structure of Game to keep track of all
submissions as objects
---
src/components/Game.js | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/src/components/Game.js b/src/components/Game.js
index 51447bd6..ddd5eb54 100644
--- a/src/components/Game.js
+++ b/src/components/Game.js
@@ -12,24 +12,28 @@ const Game = () => {
return field;
}
}).join(" ");
-
- const [player, setPlayer] = useState(1);
- const [recentSubmission, setRecentSubmission] = useState('');
- const [finalPoem, setFinalPoem] = useState('');
- // on reset
- // setPlayer(1)
+ const submissions = [];
+ const [player, setPlayer] = useState(1);
+ const [submissionsList, setsubmissionsList] = useState(submissions);
+
- const onPlayerSubmissionCallback = (submission) => {
- const sentence = "The " + submission.adjective1 + " " + submission.noun1 + " " + submission.adverb + " " + submission.verb + " the " + submission.adjective2 + " " + submission.noun2;
+ const onPlayerSubmissionCallback = (playerSubmission) => {
+ // const sentence = "The " + submission.adjective1 + " " + submission.noun1 + " " + submission.adverb + " " + submission.verb + " the " + submission.adjective2 + " " + submission.noun2;
+ // make a copy of submissionsList
+ const newSubmissions = [...submissionsList];
- setRecentSubmission(sentence);
+ // add playerSubmission to submissions list
+ newSubmissions.push(playerSubmission);
+ // update state of submissionsList to new list
+ setsubmissionsList(newSubmissions);
// increment player
setPlayer(player + 1);
- // add recent submission to final poem
- setFinalPoem(finalPoem + sentence);
}
+ // on reset
+ // setPlayer(1)
+
return (
+ {/* As players who have submitted one or more lines, I want to see all of the submissions of poetry lines in the section named "Final Poem".
+ As a player, I want to see each submission in the final poem section on a different line or paragraph, so that it looks more like a structured poem. */}
From 9ddbaa659425ff0237528cc9890bb99e63912a28 Mon Sep 17 00:00:00 2001
From: Jessica Stone
Date: Tue, 21 Apr 2020 19:01:06 -0700
Subject: [PATCH 11/23] change FinalPoem props name from finalPoem to
submissions
---
src/components/Game.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/Game.js b/src/components/Game.js
index ddd5eb54..677be119 100644
--- a/src/components/Game.js
+++ b/src/components/Game.js
@@ -50,7 +50,7 @@ const Game = () => {
-
+
@@ -18,6 +24,7 @@ const FinalPoem = (props) => {
{/* As players who have submitted one or more lines, I want to see all of the submissions of poetry lines in the section named "Final Poem".
As a player, I want to see each submission in the final poem section on a different line or paragraph, so that it looks more like a structured poem. */}
+ {finalPoem}
-
- {/* As players who have submitted one or more lines, I want to see all of the submissions of poetry lines in the section named "Final Poem".
- As a player, I want to see each submission in the final poem section on a different line or paragraph, so that it looks more like a structured poem. */}
- {finalPoem}
-
+ {/* if display is true, show final poem */}
+ { display ?
+
+
Final Poem
+ {finalPoem}
+ :
+ null
+ }
-
+
);
From c7638edc453b2ab511f7bddfc381ea20877f7035 Mon Sep 17 00:00:00 2001
From: Jessica Stone
Date: Wed, 22 Apr 2020 14:39:32 -0700
Subject: [PATCH 14/23] change callback structure to add string instead of
object to submissions array
---
src/components/Game.js | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/components/Game.js b/src/components/Game.js
index 677be119..3d4a295f 100644
--- a/src/components/Game.js
+++ b/src/components/Game.js
@@ -19,12 +19,13 @@ const Game = () => {
const onPlayerSubmissionCallback = (playerSubmission) => {
- // const sentence = "The " + submission.adjective1 + " " + submission.noun1 + " " + submission.adverb + " " + submission.verb + " the " + submission.adjective2 + " " + submission.noun2;
// make a copy of submissionsList
const newSubmissions = [...submissionsList];
-
- // add playerSubmission to submissions list
- newSubmissions.push(playerSubmission);
+
+ // create sentence structure
+ const sentence = "The " + playerSubmission.adjective1 + " " + playerSubmission.noun1 + " " + playerSubmission.adverb + " " + playerSubmission.verb + " the " + playerSubmission.adjective2 + " " + playerSubmission.noun2 + ".";
+
+ newSubmissions.push(sentence);
// update state of submissionsList to new list
setsubmissionsList(newSubmissions);
// increment player
@@ -33,7 +34,7 @@ const Game = () => {
// on reset
// setPlayer(1)
-
+
return (