RoundSummary.jsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React, { useRef } from "react";
  2. import styled from "styled-components";
  3. import useMap from "../../../hooks/useMap";
  4. import useMarkedPoints from "./useMarkedPoints";
  5. import RoundInfoPane from "./RoundInfoPane";
  6. const Container = styled.div`
  7. flex: 1;
  8. display: flex;
  9. flex-flow: column nowrap;
  10. justify-content: space-around;
  11. align-items: center;
  12. @media only screen and (min-width: 600px) {
  13. flex-flow: row nowrap;
  14. }
  15. `
  16. const MapDiv = styled.div`
  17. height: 50%;
  18. width: 100%;
  19. @media only screen and (min-width: 600px) {
  20. width: 50%;
  21. }
  22. `
  23. export default ({ gameId, round, onNext }) => {
  24. const {
  25. roundNum,
  26. selectedPoint,
  27. targetPoint,
  28. score,
  29. totalScore,
  30. } = round;
  31. const mapDivRef = useRef(null);
  32. // TODO dynamically determine this zoom level?
  33. const mapRef = useMap(mapDivRef, targetPoint.lat, targetPoint.lng, 4);
  34. useMarkedPoints(mapRef, selectedPoint, targetPoint);
  35. return (
  36. <Container>
  37. <MapDiv ref={mapDivRef} />
  38. <RoundInfoPane {...{ gameId, selectedPoint, targetPoint, roundNum, score, totalScore, onNext }}/>
  39. </Container>
  40. );
  41. };