Skip to content

Commit

Permalink
Working landing page and fight screen load button
Browse files Browse the repository at this point in the history
Relates #2 #8

Co-authored-by: shaya <[email protected]>
  • Loading branch information
azizi-a and fairyaksh committed Sep 17, 2020
1 parent 838eab4 commit 75318e4
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
22 changes: 4 additions & 18 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
import React from "react";
import "./App.css";
import FishCard from "./modules/fish-card";
import { getRandomFishData } from "./modules/fetch-helper";
import LandingPage from "./modules/landing-page";
import FightPage from "./modules/fight-page";

function App() {
const [fishData, setFishData] = React.useState(null);
// opponentFish data

// button activated effect - rejects button
React.useEffect(() => {
getRandomFishData().then((data) => {
setFishData(data);
});
}, []);
const [page, setPage] = React.useState(true);

return (
// return landing page on first load - logo and randomizer button
<div className="App">
<header className="App-header"></header>
{/* title - some kind of fish pun */}
<body className="App-body">
<LandingPage />
{/* <FishCard {...fishData} /> */}
{/* accept or reject buttons */}
{page ? <LandingPage setPage={setPage} /> : <FightPage />}
</body>
</div>
);
}
//landing page function
//fight page function

export default App;
File renamed without changes
33 changes: 33 additions & 0 deletions src/modules/fight-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react";
import FishCard from "./fish-card";
import { getRandomFishData } from "./fetch-helper";

const FightPage = () => {
const [fishData, setFishData] = React.useState(null);
const [opponentFishData, setOpponentFishData] = React.useState(null);

// button activated effect - rejects button
React.useEffect(() => {
getRandomFishData().then((data) => {
setFishData(data);
});
}, []);
return (
<>
<h1>Being weighed in the scales</h1>
<FishCard {...fishData} />
<button>I'm hooked - Accept</button>
<button
onClick={() => {
getRandomFishData().then((data) => {
setFishData(data);
});
}}
>
A load of pollocks! - Choose again.
</button>
</>
);
};

export default FightPage;
10 changes: 6 additions & 4 deletions src/modules/landing-page.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import React from "react";
import logo from "Sword-Fish-Fencing.png";
import logo from "../logo.png";
// import FishPage from "./fight-page";
import { loadFish } from "../App";

const LandingPage = () => {
const LandingPage = ({ setPage }) => {
return (
<>
<h1>Fish Fight!</h1>
<img
onClick={/*generate fight page with first fish*/}
onClick={() => setPage(false)}
src={logo}
className="App-logo"
alt="logo"
/>
<button onClick={/*generate fight page with first fish*/}>
<button onClick={() => setPage(false)}>
There are plenty of fish in the sea. Which will you be?
</button>
</>
Expand Down

0 comments on commit 75318e4

Please sign in to comment.