Home.jsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import React from "react";
  2. import { Switch, Route } from "react-router-dom";
  3. import { useTranslation } from "react-i18next";
  4. import styled from "styled-components";
  5. import CookieNotice, { useCookieConsent } from "./CookieNotice";
  6. import useLocalStorage from "../hooks/useLocalStorage";
  7. import useQueryParam from "../hooks/useQueryParam";
  8. import HomeNav from "./HomeNav";
  9. import AboutModal from "./AboutModal";
  10. import GameListView from "./GameListView";
  11. import GameStudio from "./GameStudio";
  12. const StyledHome = styled.div`
  13. min-height: 100vh;
  14. flex-direction: column;
  15. & > footer {
  16. width: 100%;
  17. grid-column: 1 / 4;
  18. padding: 0.5em 0;
  19. text-align: center;
  20. background-color: #00000099;
  21. }
  22. `;
  23. const Home = () => {
  24. const { t } = useTranslation();
  25. const cookieConsent = useCookieConsent();
  26. const [isBeta, setIsBeta] = useLocalStorage("isBeta", false);
  27. if (isBeta) {
  28. console.log("Beta activated");
  29. }
  30. const [showAboutModal, setShowAboutModal] = React.useState(false);
  31. let query = useQueryParam();
  32. const forceBeta = query.get("beta") === "true";
  33. React.useEffect(() => {
  34. if (forceBeta) {
  35. setIsBeta(true);
  36. }
  37. }, [forceBeta, setIsBeta]);
  38. return (
  39. <>
  40. <StyledHome>
  41. <HomeNav cookieConsent={cookieConsent} />
  42. <Switch>
  43. <Route exact path="/games">
  44. <GameListView />
  45. </Route>
  46. <Route path="/studio">
  47. <GameStudio />
  48. </Route>
  49. </Switch>
  50. <footer>
  51. <button
  52. className="button clear"
  53. onClick={() => setShowAboutModal(true)}
  54. >
  55. {t("About")}
  56. </button>
  57. </footer>
  58. </StyledHome>
  59. <AboutModal show={showAboutModal} setShow={setShowAboutModal} />
  60. <CookieNotice />
  61. </>
  62. );
  63. };
  64. export default Home;