GamePanel.jsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React, { useEffect } from 'react';
  2. import styled from 'styled-components';
  3. import Loading from '../../util/Loading';
  4. import GuessPane from "./GuessPane";
  5. import PositionedStreetView from "./PositionedStreetView";
  6. import { dispatch, useCurrentRound } from '../../../domain/gameStore';
  7. import usePreventNavigation from '../../../hooks/usePreventNavigation';
  8. const Container = styled.div`
  9. height: 100%;
  10. width: 100%;
  11. display: flex;
  12. flex-flow: column nowrap;
  13. justify-content: space-between;
  14. align-items: center;
  15. @media only screen and (min-width: 600px) and (min-height: 600px) {
  16. display: block;
  17. position: relative;
  18. margin-bottom: 2px;
  19. margin-right: 2px;
  20. }
  21. `
  22. const StreetViewWrapper = styled.div`
  23. height: 100%;
  24. width: 100%;
  25. margin-bottom: 2px;
  26. flex: 3;
  27. `
  28. export default () => {
  29. // warn the user if they navigate away
  30. usePreventNavigation();
  31. const finished = useCurrentRound() === null;
  32. useEffect(() => {
  33. if (finished) {
  34. dispatch.goToSummary();
  35. }
  36. }, [finished]);
  37. return finished
  38. ? <Loading />
  39. : (
  40. <Container>
  41. <StreetViewWrapper>
  42. <PositionedStreetView
  43. onPanoMoved={(lat, lng, head, pitch) => console.log(`${lat}, ${lng}, ${head}, ${pitch}`)}
  44. />
  45. </StreetViewWrapper>
  46. <GuessPane />
  47. </Container>
  48. );
  49. }