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
28 changes: 21 additions & 7 deletions src/components/FinalPoem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,31 @@ import React from 'react';
import './FinalPoem.css';

const FinalPoem = (props) => {
const { inProgress, finishGameCallback, text} = props;
let display = undefined

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

</section>
const poem = text.map((sub) => {
return <p>{ sub }</p>;
});

if (inProgress) {
display =
<div className="FinalPoem__reveal-btn-container">
<input type="button" value="We are finished: Reveal the Poem" className="FinalPoem__reveal-btn" />
<input onClick={finishGameCallback} type="button" value="We are finished: Reveal the Poem" className="FinalPoem__reveal-btn" />
</div>
} else {
display =
<div className="FinalPoem">
<section className="FinalPoem__poem">
<h3>Final Poem</h3>
{poem}
</section>
</div>
}

return (
<div className="FinalPoem">
{display}
</div>
);
}
Expand Down
28 changes: 25 additions & 3 deletions src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@ class Game extends Component {

constructor(props) {
super(props);

this.state = {
recent: '',
playSubmissions: [],
inProgress: true
}
}

addLine = (formText) => {

const newSubs = this.state.playSubmissions
newSubs.push(formText)
this.setState({
playSubmissions: newSubs,
recent: formText
})

}

finishGame = () => {
this.setState({inProgress: false})
}

render() {
Expand All @@ -20,6 +41,7 @@ class Game extends Component {
}
}).join(" ");


return (
<div className="Game">
<h2>Game</h2>
Expand All @@ -32,11 +54,11 @@ class Game extends Component {
{ exampleFormat }
</p>

<RecentSubmission />
{this.state.inProgress && this.state.recent ? <RecentSubmission text={this.state.recent}/> : ""}

<PlayerSubmissionForm />
{this.state.inProgress ? <PlayerSubmissionForm addLineCallback={formText => this.addLine(formText)}/> : ""}

<FinalPoem />
<FinalPoem inProgress={this.state.inProgress} finishGameCallback={this.finishGame} text={this.state.playSubmissions}/>

</div>
);
Expand Down
59 changes: 47 additions & 12 deletions src/components/PlayerSubmissionForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,62 @@ class PlayerSubmissionForm extends Component {

constructor(props) {
super(props);

this.state = {
input1: "",
input2: "",
input3: "",
input4: "",
input5: "",
input6: "",
valid: false,
player: 1
}
}


onInputChange = (event) => {
const updatedState = {};

const field = event.target.name;
const value = event.target.value;

updatedState[field] = value;
this.setState(updatedState);
}

addLineCallback = (event) => {
event.preventDefault();
const formText = "The" + " " + this.state.input1 + " " + this.state.input2 + " " + this.state.input3 + " " + this.state.input4 + " " + "the" + " " + this.state.input5 + " " + this.state.input6 + "."
this.props.addLineCallback(formText);
this.setState({
input1: "",
input2: "",
input3: "",
input4: "",
input5: "",
input6: "",})
this.setState({player: this.state.player + 1})
}

render() {

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

<form className="PlayerSubmissionForm__form" >
<h3>Player Submission Form for Player #{ this.state.player }</h3>

<form className="PlayerSubmissionForm__form" onSubmit={this.addLineCallback} >
<div className="PlayerSubmissionForm__poem-inputs">

{
// Put your form inputs here... We've put in one below as an example
}
<input
placeholder="hm..."
type="text" />

The
<input className={this.state.valid ? "" : "PlayerSubmissionFormt__input--invalid" } placeholder="adjective" name="input1" onChange={this.onInputChange} value={this.state.input1}/>
<input className={this.state.valid ? "" : "PlayerSubmissionFormt__input--invalid" } placeholder="noun" name="input2" onChange={this.onInputChange} value={this.state.input2}/>
<input className={this.state.valid ? "" : "PlayerSubmissionFormt__input--invalid" } placeholder="adverb" name="input3" onChange={this.onInputChange} value={this.state.input3}/>
<input className={this.state.valid ? "" : "PlayerSubmissionFormt__input--invalid" } placeholder="verb" name="input4" onChange={this.onInputChange} value={this.state.input4}/>
the
<input className={this.state.valid ? "" : "PlayerSubmissionFormt__input--invalid" } placeholder="adjective" name="input5" onChange={this.onInputChange} value={this.state.input5}/>
<input className={this.state.valid ? "" : "PlayerSubmissionFormt__input--invalid" } placeholder="noun" name="input6" onChange={this.onInputChange} value={this.state.input6}/>
.
</div>

<div className="PlayerSubmissionForm__submit">
<input type="submit" value="Submit Line" className="PlayerSubmissionForm__submit-btn" />
</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 @@ -5,7 +5,7 @@ const RecentSubmission = (props) => {
return (
<div className="RecentSubmission">
<h3>The Most Recent Submission</h3>
<p className="RecentSubmission__submission">{ }</p>
<p className="RecentSubmission__submission">{ props.text }</p>
</div>
);
}
Expand Down