diff --git a/src/components/FinalPoem.css b/src/components/FinalPoem.css
index 67dda943..c9c2f7df 100644
--- a/src/components/FinalPoem.css
+++ b/src/components/FinalPoem.css
@@ -13,7 +13,7 @@
}
.FinalPoem__reveal-btn:hover {
- background-color: tomato;
+ background-color: rgb(54, 236, 197);
}
.FinalPoem__poem {
diff --git a/src/components/FinalPoem.js b/src/components/FinalPoem.js
index d516184e..61811e49 100644
--- a/src/components/FinalPoem.js
+++ b/src/components/FinalPoem.js
@@ -1,20 +1,53 @@
import React from 'react';
import './FinalPoem.css';
+import PropTypes from 'prop-types';
const FinalPoem = (props) => {
+ console.log(props)
+
+ // Each submission in the final poem section on a different line or paragraph.
+ const showingPoemLines = props.poems.map((poem, i) => {
+ return (
+
{poem}
+ )
+ });
+
+ // It shows each part depends on playing state.
+
return (
-
-
Final Poem
+ {
+ // props.playing || === !props.playing
+ // It shows final poem if playing is false.
+ props.playing || (
+
+
Final Poem
+ {/* See all of the submissions of poetry lines in the section named "Final Poem". */}
+ {showingPoemLines}
+
+ )
+ }
+ {
+ // It shows the button if playing is true.
+ // Means the game is not over.
+ props.playing && (
+
+ {/* A button to click to finalize the poem and reveal the entire final poem,
+ it does not show the previous lines until the poem is finished. */}
+
+
+ )
+ }
-
-
-
-
-
);
}
+FinalPoem.propTypes = {
+ poems: PropTypes.array.isRequired,
+ playing: PropTypes.bool.isRequired,
+ onGameOverCallback: PropTypes.func.isRequired
+};
+
export default FinalPoem;
diff --git a/src/components/Game.css b/src/components/Game.css
index 8ff58e42..b85331d2 100644
--- a/src/components/Game.css
+++ b/src/components/Game.css
@@ -2,3 +2,11 @@
text-align: center;
font-style: italic;
}
+.btn {
+ display: flex;
+ justify-content: space-around;
+}
+
+h2 {
+ padding: 20px;
+}
diff --git a/src/components/Game.js b/src/components/Game.js
index ad27105b..3589fc15 100644
--- a/src/components/Game.js
+++ b/src/components/Game.js
@@ -4,7 +4,17 @@ import PlayerSubmissionForm from './PlayerSubmissionForm';
import FinalPoem from './FinalPoem';
import RecentSubmission from './RecentSubmission';
+
const Game = () => {
+
+ // data of form submission, so that the Game component keeps track of all of the submissions.
+
+ const [poems, setPoemPieces] = useState([]);
+ // SetPlaying false when the game is over.
+ const [playing, setPlaying] = useState(true);
+ // State to add up 1 to the next player.
+ const [player, setPlayer] = useState(1)
+
const exampleFormat = FIELDS.map((field) => {
if (field.key) {
return field.placeholder;
@@ -13,24 +23,63 @@ const Game = () => {
}
}).join(" ");
+ // Function to start over the game! Anytime
+ const resetGame = () => {
+ setPoemPieces([]);
+ setPlaying(true);
+ setPlayer(1);
+ }
+
+
+ // CallBack func to get the info from the form.
+ const addPoemPiece = (poem) => {
+
+ const newPoemPiece = [...poems];
+ console.log(poem)
+
+ newPoemPiece.push(poem)
+ setPlayer(player + 1)
+ setPoemPieces(newPoemPiece);
+ }
+
+ const gameOver = () => {
+ setPlaying(false);
+ }
+
return (
Game
+
+
+
Each player should take turns filling out and submitting the form below. Each turn should be done individually and in secret! Take inspiration from the revealed recent submission. When all players are finished, click the final button on the bottom to reveal the entire poem.
Please follow the following format for your poetry submission:
+ )
+ };
+
+ // It returns false if there is not poems within the array.
+ const shouldDisplay = () => {
+ if (props.poems.length === 0) {
+ return false;
+ } else {
+ return props.playing;
+ }
+ }
+
return (
-
-
The Most Recent Submission
-
{ }
-
+ // If the result of sholdDisplay is true -> Display the Most Recent.
+ // React does not render anything if the return of our func is false.
+ shouldDisplay() && (
+
+ {/* See only the most recent submission of poetry in the section */}
+