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

Sockets-Bita #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
37 changes: 25 additions & 12 deletions src/components/FinalPoem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,31 @@ import './FinalPoem.css';

const FinalPoem = (props) => {

return (
<div className="FinalPoem">
<section className="FinalPoem__poem">
<h3>Final Poem</h3>
const poem = props.submissions.map((line, i) => {
return <p key={i}> {line}</p>
})
const handleClick = () => {
console.log("I am clicking")
props.poemCallback();
}
const poemButton =
<div className="FinalPoem__reveal-btn-container" >
<input type="button" value="We are finished: Reveal the Poem" className="FinalPoem__reveal-btn" onClick={handleClick} />
</div>

</section>
const showpoem =
<section className="FinalPoem__poem">
<h3>Final Poem</h3>
<div>{poem}</div>
</section>;
const content = props.isSubmitted? showpoem : poemButton

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

export default FinalPoem;
</div>
);
}

export default FinalPoem;
40 changes: 35 additions & 5 deletions src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,35 @@ class Game extends Component {

constructor(props) {
super(props);
this.state = {
submissions: [],
isSubmitted: false,
counter: 1,
}
}

addSubmission = (newSentence)=> {
console.log(newSentence)
let nextSubmission = this.state.submissions
nextSubmission.push(newSentence)
this.setState({
submissions: nextSubmission,
counter: this.state.counter + 1
})
console.log(this.state.submissions)

}
setSubmitted=()=> {
this.setState({
isSubmitted: true,
counter: 1,
})
}





render() {

const exampleFormat = FIELDS.map((field) => {
Expand All @@ -19,6 +46,9 @@ class Game extends Component {
return field;
}
}).join(" ");
const playersubmissionform = this.state.isSubmitted? '' : <PlayerSubmissionForm onSubmissionCallback={this.addSubmission} Counter={this.state.counter}/>
const recentsubmission = this.state.isSubmitted? '' : <RecentSubmission recentSubmission= {this.state.submissions[this.state.submissions.length - 1]} />


return (
<div className="Game">
Expand All @@ -31,12 +61,12 @@ class Game extends Component {
<p className="Game__format-example">
{ exampleFormat }
</p>
{recentsubmission}
{playersubmissionform}


<RecentSubmission />

<PlayerSubmissionForm />

<FinalPoem />
<FinalPoem poemCallback={this.setSubmitted} submissions={this.state.submissions} isSubmitted={this.state.isSubmitted} />


</div>
);
Expand Down
2 changes: 2 additions & 0 deletions src/components/PlayerSubmissionForm.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
background-color: #FFE9E9;
}



.PlayerSubmissionForm__input--invalid::placeholder {
color: black;
}
106 changes: 98 additions & 8 deletions src/components/PlayerSubmissionForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,119 @@ class PlayerSubmissionForm extends Component {

constructor(props) {
super(props);
this.state = {
adj1: '',
noun1: '',
adv: '',
verb: '',
adj2: '',
noun2: '',
}
}

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

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


updatedState[field] = value;
this.setState(updatedState);
}
onFormSubmit = (event) => {
event.preventDefault();

// const newSubmission = {
// adj1: this.state.adj1,
// noun1: this.state.noun1,
// adv: this.state.adv,
// verb: this.state.verb,
// adj2: this.state.adj2,
// noun2: this.state.noun2,
// };
const newSentence = "The " + this.state.adj1 + " " + this.state.noun1 + " " + this.state.adv + " " + this.state.verb + " the " + this.state.adj2 + " " + this.state.noun2
console.log(newSentence)



this.setState({
adj1: '',
noun1: '',
adv: '',
verb: '',
adj2: '',
noun2: '',
});

this.props.onSubmissionCallback(newSentence)

}



render() {
// let classname = "PlayerSubmissionFormt__input--invalid"
return (
<div className="PlayerSubmissionForm">
<h3>Player Submission Form for Player #{ }</h3>

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

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

<div className="PlayerSubmissionForm__poem-inputs">

<span>The</span>

{
// Put your form inputs here... We've put in one below as an example
}
<input
placeholder="hm..."
placeholder="adjective"
className="PlayerSubmissionFormt__input--invalid"
name="adj1"
onChange={this.onInputChange}
value={this.state.adj1}
type="text" />
<input
placeholder="noun"
className="PlayerSubmissionFormt__input--invalid"
name="noun1"
onChange={this.onInputChange}
value={this.state.noun1}
type="text" />
<input
placeholder="adverb"
className="PlayerSubmissionFormt__input--invalid"
name="adv"
onChange={this.onInputChange}
value={this.state.adv}
type="text" />
<input
placeholder="verb"
className="PlayerSubmissionFormt__input--invalid"
name="verb"
onChange={this.onInputChange}
value={this.state.verb}
type="text" />
<span>the</span>
<input
placeholder="adjective"
className="PlayerSubmissionFormt__input--invalid"
name="adj2"
onChange={this.onInputChange}
value={this.state.adj2}
type="text" />
<input
placeholder="noun"
className="PlayerSubmissionFormt__input--invalid"
name="noun2"
onChange={this.onInputChange}
value={this.state.noun2}
type="text" />
<span>,</span>

</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
3 changes: 2 additions & 1 deletion src/components/RecentSubmission.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import React from 'react';
import './RecentSubmission.css';

const RecentSubmission = (props) => {
console.log(props)
return (
<div className="RecentSubmission">
<h3>The Most Recent Submission</h3>
<p className="RecentSubmission__submission">{ }</p>
<p className="RecentSubmission__submission">{props.recentSubmission}</p>
</div>
);
}
Expand Down