diff --git a/frontend/src/js/components/button.js b/frontend/src/js/components/button.js index 914b299..a9866ce 100644 --- a/frontend/src/js/components/button.js +++ b/frontend/src/js/components/button.js @@ -1,12 +1,22 @@ import React from 'react'; +import { Link} from "react-router-dom"; function Button(props){ return ( - + + {props.displayValue} + ); } +Button.defaultProps = { + disabled: false, + link: "/", + displayValue: "Missing displayValue" +} + export default Button; \ No newline at end of file diff --git a/frontend/src/js/components/gameList.js b/frontend/src/js/components/gameList.js new file mode 100644 index 0000000..12492fb --- /dev/null +++ b/frontend/src/js/components/gameList.js @@ -0,0 +1,19 @@ +import React from 'react'; +import ListGameCell from '../components/listGameCell'; + +function GameList(props){ + return ( +
+ {props.games.map((game) => ( + + ))} +
+ ) +} + +export default GameList; \ No newline at end of file diff --git a/frontend/src/js/components/leaderboard.js b/frontend/src/js/components/leaderboard.js index eea263d..24e1425 100644 --- a/frontend/src/js/components/leaderboard.js +++ b/frontend/src/js/components/leaderboard.js @@ -2,7 +2,7 @@ import React from 'react'; function Leaderboard(){ return ( -
+
); diff --git a/frontend/src/js/components/listGameCell.js b/frontend/src/js/components/listGameCell.js new file mode 100644 index 0000000..377b4dc --- /dev/null +++ b/frontend/src/js/components/listGameCell.js @@ -0,0 +1,21 @@ +import React from 'react'; + +function ListGameCell(props){ + const isSelected = props.selectedGame === props.data.gameId; + + return ( +
isSelected ? props.setGame(null) :props.setGame(props.data.gameId)} + > +

Game ID: {props.data.gameId}

+

+ {props.data.completed}/{props.data.gameSize} +

+
+ ); +} + +export default ListGameCell; \ No newline at end of file diff --git a/frontend/src/js/pages/gameView.js b/frontend/src/js/pages/gameView.js index 551f1b6..eb0db44 100644 --- a/frontend/src/js/pages/gameView.js +++ b/frontend/src/js/pages/gameView.js @@ -1,10 +1,19 @@ import React from 'react'; import {useParams} from 'react-router-dom'; +import GameCard from '../components/gameCard'; +import Button from '../components/button'; function GameView(){ const {id} = useParams(); return ( -

{id}

+
+

Game ID: {id}

+ +
+
+
); } diff --git a/frontend/src/js/pages/home.js b/frontend/src/js/pages/home.js index d0d8974..0b48dd7 100644 --- a/frontend/src/js/pages/home.js +++ b/frontend/src/js/pages/home.js @@ -1,10 +1,42 @@ -import React from 'react'; +import React, { useState} from 'react'; import Leaderboard from '../components/leaderboard'; +import GameList from '../components/gameList'; +import Button from '../components/button'; + function Home(){ + const [selectedGame, setSelectedGame] = useState(null); + + const games = [ + { + "gameId": 1, + "completed": 3, + "gameSize": 9, + },{ + "gameId": 2, + "completed": 16, + "gameSize": 25, + },{ + "gameId": 4, + "completed": 14, + "gameSize": 25, + },{ + "gameId": 7, + "completed": 3, + "gameSize": 9, + } + ] return ( -
+
+ +
+
); }