Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aimee 👾 - Fire 🔥 #29

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43,435 changes: 34,116 additions & 9,319 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 19 additions & 6 deletions src/components/FinalPoem.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,31 @@ import './FinalPoem.css';

const FinalPoem = (props) => {

return (
const onSubmission = (event) => {
event.preventDefault();
props.revealPoem();
}

if (props.isSubmitted) {
return (
<div className="FinalPoem">
<section className="FinalPoem__poem">
<h3>Final Poem</h3>

{props.submissions.map((submission, i) => (
<p key={i}>The {submission.adj1} {submission.noun1} {submission.adv} {submission.verb} the {submission.adj2} {submission.noun2} .</p>
))}
</section>

</div>
)}
else { return (
<div className="FinalPoem__reveal-btn-container">
<input type="button" value="We are finished: Reveal the Poem" className="FinalPoem__reveal-btn" />
<input
onClick={onSubmission}
type="button"
value="We are finished: Reveal the Poem"
className="FinalPoem__reveal-btn" />
</div>
</div>
);
)}
}

FinalPoem.propTypes = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/FinalPoem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import userEvent from '@testing-library/user-event';

import FinalPoem from './FinalPoem';

describe.skip('FinalPoem', () => {
describe('FinalPoem', () => {
describe('before the poem is finished', () => {
test('it renders with a button when isSubmitted is false', () => {
// Act
Expand Down
40 changes: 35 additions & 5 deletions src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ const Game = () => {
}
}).join(' ');

const[currentPlayer, setCurrentPlayer] = useState(1);
const[playerSubmission, setPlayerSubmission] = useState([]);
const[isSubmitted, setIsSubmitted] = useState(false);

const addPlayerSubmission = (submission) => {
const poem = [...playerSubmission];
poem.push(submission);
setPlayerSubmission(poem);
setCurrentPlayer(currentPlayer + 1);
}

const mostRecentSubmission = playerSubmission.map((words) => {
return `The ${words.adjective1} ${words.noun1} ${words.adverb} ${words.verb} the ${words.adjective2} ${words.noun2} .`
})

const revealPoem = () => {
setIsSubmitted(true);
}

return (
<div className="Game">
<h2>Game</h2>
Expand All @@ -24,12 +43,23 @@ const Game = () => {
<p className="Game__format-example">
{ exampleFormat }
</p>

{!isSubmitted &&
<RecentSubmission
submission={mostRecentSubmission[mostRecentSubmission.length - 1]} />
}

{!isSubmitted &&
<PlayerSubmissionForm
sendSubmission={addPlayerSubmission}
index={currentPlayer}
fields={FIELDS} />
}

<RecentSubmission />

<PlayerSubmissionForm />

<FinalPoem />
<FinalPoem
isSubmitted={isSubmitted}
submissions={playerSubmission}
revealPoem={revealPoem} />

</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Game.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const FIELDS = [

const INPUT_FIELDS = FIELDS.filter((element) => typeof element !== 'string');

describe.skip('Game', () => {
describe('Game', () => {

describe('Wave 1: Rendering Game', () => {

Expand Down
8 changes: 8 additions & 0 deletions src/components/PlayerSubmissionForm.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@
.PlayerSubmissionForm__input--invalid::placeholder {
color: black;
}

.blankInput {
background-color: pink;
}

.typedInput {
background-color: whitesmoke;
}
93 changes: 84 additions & 9 deletions src/components/PlayerSubmissionForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,101 @@ import PropTypes from 'prop-types';

import './PlayerSubmissionForm.css';

const PlayerSubmissionForm = () => {
const PlayerSubmissionForm = (props) => {
const initState = {
adjective1: '',
noun1: '',
adverb: '',
verb: '',
adjective2: '',
noun2: ''
};

const [poemLine, setPoemLine] = useState(initState);

const onPoemInputChange = (event) => {
const newLine = {
...poemLine,
};

newLine[event.target.name] = [event.target.value]
setPoemLine(newLine);
}


const onFormSubmit = (event) => {
event.preventDefault();

props.sendSubmission(poemLine);

setPoemLine(initState);
}

return (
<div className="PlayerSubmissionForm">
<h3>Player Submission Form for Player #{ }</h3>
<h3>Player Submission Form for Player #{props.index}</h3>

<form className="PlayerSubmissionForm__form" >
<form
className="PlayerSubmissionForm__form"
onSubmit={onFormSubmit}>

<div className="PlayerSubmissionForm__poem-inputs">

{
// Put your form inputs here... We've put in one below as an example
}
<input
name='adjective1'
placeholder="adjective1"
value={poemLine.adjective1}
type="text"
onChange={onPoemInputChange}
className={poemLine.adjective1 === '' ? 'blankInput' : 'typedInput'} />

<input
name='noun1'
placeholder="noun1"
value={poemLine.noun1}
type="text"
onChange={onPoemInputChange}
className={poemLine.noun1 === '' ? 'blankInput' : 'typedInput'}/>

<input
name='adverb'
placeholder="adverb1"
value={poemLine.adverb}
type="text"
onChange={onPoemInputChange}
className={poemLine.adverb === '' ? 'blankInput' : 'typedInput'} />

<input
name='verb'
placeholder="verb1"
value={poemLine.verb}
type="text"
onChange={onPoemInputChange}
className={poemLine.verb === '' ? 'blankInput' : 'typedInput'} />

<input
name='adjective2'
placeholder="adjective2"
value={poemLine.adjective2}
type="text"
onChange={onPoemInputChange}
className={poemLine.adjective2 === '' ? 'blankInput' : 'typedInput'} />

<input
placeholder="hm..."
type="text" />
name='noun2'
placeholder="noun2"
value={poemLine.noun2}
type="text"
onChange={onPoemInputChange}
className={poemLine.noun2 === '' ? 'blankInput' : 'typedInput'} />

</div>

<div className="PlayerSubmissionForm__submit">
<input type="submit" value="Submit Line" className="PlayerSubmissionForm__submit-btn" />
<input
type="submit"
value="Submit Line"
className="PlayerSubmissionForm__submit-btn" />
</div>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/RecentSubmission.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const RecentSubmission = (props) => {
return (
<div className="RecentSubmission">
<h3>The Most Recent Submission</h3>
<p className="RecentSubmission__submission">{ }</p>
<p className="RecentSubmission__submission">{props.submission}</p>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/RecentSubmission.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { render, screen } from '@testing-library/react';
import RecentSubmission from './RecentSubmission';


describe.skip('Wave 2: RecentSubmission', () => {
describe('Wave 2: RecentSubmission', () => {
test('It renders with a submission and shows the text', () => {
// Act
render(<RecentSubmission submission={'This is a submission'} />);
Expand Down