From d1b17807636784d3fdb64d34bc45b28ada95b6ad Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 20 Mar 2020 19:19:46 +1100 Subject: [PATCH] Added a social view and a switch between the new view and the old --- src/components/AddPartyMemberButton.js | 2 +- src/components/GameViewSwitch.js | 98 ++++++++++++++++++++++++++ src/components/Party.js | 88 ++++++++++++++++++----- src/components/PartyVideo.js | 15 ++-- src/routes/Game.js | 38 +++++++--- 5 files changed, 203 insertions(+), 38 deletions(-) create mode 100644 src/components/GameViewSwitch.js diff --git a/src/components/AddPartyMemberButton.js b/src/components/AddPartyMemberButton.js index e425dc9..b4920b4 100644 --- a/src/components/AddPartyMemberButton.js +++ b/src/components/AddPartyMemberButton.js @@ -14,7 +14,7 @@ function AddPartyMemberButton({ streamId }) { return ( <> - + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} + +function EncounterIcon() { + return ( + + + + + + + ); +} + +function GameViewSwitch({ view, onViewChange }) { + return ( + + onViewChange("social")} + > + + + onViewChange("encounter")} + > + + + + ); +} + +export default GameViewSwitch; diff --git a/src/components/Party.js b/src/components/Party.js index 51dcea5..2a27901 100644 --- a/src/components/Party.js +++ b/src/components/Party.js @@ -1,28 +1,78 @@ import React from "react"; -import { Flex } from "theme-ui"; +import { Flex, Box } from "theme-ui"; import PartyVideo from "./PartyVideo"; import AddPartyMemberButton from "./AddPartyMemberButton"; +import GameViewSwitch from "./GameViewSwitch"; -function Party({ streams, localStreamId }) { - return ( - - {Object.entries(streams).map(([id, stream]) => ( - - ))} - - - ); +function Party({ streams, localStreamId, view, onViewChange }) { + if (view === "social") { + return ( + + + {Object.entries(streams).map(([id, stream]) => ( + + + + ))} + + + + + + + + + ); + } else if (view === "encounter") { + return ( + + {Object.entries(streams).map(([id, stream]) => ( + + + + ))} + + + + + + + + ); + } + + return null; } +Party.defaultProps = { view: "social" }; + export default Party; diff --git a/src/components/PartyVideo.js b/src/components/PartyVideo.js index 1a80c72..0ab1f76 100644 --- a/src/components/PartyVideo.js +++ b/src/components/PartyVideo.js @@ -1,5 +1,4 @@ import React, { useRef, useEffect } from "react"; -import { Box } from "theme-ui"; function PartyVideo({ stream, muted }) { const videoRef = useRef(); @@ -11,14 +10,12 @@ function PartyVideo({ stream, muted }) { }, [stream]); return ( - - +