diff --git a/src/components/FinalPoem.css b/src/components/FinalPoem.css index 67dda943..36627782 100644 --- a/src/components/FinalPoem.css +++ b/src/components/FinalPoem.css @@ -7,7 +7,7 @@ flex: 0.8; padding: 1rem; - border: 2px black solid; + border: 2px rgb(0, 0, 0) solid; box-shadow: 5px 10px black; transition: 0.25s; } @@ -16,6 +16,19 @@ background-color: tomato; } +.noShow{ + display:none; + +} + +.show{ + font-size: 32px; + background-color: rgb(7, 189, 89); + text-align: center; + margin: 0px 300px; + border-radius: 20px; +} + .FinalPoem__poem { border-bottom: 2px gray dashed; } diff --git a/src/components/FinalPoem.js b/src/components/FinalPoem.js index d516184e..4a94d13a 100644 --- a/src/components/FinalPoem.js +++ b/src/components/FinalPoem.js @@ -1,20 +1,43 @@ -import React from 'react'; +import React, { useState } from 'react'; import './FinalPoem.css'; +import PropTypes from 'prop-types'; const FinalPoem = (props) => { + const [show, setShow] = useState(false) + + const onButtonClick = () => { + setShow(true) + + props.componentDissapear() + }; + + const lineComponents = props.props.map((line) => { + return ( +

+ {line} +

+ ); + }); return (

Final Poem

-
-
- +
+
+

+ {lineComponents} +

); } +FinalPoem.propTypes = { + props: PropTypes.array, + componentDissapear: PropTypes.func.isRequired, +}; + export default FinalPoem; diff --git a/src/components/Game.css b/src/components/Game.css index 8ff58e42..e6825de6 100644 --- a/src/components/Game.css +++ b/src/components/Game.css @@ -2,3 +2,7 @@ text-align: center; font-style: italic; } + +.noShow{ + display:none; +} \ No newline at end of file diff --git a/src/components/Game.js b/src/components/Game.js index ad27105b..dd659cc5 100644 --- a/src/components/Game.js +++ b/src/components/Game.js @@ -4,7 +4,19 @@ import PlayerSubmissionForm from './PlayerSubmissionForm'; import FinalPoem from './FinalPoem'; import RecentSubmission from './RecentSubmission'; +let recent = ""; +let poemLines = []; + const Game = () => { + const [poemList, setPoemList] = useState([]); + const [player, setPlayer] = useState(1); + + const [show, setShow] = useState(true) + + const componentDissapear = () => { + setShow(false) + }; + const exampleFormat = FIELDS.map((field) => { if (field.key) { return field.placeholder; @@ -13,6 +25,19 @@ const Game = () => { } }).join(" "); + const addLine = (line) => { + const newPoemList = [...poemList]; + newPoemList.push({ ...line + }); + + setPoemList(newPoemList); + + setPlayer(player + 1) + + recent = (Object.values(line)).join(" "); + poemLines.push(recent); + } + return (

Game

@@ -25,11 +50,11 @@ const Game = () => { { exampleFormat }

- + - + - +
); diff --git a/src/components/PlayerSubmissionForm.css b/src/components/PlayerSubmissionForm.css index 7cded5d9..a54fbef9 100644 --- a/src/components/PlayerSubmissionForm.css +++ b/src/components/PlayerSubmissionForm.css @@ -10,7 +10,11 @@ display: flex; flex-wrap: wrap; justify-content: space-around; -} + } + +.boxColor { + color: pink; + } .PlayerSubmissionForm__submit { display: flex; @@ -35,6 +39,10 @@ background-color: #FFE9E9; } +.valid { + background-color: white; +} + .PlayerSubmissionForm__input--invalid::placeholder { color: black; } diff --git a/src/components/PlayerSubmissionForm.js b/src/components/PlayerSubmissionForm.js index ba19e6ef..4a507263 100644 --- a/src/components/PlayerSubmissionForm.js +++ b/src/components/PlayerSubmissionForm.js @@ -1,21 +1,107 @@ import React, { useState } from 'react'; import './PlayerSubmissionForm.css'; +import PropTypes from 'prop-types'; -const PlayerSubmissionForm = () => { +const PlayerSubmissionForm = (props) => { + + const [line, setLine] = useState({ + the1: 'The', + adj1: '', + noun1: '', + adv: '', + verb: '', + the2: 'the', + adj2: '', + noun2: '', + }); + + const onInputChange = (event) => { + console.log(`Changing field ${ event.target.name } to ${ event.target.value }`); + + const newLine = { + ...line + } + + newLine[event.target.name] = event.target.value; + setLine(newLine); + }; + + const onFormSubmit = (event) => { + event.preventDefault(); + console.log('Submitting form'); + + if (line.adj1 !== '' && line.noun1 !== '' && line.adv !== '' && line.verb !== '' && line.adj2 !== '' && line.noun2 !== '') { + props.onSubmitCallback(line); + setLine ({ //Clearing Fields + the1: 'The', + adj1: '', + noun1: '', + adv: '', + verb: '', + the2: 'the', + adj2: '', + noun2: '', + }); + } + } + + const boxColor = (name) => { + return (name === "") ? "PlayerSubmissionFormt__input--invalid" : "valid"; + }; + return ( -
-

Player Submission Form for Player #{ }

+
+

Player Submission Form for Player #{props.player}

-
+
- { - // Put your form inputs here... We've put in one below as an example - } +

The

+ + + className={boxColor(line.adv)} + placeholder="adverb" + type="text" + name='adv' + value={line.adv} + onChange={onInputChange}/> + +

the

+ +
@@ -27,5 +113,12 @@ const PlayerSubmissionForm = () => { ); } - +PlayerSubmissionForm.propTypes = { + onSubmitCallback: PropTypes.func.isRequired, + player: PropTypes.number, + className: PropTypes.string, +}; export default PlayerSubmissionForm; + + + \ No newline at end of file diff --git a/src/components/RecentSubmission.js b/src/components/RecentSubmission.js index 663da34b..f0a0e045 100644 --- a/src/components/RecentSubmission.js +++ b/src/components/RecentSubmission.js @@ -1,13 +1,18 @@ import React from 'react'; import './RecentSubmission.css'; +import PropTypes from 'prop-types'; const RecentSubmission = (props) => { return ( -
+

The Most Recent Submission

-

{ }

+

{props.line}

); } +RecentSubmission.propTypes = { + line: PropTypes.string, + className: PropTypes.string, +}; export default RecentSubmission;