|
@@ -1,10 +1,26 @@
|
|
|
import React from 'react';
|
|
|
+import styled from "styled-components";
|
|
|
import Loading from '../../util/Loading';
|
|
|
import Button from "../../util/Button";
|
|
|
-import PlayerScoresList from "./PlayerScoresList";
|
|
|
+import PlayerScoreTile from "./PlayerScoreTile";
|
|
|
import usePlayerScores from '../../../hooks/usePlayerScores';
|
|
|
|
|
|
-const PlayerScoresContainer = ({ gameId, onReturnToStart }) => {
|
|
|
+const Container = styled.div`
|
|
|
+ display: flex;
|
|
|
+ flex-flow: column nowrap;
|
|
|
+ justify-content: space-around;
|
|
|
+ align-items: center;
|
|
|
+`
|
|
|
+
|
|
|
+const ScoreBoard = styled.div`
|
|
|
+ display: flex;
|
|
|
+ flex-flow: row wrap;
|
|
|
+ justify-content: space-around;
|
|
|
+ align-items: center;
|
|
|
+ align-content: space-around;
|
|
|
+`
|
|
|
+
|
|
|
+export default ({ gameId, onReturnToStart }) => {
|
|
|
const scores = usePlayerScores(gameId);
|
|
|
|
|
|
if (!scores) {
|
|
@@ -12,11 +28,16 @@ const PlayerScoresContainer = ({ gameId, onReturnToStart }) => {
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
- <div className="player-scores">
|
|
|
- <PlayerScoresList scores={scores} />
|
|
|
- <Button className="player-scores__button" onClick={onReturnToStart}>Return to Start</Button>
|
|
|
- </div>
|
|
|
+ <Container>
|
|
|
+ <ScoreBoard>
|
|
|
+ {
|
|
|
+ scores
|
|
|
+ .filter(({ currentRound }) => currentRound === null)
|
|
|
+ .sort((p1, p2) => p1.totalScore > p2.totalScore ? -1 : (p1.totalScore < p2.totalScore ? 1 : 0))
|
|
|
+ .map(({ name, guesses, totalScore }) => <PlayerScoreTile key={name} {...{ name, guesses, totalScore }} />)
|
|
|
+ }
|
|
|
+ </ScoreBoard>
|
|
|
+ <Button onClick={onReturnToStart}>Return to Start</Button>
|
|
|
+ </Container>
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
-export default PlayerScoresContainer;
|