PlayerScoreTile.jsx 980 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import React from "react";
  2. import styled from "styled-components";
  3. const Tile = styled.div`
  4. flex: 1;
  5. display: flex;
  6. flex-flow: column nowrap;
  7. justify-content: flex-start;
  8. align-items: center;
  9. min-width: 10em;
  10. `
  11. const Name = styled.span`
  12. font-size: 1.4em;
  13. font-weight: 800;
  14. `
  15. const TotalScore = styled.span`
  16. font-size: 1.1em;
  17. margin-left: .5em;
  18. `
  19. const List = styled.div`
  20. display: flex;
  21. flex-flow: column nowrap;
  22. justify-content: center;
  23. align-items: flex-start;
  24. margin-bottom: 20%;
  25. margin-left: 1em;
  26. list-style: none;
  27. `
  28. const Score = styled.span`
  29. `
  30. export default ({ name, guesses, totalScore }) => (
  31. <Tile>
  32. <Name>{name}</Name>
  33. <TotalScore>Score: {totalScore}</TotalScore>
  34. <List>
  35. {
  36. ["1", "2", "3", "4", "5"]
  37. .map(num => {
  38. const score = guesses[num]?.score
  39. return score !== undefined ? <Score key={num}>{num}: {score}</Score> : null
  40. })
  41. }
  42. </List>
  43. </Tile>
  44. );