Skip to content
Open
Show file tree
Hide file tree
Changes from all 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,431 changes: 34,114 additions & 9,317 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/components/FinalPoem.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

.FinalPoem__reveal-btn {
flex: 0.8;

padding: 1rem;
border: 2px black solid;
box-shadow: 5px 10px black;
Expand Down
42 changes: 30 additions & 12 deletions src/components/FinalPoem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,38 @@ import PropTypes from 'prop-types';
import './FinalPoem.css';

const FinalPoem = (props) => {
const printLines = props.submissions.map((submission,index) => {
return (
<p key={index}>{submission}</p>
)
});

return (
<div className="FinalPoem">
<section className="FinalPoem__poem">
<h3>Final Poem</h3>

</section>

<div className="FinalPoem__reveal-btn-container">
<input type="button" value="We are finished: Reveal the Poem" className="FinalPoem__reveal-btn" />
if (props.isSubmitted) {
return (
<div className="FinalPoem">
<section className="FinalPoem__poem">
<h3>Final Poem</h3>
{printLines}
</section>
</div>
);
} else {
return (
<div className="FinalPoem">
<div className="FinalPoem__reveal-btn-container">
<input
type="button"
value="We are finished: Reveal the Poem"
className="FinalPoem__reveal-btn"
onClick={props.revealPoem} />

</div>
</div>
</div>
);
}
);
}
};

//come back to this later for experiments

FinalPoem.propTypes = {
isSubmitted: PropTypes.bool.isRequired,
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
41 changes: 35 additions & 6 deletions src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,32 @@ import FinalPoem from './FinalPoem';
import RecentSubmission from './RecentSubmission';

const Game = () => {
const exampleFormat = FIELDS.map((field) => {
const [playerCount, setPlayerCount] = useState(1);
const [submissions, setSubmissions] = useState([]);
const [isSubmitted, setIsSubmitted] = useState(false);

const exampleFormat = FIELDS.map((field) => {
if (field.key) {
return field.placeholder;
} else {
return field;
}
}).join(' ');

const lineSubmission = (submission) => {
const newLineSubmission = [...submissions]
newLineSubmission.push(submission)

setSubmissions(newLineSubmission)
setPlayerCount(playerCount + 1)
}

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

const revealLastSubmission = submissions[submissions.length - 1]

return (
<div className="Game">
<h2>Game</h2>
Expand All @@ -25,18 +43,29 @@ const Game = () => {
{ exampleFormat }
</p>

<RecentSubmission />
{ (!isSubmitted) ?
<PlayerSubmissionForm
index={playerCount}
sendSubmission={lineSubmission}
fields={FIELDS} />
: ''}

<PlayerSubmissionForm />
{(!isSubmitted && submissions.length > 0) ?
<RecentSubmission submission={revealLastSubmission}/>
: '' }

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


</div>
);
}


const FIELDS = [
export const FIELDS = [
'The',
{
key: 'adj1',
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
78 changes: 67 additions & 11 deletions src/components/PlayerSubmissionForm.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,80 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';

import './PlayerSubmissionForm.css';

const PlayerSubmissionForm = () => {
const PlayerSubmissionForm = (props) => {
const [entry, setEntry] = useState ({

adj1: '',
noun1: '',
adv: '',
verb: '',
adj2: '',
noun2: '',
})

const onEntryChange = (event) => {
const newEntryValues = {
...entry,
}
const {name, value} = event.target;

newEntryValues[name] = value;
setEntry(newEntryValues);
};

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

const poemData = props.fields.map(field => {
const submittedData = {...entry};
if (field.key) {
return submittedData[field.key];
} else {
return field;
}
}).join(' ');

props.sendSubmission(poemData);

setEntry({
adj1: '',
noun1: '',
adv: '',
verb: '',
adj2: '',
noun2: '',
});
}


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
placeholder="hm..."
type="text" />

props.fields.map((field, i) => {
if (field.key) {
return (
<input
key={field.key}
name={field.key}
placeholder={field.placeholder}
value={entry[field.key] || ''}
onChange={onEntryChange}
data-testid={field.key}
type="text"
className={entry[field.key] === '' ? 'PlayerSubmissionFormt__input--invalid' : ''}
/>)
} else {
return field;
}
})
}
</div>

<div className="PlayerSubmissionForm__submit">
Expand Down
4 changes: 3 additions & 1 deletion src/components/RecentSubmission.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ 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