Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fb1b0ab
adds player and fieldInput default states, passes to PlayerSubmission…
Apr 22, 2020
40d2aec
adds text fields, updates styling
Apr 22, 2020
0afd4a2
moves fieldInput and setFieldInput to PlayerSubmissionForm, adds onIn…
Apr 23, 2020
e8bc57a
adds onSubmit event listener and onFormSubmit event handler
Apr 23, 2020
aec8731
adds onLineSubmitCallback function to Game and calls it in PlayerSubm…
Apr 23, 2020
66e50a7
expands onLineSubmitCallback, saves form data in an array, converts f…
Apr 23, 2020
277672f
passes submissionList into FinalPoem and renders, onClick event liste…
Apr 23, 2020
933e660
adds onButtonClickCallback function for FinalPoem, displays poem when…
Apr 23, 2020
5f4388a
hides RecentSubmission and PlayerSubmissionForm when the final poem i…
Apr 23, 2020
4a0bd73
changes className on final poem reveal from noshow to hide
Apr 23, 2020
5483d40
adds dynamic styling to input fields, light pink background if empty
Apr 23, 2020
f192054
changes the data passed into RecentSubmission so the component handle…
Apr 23, 2020
7afe65a
displays each line of the final poem on a new line, cleans up code
Apr 23, 2020
9e43ac1
cleans up spacing
Apr 23, 2020
e1bfe2e
cleans up spacing, refactors isValid helper function, adds comments
Apr 23, 2020
5842ab3
removes unusued class
Apr 23, 2020
fbdbc88
adds missing semi-colons
Apr 23, 2020
b226b29
adds PropTypes
Apr 23, 2020
b250068
hides FinalPoem button when the poem has been revealed
Apr 23, 2020
34d985c
enables deployment to github pages
Apr 23, 2020
a94d0fe
fixes comma error
Apr 23, 2020
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
91 changes: 91 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"name": "exquisite-react",
"version": "0.1.0",
"private": true,
"homepage": "https://peachmakkoli.github.io/exquisite-react/",
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"gh-pages": "^2.2.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
Expand All @@ -14,6 +16,8 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"eject": "react-scripts eject"
},
"eslintConfig": {
Expand Down
4 changes: 4 additions & 0 deletions src/components/FinalPoem.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@
.FinalPoem__poem {
border-bottom: 2px gray dashed;
}

.FinalPoem__hide {
display: none;
}
35 changes: 29 additions & 6 deletions src/components/FinalPoem.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,43 @@
import React from 'react';
import PropTypes from 'prop-types';
import './FinalPoem.css';

const FinalPoem = (props) => {
const FinalPoem = ({ submissions, onButtonClickCallback, revealPoem }) => {
const finalPoem = submissions.map(submission => <p key={submission.key}>The {submission.adj1} {submission.noun1} {submission.adv} {submission.verb} the {submission.adj2} {submission.noun2}.</p>);

return (
<div className="FinalPoem">
<section className="FinalPoem__poem">
<section className={ revealPoem ? "FinalPoem__poem" : "FinalPoem__hide" }>
<h3>Final Poem</h3>

{finalPoem}
</section>

<div className="FinalPoem__reveal-btn-container">
<input type="button" value="We are finished: Reveal the Poem" className="FinalPoem__reveal-btn" />
<div className={ revealPoem ? "FinalPoem__hide" : "FinalPoem__reveal-btn-container" }>
<input
type="button"
value="We are finished: Reveal the Poem"
className="FinalPoem__reveal-btn"
onClick={onButtonClickCallback}
/>
</div>
</div>
);
}
};

FinalPoem.propTypes = {
submissions: PropTypes.arrayOf(
PropTypes.shape({
key: PropTypes.number.isRequired,
adj1: PropTypes.string.isRequired,
noun1: PropTypes.string.isRequired,
adv: PropTypes.string.isRequired,
verb: PropTypes.string.isRequired,
adj2: PropTypes.string.isRequired,
noun2: PropTypes.string.isRequired,
})
),
onButtonClickCallback: PropTypes.func.isRequired,
revealPoem: PropTypes.bool.isRequired,
};

export default FinalPoem;
29 changes: 25 additions & 4 deletions src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ const Game = () => {
}
}).join(" ");

const [ player, setPlayer ] = useState(1);
const [ playerSubmission, setPlayerSubmission ] = useState(null);
const [ submissionList, setSubmissionList ] = useState([]);
const [ revealPoem, setRevealPoem ] = useState(false);

const onLineSubmitCallback = (formInput) => {
const newSubmissionList = [...submissionList];
newSubmissionList.push({
key: player,
...formInput,
});

setSubmissionList(newSubmissionList);
setPlayerSubmission(formInput);
setPlayer(player+1);
};

const onButtonClickCallback = () => {
setRevealPoem(true);
};

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

<RecentSubmission />
<RecentSubmission submission={playerSubmission} revealPoem={revealPoem} />

<PlayerSubmissionForm />
<PlayerSubmissionForm player={player} onLineSubmitCallback={onLineSubmitCallback} revealPoem={revealPoem} />

<FinalPoem />
<FinalPoem submissions={submissionList} onButtonClickCallback={onButtonClickCallback} revealPoem={revealPoem} />

</div>
);
}
};


const FIELDS = [
Expand Down
13 changes: 13 additions & 0 deletions src/components/PlayerSubmissionForm.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
justify-content: space-around;
}

.PlayerSubmissionForm__poem-inputs div {
display: flex;
align-content: center;
}

.PlayerSubmissionForm__poem-inputs label {
display: none;
}

.PlayerSubmissionForm__input-invalid {
background-color: lightpink;
}

.PlayerSubmissionForm__submit {
display: flex;
justify-content: center;
Expand Down
Loading