From 6b7d46a56f1769b67a3e69dfbf2716aee3ffa5b1 Mon Sep 17 00:00:00 2001
From: Heather Izumi
Date: Tue, 18 Jun 2019 14:17:48 -0700
Subject: [PATCH 1/9] starting PlayerSubmissionForm
---
src/components/Game.js | 16 +++++++--
src/components/PlayerSubmissionForm.js | 48 ++++++++++++++++++++++++--
src/components/RecentSubmission.js | 1 +
3 files changed, 59 insertions(+), 6 deletions(-)
diff --git a/src/components/Game.js b/src/components/Game.js
index e99f985a..c7fd1ab8 100644
--- a/src/components/Game.js
+++ b/src/components/Game.js
@@ -6,11 +6,19 @@ import RecentSubmission from './RecentSubmission';
class Game extends Component {
+
constructor(props) {
super(props);
+
+ this.state = {
+ recentLine: 'test',
+ poem: [],
+
+ }
}
render() {
+ const {recentLine, poem} = this.state;
const exampleFormat = FIELDS.map((field) => {
if (field.key) {
@@ -29,14 +37,16 @@ class Game extends Component {
Please follow the following format for your poetry submission:
- { exampleFormat }
+ {exampleFormat}
-
+
-
+
);
diff --git a/src/components/PlayerSubmissionForm.js b/src/components/PlayerSubmissionForm.js
index 1de05095..84620490 100644
--- a/src/components/PlayerSubmissionForm.js
+++ b/src/components/PlayerSubmissionForm.js
@@ -9,6 +9,8 @@ class PlayerSubmissionForm extends Component {
render() {
+ const { adjective1, noun1, adverb, verb, adjective2, noun2} = this.state;
+
return (
Player Submission Form for Player #{ }
@@ -16,10 +18,50 @@ class PlayerSubmissionForm extends Component {
);
From d71bed3e4ebd1bb1d5f21fb1b2006e1126268da6 Mon Sep 17 00:00:00 2001
From: Heather Izumi
Date: Wed, 19 Jun 2019 15:40:31 -0700
Subject: [PATCH 8/9] Added css to PlayerSubmissionForm and updated conditional
rendering of RecentSubmission
---
src/components/Game.js | 2 +-
src/components/PlayerSubmissionForm.css | 5 +++++
src/components/PlayerSubmissionForm.js | 29 +++++++++++++++++++++----
3 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/components/Game.js b/src/components/Game.js
index 3c73936b..d30435c2 100644
--- a/src/components/Game.js
+++ b/src/components/Game.js
@@ -65,7 +65,7 @@ class Game extends Component {
{exampleFormat}
- {(!finalDisplay && player < 1) && }
{!finalDisplay && {
+ return this.validations[fieldName].test(this.state[fieldName]);
+ }
+
onChangeHandler = (event) => {
const field = {}
@@ -49,6 +62,8 @@ class PlayerSubmissionForm extends Component {
});
}
+
+
render() {
const { adjective1, noun1, adverb, verb, adjective2, noun2 } = this.state;
@@ -69,14 +84,16 @@ class PlayerSubmissionForm extends Component {
size='10'
value={adjective1}
onChange={this.onChangeHandler}
+ className={this.fieldValid('adjective1') ? 'valid' : 'PlayerSubmissionFormt__input--invalid'}
/>
the
@@ -102,6 +121,7 @@ class PlayerSubmissionForm extends Component {
size='10'
value={adjective2}
onChange={this.onChangeHandler}
+ className={this.fieldValid('adjective2') ? 'valid' : 'PlayerSubmissionFormt__input--invalid'}
/>
-
-
-
+
+
+
);
From bb562383ada4f4cdb4363f11cf9f43121c1af692 Mon Sep 17 00:00:00 2001
From: Heather Izumi
Date: Wed, 19 Jun 2019 16:01:08 -0700
Subject: [PATCH 9/9] added PropTypes to components
---
src/components/FinalPoem.js | 8 ++++++++
src/components/Game.js | 4 ----
src/components/PlayerSubmissionForm.js | 7 +++++++
src/components/RecentSubmission.js | 5 +++++
4 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/components/FinalPoem.js b/src/components/FinalPoem.js
index afd0fc84..4824742d 100644
--- a/src/components/FinalPoem.js
+++ b/src/components/FinalPoem.js
@@ -1,5 +1,6 @@
import React from 'react';
import './FinalPoem.css';
+import PropTypes from 'prop-types';
const FinalPoem = (props) => {
@@ -33,4 +34,11 @@ const FinalPoem = (props) => {
);
}
+FinalPoem.propTypes = {
+ finalPoem: PropTypes.array.isRequired,
+ onShowPoemCallback: PropTypes.func.isRequired,
+ display: PropTypes.bool.isRequired,
+};
+
+
export default FinalPoem;
diff --git a/src/components/Game.js b/src/components/Game.js
index d30435c2..7444e59b 100644
--- a/src/components/Game.js
+++ b/src/components/Game.js
@@ -33,13 +33,9 @@ class Game extends Component {
}
onShowPoem = () => {
- console.log(`I am in show poem before: ${this.state.finalDisplay}` );
-
this.setState({
finalDisplay: true
})
-
- console.log(`I am in show poem after: ${this.state.finalDisplay}` );
}
render() {
diff --git a/src/components/PlayerSubmissionForm.js b/src/components/PlayerSubmissionForm.js
index 61865ae7..e7bf25e2 100644
--- a/src/components/PlayerSubmissionForm.js
+++ b/src/components/PlayerSubmissionForm.js
@@ -1,5 +1,6 @@
import React, { Component } from 'react';
import './PlayerSubmissionForm.css';
+import PropTypes from 'prop-types';
class PlayerSubmissionForm extends Component {
@@ -143,4 +144,10 @@ class PlayerSubmissionForm extends Component {
}
}
+PlayerSubmissionForm.propTypes = {
+ onSubmitLineCallback: PropTypes.func.isRequired,
+ playerNumber: PropTypes.number.isRequired,
+};
+
+
export default PlayerSubmissionForm;
diff --git a/src/components/RecentSubmission.js b/src/components/RecentSubmission.js
index 063b68a1..ac8d6400 100644
--- a/src/components/RecentSubmission.js
+++ b/src/components/RecentSubmission.js
@@ -1,5 +1,6 @@
import React from 'react';
import './RecentSubmission.css';
+import PropTypes from 'prop-types';
const RecentSubmission = (props) => {
return (
@@ -11,4 +12,8 @@ const RecentSubmission = (props) => {
);
}
+RecentSubmission.propTypes = {
+ line: PropTypes.string.isRequired,
+};
+
export default RecentSubmission;