ScoreBoard.jsx 685 B

12345678910111213141516171819202122232425
  1. import React from "react";
  2. import styled from "styled-components";
  3. import PlayerScoreTile from "./PlayerScoreTile";
  4. const ScoreBoardContainer = styled.div`
  5. flex: 2;
  6. display: flex;
  7. flex-flow: row wrap;
  8. justify-content: space-evenly;
  9. align-items: flex-start;
  10. align-content: space-around;
  11. max-width: 80%;
  12. margin-top: 2em;
  13. `
  14. export default ({ players }) => (
  15. <ScoreBoardContainer>
  16. {
  17. players
  18. .filter(({ currentRound }) => currentRound === null)
  19. .sort((p1, p2) => p1.totalScore > p2.totalScore ? -1 : (p1.totalScore < p2.totalScore ? 1 : 0))
  20. .map((data) => <PlayerScoreTile key={data.name} {...data} />)
  21. }
  22. </ScoreBoardContainer>
  23. );