From 82f942df548781f0f1087718decfb6ea3d9be7e9 Mon Sep 17 00:00:00 2001
From: Morgan Schuler
Date: Thu, 12 Dec 2019 19:30:31 -0800
Subject: [PATCH 1/5] completed wave 1
---
src/components/Game.js | 79 +++++++++++++----------
src/components/PlayerSubmissionForm.js | 87 ++++++++++++++++++++++++--
src/components/RecentSubmission.js | 20 ++++++
3 files changed, 149 insertions(+), 37 deletions(-)
diff --git a/src/components/Game.js b/src/components/Game.js
index e99f985a..11e2a881 100644
--- a/src/components/Game.js
+++ b/src/components/Game.js
@@ -4,14 +4,57 @@ import PlayerSubmissionForm from './PlayerSubmissionForm';
import FinalPoem from './FinalPoem';
import RecentSubmission from './RecentSubmission';
+const FIELDS = [
+ "The",
+ {
+ key: 'adj1',
+ placeholder: 'adjective',
+ },
+ {
+ key: 'noun1',
+ placeholder: 'noun',
+ },
+ {
+ key: 'adv',
+ placeholder: 'adverb',
+ },
+ {
+ key: 'verb',
+ placeholder: 'verb',
+ },
+ "the",
+ {
+ key: 'adj2',
+ placeholder: 'adjective',
+ },
+ {
+ key: 'noun2',
+ placeholder: 'noun',
+ },
+ ".",
+];
+
class Game extends Component {
constructor(props) {
super(props);
+ this.state = {
+ poem: []
+ };
}
+ addLineToPoem = (poemLine) => {
+ this.setState((prevState) => ({
+ poem: [
+ ...prevState.poem,
+ poemLine
+ ]
+ }));
+ }
+ // ... is saying: in this spot on the code, take all the elements on the array and add them one by one
+ // prevState(variable name) will always give you the most current version of state
render() {
-
+ console.log(this.state.poem)
const exampleFormat = FIELDS.map((field) => {
if (field.key) {
return field.placeholder;
@@ -32,9 +75,9 @@ class Game extends Component {
{ exampleFormat }
-
+
-
+
@@ -43,34 +86,4 @@ class Game extends Component {
}
}
-const FIELDS = [
- "The",
- {
- key: 'adj1',
- placeholder: 'adjective',
- },
- {
- key: 'noun1',
- placeholder: 'noun',
- },
- {
- key: 'adv',
- placeholder: 'adverb',
- },
- {
- key: 'verb',
- placeholder: 'verb',
- },
- "the",
- {
- key: 'adj2',
- placeholder: 'adjective',
- },
- {
- key: 'noun2',
- placeholder: 'noun',
- },
- ".",
-];
-
export default Game;
diff --git a/src/components/PlayerSubmissionForm.js b/src/components/PlayerSubmissionForm.js
index 1de05095..4b1fa3ba 100644
--- a/src/components/PlayerSubmissionForm.js
+++ b/src/components/PlayerSubmissionForm.js
@@ -5,13 +5,49 @@ class PlayerSubmissionForm extends Component {
constructor(props) {
super(props);
+ this.state = {
+ adjective1: "",
+ noun1: "",
+ adverb: "",
+ verb: "",
+ adjective2: "",
+ noun2: ""
+ };
+ }
+
+ handleChange = (event) => {
+ this.setState({ [event.target.name]: event.target.value });
+ }
+
+ handleClick = (event) => {
+ const {
+ adjective1,
+ noun1,
+ adverb,
+ verb,
+ adjective2,
+ noun2
+ } = this.state;
+ const poemLine = `The ${adjective1} ${noun1} ${adverb} ${verb} the ${adjective2} ${noun2}.`;
+
+ event.preventDefault();
+
+ this.props.onSubmitLine(poemLine);
+ this.setState({
+ adjective1: "",
+ noun1: "",
+ adverb: "",
+ verb: "",
+ adjective2: "",
+ noun2: ""
+ });
}
render() {
return (
-
Player Submission Form for Player #{ }
+ Player Submission Form for Player #{this.props.currentPlayer}
-
+
diff --git a/src/components/RecentSubmission.js b/src/components/RecentSubmission.js
index 663da34b..31aa02ee 100644
--- a/src/components/RecentSubmission.js
+++ b/src/components/RecentSubmission.js
@@ -1,7 +1,19 @@
import React from 'react';
+import PropTypes from 'prop-types';
import './RecentSubmission.css';
const RecentSubmission = (props) => {
+
+ // const lines = props.lines.map((line) => {
+ // return (
+ //
+ // )
+ // });
+
return (
The Most Recent Submission
@@ -10,4 +22,12 @@ const RecentSubmission = (props) => {
);
}
+RecentSubmission.propTypes = {
+ lines: PropTypes.array,
+ handleChange: PropTypes.func,
+ onSelectPet: PropTypes.func
+}
+
export default RecentSubmission;
+
+
From c8ca1aade37224324487fea11138ceea79c94cb7 Mon Sep 17 00:00:00 2001
From: Morgan Schuler
Date: Thu, 12 Dec 2019 22:27:10 -0800
Subject: [PATCH 2/5] added logic for wave 2
---
src/components/FinalPoem.js | 12 +-
src/components/Game.js | 25 +++-
src/components/PlayerSubmissionForm.css | 2 +-
src/components/PlayerSubmissionForm.js | 149 +++++++++++++++++++-----
src/components/RecentSubmission.js | 19 ++-
5 files changed, 152 insertions(+), 55 deletions(-)
diff --git a/src/components/FinalPoem.js b/src/components/FinalPoem.js
index d516184e..a6e7fa75 100644
--- a/src/components/FinalPoem.js
+++ b/src/components/FinalPoem.js
@@ -5,14 +5,18 @@ const FinalPoem = (props) => {
return (
+ {props.showPoem ? (
Final Poem
-
+ {props.poem.map((poemLine, i) => (
+ {poemLine}
+ ))}
-
-
);
}
diff --git a/src/components/Game.js b/src/components/Game.js
index 11e2a881..a4fa5f28 100644
--- a/src/components/Game.js
+++ b/src/components/Game.js
@@ -39,7 +39,8 @@ class Game extends Component {
constructor(props) {
super(props);
this.state = {
- poem: []
+ poem: [],
+ showPoem: false
};
}
@@ -53,7 +54,11 @@ class Game extends Component {
}
// ... is saying: in this spot on the code, take all the elements on the array and add them one by one
// prevState(variable name) will always give you the most current version of state
- render() {
+ handleDisplayPoem = () => {
+ this.setState({ showPoem: true });
+ }
+
+ render() {
console.log(this.state.poem)
const exampleFormat = FIELDS.map((field) => {
if (field.key) {
@@ -75,11 +80,19 @@ class Game extends Component {
{ exampleFormat }
-
+ {!this.state.showPoem && (
+ <>
-
-
-
+
+
+
+ >
+ )}
+
);
diff --git a/src/components/PlayerSubmissionForm.css b/src/components/PlayerSubmissionForm.css
index 7cded5d9..6d6f98eb 100644
--- a/src/components/PlayerSubmissionForm.css
+++ b/src/components/PlayerSubmissionForm.css
@@ -31,7 +31,7 @@
background-color: tomato;
}
-.PlayerSubmissionFormt__input--invalid {
+.PlayerSubmissionForm__input--invalid {
background-color: #FFE9E9;
}
diff --git a/src/components/PlayerSubmissionForm.js b/src/components/PlayerSubmissionForm.js
index 4b1fa3ba..523c9d3a 100644
--- a/src/components/PlayerSubmissionForm.js
+++ b/src/components/PlayerSubmissionForm.js
@@ -4,44 +4,104 @@ import './PlayerSubmissionForm.css';
class PlayerSubmissionForm extends Component {
constructor(props) {
- super(props);
+ super(props); super(props);
this.state = {
- adjective1: "",
- noun1: "",
- adverb: "",
- verb: "",
- adjective2: "",
- noun2: ""
+ adjectiveFirst: '',
+ nounFirst: '',
+ adverb: '',
+ verb: '',
+ adjectiveSecond: '',
+ nounSecond: ''
};
- }
+ }
+
handleChange = (event) => {
- this.setState({ [event.target.name]: event.target.value });
- }
+ const newState = {};
+ newState[event.target.name] = event.target.value;
+ this.setState(newState);
+ console.log(this.state);
+ };
handleClick = (event) => {
- const {
- adjective1,
- noun1,
- adverb,
- verb,
- adjective2,
- noun2
- } = this.state;
- const poemLine = `The ${adjective1} ${noun1} ${adverb} ${verb} the ${adjective2} ${noun2}.`;
-
event.preventDefault();
+ const sentence = this.props.fields.reduce((acc, field, i) => {
+ if (field.key) {
+ return `${acc} ${this.state[field.name].trim()}`;
+ }
+ else {
+ if (i > 0 && i < (this.props.fields.length - 1))
+ return `${acc} ${field}`;
+ }
+ return `${acc}${field}`;
+ }
+ }, '');
+
+ this.props.onSubmitLine(sentence);
- this.props.onSubmitLine(poemLine);
this.setState({
- adjective1: "",
- noun1: "",
- adverb: "",
- verb: "",
- adjective2: "",
- noun2: ""
+ adjectiveFirst: '',
+ nounFirst: '',
+ adverb: '',
+ verb: '',
+ adjectiveSecond: '',
+ nounSecond: ''
});
- }
+ };
+
+
+
+// constructor(props) {
+// super(props);
+// this.state = {
+// adjective1: "",
+// noun1: "",
+// adverb: "",
+// verb: "",
+// adjective2: "",
+// noun2: ""
+// };
+// }
+
+// handleChange = (event) => {
+// this.setState({ [event.target.name]: event.target.value });
+// }
+
+// handleClick = (event) => {
+// event.preventDefault();
+
+// const sentence = this.props.fields.reduce((acc, field, i) => {
+// if (field.key) {
+// return `${acc} $this.state[field.name].trim()]`;
+// }
+// else {
+// if (i > 0 && i < (this.props.fields.length - 1))
+
+// return `${acc} ${field}`;
+// }
+// return `${acc}${field}`;
+// }
+// }, '');
+
+// // adjective1,
+// // noun1,
+// // adverb,
+// // verb,
+// // adjective2,
+// // noun2
+// // } = this.state;
+// // const poemLine = `The ${adjective1} ${noun1} ${adverb} ${verb} the ${adjective2} ${noun2}.`;
+
+// this.props.onSubmitLine(poemLine);
+// this.setState({
+// adjective1: "",
+// noun1: "",
+// adverb: "",
+// verb: "",
+// adjective2: "",
+// noun2: ""
+// });
+//
render() {
@@ -55,14 +115,34 @@ class PlayerSubmissionForm extends Component {
{
// Put your form inputs here... We've put in one below as an example
- }
- The
+ this.props.fields.map((field, i) => {
+ if (field.key) {
+ return (
+
+ );
+ }
+ else {
+ return {field} ;}
+ })
+ }
+
+
+ {/* /* The
the
- .
+ . */}
-
+ {/* */}
diff --git a/src/components/RecentSubmission.js b/src/components/RecentSubmission.js
index 31aa02ee..9a3e9596 100644
--- a/src/components/RecentSubmission.js
+++ b/src/components/RecentSubmission.js
@@ -3,21 +3,16 @@ import PropTypes from 'prop-types';
import './RecentSubmission.css';
const RecentSubmission = (props) => {
-
- // const lines = props.lines.map((line) => {
- // return (
- //
- // )
- // });
-
return (
+ {props.lastLine && (
+ <>
+
+
The Most Recent Submission
-
{ }
+
{props.lastLine}
+ >
+ )}
);
}
From d86865702ac4d2e0b6fd2a810065c0b6e1979c41 Mon Sep 17 00:00:00 2001
From: Morgan Schuler
Date: Thu, 12 Dec 2019 23:35:22 -0800
Subject: [PATCH 3/5] updated display poem line section
---
src/components/Game.js | 8 +++-
src/components/PlayerSubmissionForm.css | 4 ++
src/components/PlayerSubmissionForm.js | 58 +------------------------
3 files changed, 13 insertions(+), 57 deletions(-)
diff --git a/src/components/Game.js b/src/components/Game.js
index a4fa5f28..2b05407f 100644
--- a/src/components/Game.js
+++ b/src/components/Game.js
@@ -9,27 +9,33 @@ const FIELDS = [
{
key: 'adj1',
placeholder: 'adjective',
+ name: 'adjectiveFirst',
},
{
key: 'noun1',
placeholder: 'noun',
+ name: 'nounFirst'
},
{
key: 'adv',
placeholder: 'adverb',
+ name: 'adverb'
},
{
key: 'verb',
placeholder: 'verb',
+ name: 'verb'
},
"the",
{
key: 'adj2',
placeholder: 'adjective',
+ name: 'adjectiveSecond'
},
{
key: 'noun2',
placeholder: 'noun',
+ name: 'nounSecond'
},
".",
];
@@ -83,7 +89,7 @@ class Game extends Component {
{!this.state.showPoem && (
<>
-
+
>
diff --git a/src/components/PlayerSubmissionForm.css b/src/components/PlayerSubmissionForm.css
index 6d6f98eb..fce16195 100644
--- a/src/components/PlayerSubmissionForm.css
+++ b/src/components/PlayerSubmissionForm.css
@@ -38,3 +38,7 @@
.PlayerSubmissionForm__input--invalid::placeholder {
color: black;
}
+
+.red {
+ background-color: red
+}
\ No newline at end of file
diff --git a/src/components/PlayerSubmissionForm.js b/src/components/PlayerSubmissionForm.js
index 523c9d3a..7b9821b6 100644
--- a/src/components/PlayerSubmissionForm.js
+++ b/src/components/PlayerSubmissionForm.js
@@ -13,7 +13,7 @@ class PlayerSubmissionForm extends Component {
adjectiveSecond: '',
nounSecond: ''
};
- }
+ }
handleChange = (event) => {
@@ -30,7 +30,7 @@ class PlayerSubmissionForm extends Component {
return `${acc} ${this.state[field.name].trim()}`;
}
else {
- if (i > 0 && i < (this.props.fields.length - 1))
+ if (i > 0 && i < (this.props.fields.length - 1)) {
return `${acc} ${field}`;
}
return `${acc}${field}`;
@@ -49,60 +49,6 @@ class PlayerSubmissionForm extends Component {
});
};
-
-
-// constructor(props) {
-// super(props);
-// this.state = {
-// adjective1: "",
-// noun1: "",
-// adverb: "",
-// verb: "",
-// adjective2: "",
-// noun2: ""
-// };
-// }
-
-// handleChange = (event) => {
-// this.setState({ [event.target.name]: event.target.value });
-// }
-
-// handleClick = (event) => {
-// event.preventDefault();
-
-// const sentence = this.props.fields.reduce((acc, field, i) => {
-// if (field.key) {
-// return `${acc} $this.state[field.name].trim()]`;
-// }
-// else {
-// if (i > 0 && i < (this.props.fields.length - 1))
-
-// return `${acc} ${field}`;
-// }
-// return `${acc}${field}`;
-// }
-// }, '');
-
-// // adjective1,
-// // noun1,
-// // adverb,
-// // verb,
-// // adjective2,
-// // noun2
-// // } = this.state;
-// // const poemLine = `The ${adjective1} ${noun1} ${adverb} ${verb} the ${adjective2} ${noun2}.`;
-
-// this.props.onSubmitLine(poemLine);
-// this.setState({
-// adjective1: "",
-// noun1: "",
-// adverb: "",
-// verb: "",
-// adjective2: "",
-// noun2: ""
-// });
-//
-
render() {
return (
From 56e615abb8c3ea4adb09a6339f53d9b6f7340d48 Mon Sep 17 00:00:00 2001
From: Morgan Schuler
Date: Fri, 13 Dec 2019 13:54:42 -0800
Subject: [PATCH 4/5] adjustments to plater submission form
---
src/components/PlayerSubmissionForm.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/components/PlayerSubmissionForm.js b/src/components/PlayerSubmissionForm.js
index 7b9821b6..a33cc85f 100644
--- a/src/components/PlayerSubmissionForm.js
+++ b/src/components/PlayerSubmissionForm.js
@@ -13,8 +13,7 @@ class PlayerSubmissionForm extends Component {
adjectiveSecond: '',
nounSecond: ''
};
- }
-
+ }
handleChange = (event) => {
const newState = {};
From 380a281284f82e4e047936174d821d6779d34fa4 Mon Sep 17 00:00:00 2001
From: Morgan Schuler
Date: Fri, 13 Dec 2019 13:56:04 -0800
Subject: [PATCH 5/5] fixed dynamic form
---
src/components/PlayerSubmissionForm.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/PlayerSubmissionForm.js b/src/components/PlayerSubmissionForm.js
index a33cc85f..edf92838 100644
--- a/src/components/PlayerSubmissionForm.js
+++ b/src/components/PlayerSubmissionForm.js
@@ -13,7 +13,7 @@ class PlayerSubmissionForm extends Component {
adjectiveSecond: '',
nounSecond: ''
};
- }
+ }
handleChange = (event) => {
const newState = {};