generated from nyu-software-engineering/final-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from software-students-spring2024/update-frontend
changed layout of game page
- Loading branch information
Showing
9 changed files
with
630 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import { useEffect, useState } from "react"; | ||
import { | ||
HStack, | ||
VStack, | ||
Image, | ||
Spinner, | ||
Box, | ||
Text, | ||
Center, | ||
Icon, | ||
} from "@chakra-ui/react"; | ||
import Zoom from "react-medium-image-zoom"; | ||
import "react-medium-image-zoom/dist/styles.css"; | ||
import { FiZoomIn } from "react-icons/fi"; | ||
|
||
export default function ArtifactViewer({ gameObjects, progression }) { | ||
const [bigImgSrc, setBigImgSrc] = useState(gameObjects[0]["primaryImage"]); | ||
const [loading, setLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
setLoading(true); | ||
setBigImgSrc(gameObjects[progression]["primaryImage"]); | ||
setTimeout(() => { | ||
setLoading(false); | ||
}, 200); | ||
}, [progression]); | ||
|
||
return ( | ||
<HStack gap={5}> | ||
{/* additional images */} | ||
<VStack | ||
maxH="500px" | ||
overflowY="auto" | ||
style={{ scrollBarWidth: "none", msOverflowStyle: "none" }} | ||
> | ||
<VStack gap={5}></VStack> | ||
</VStack> | ||
|
||
<HStack> | ||
{/* image */} | ||
{loading ? ( | ||
<Box h={400} w={400}> | ||
<Center h="100%"> | ||
<Spinner size="lg" color="brand.700" /> | ||
</Center> | ||
</Box> | ||
) : ( | ||
<Zoom zoomMargin={400}> | ||
<Image src={bigImgSrc} maxW={400} maxH={400} objectFit="contain" /> | ||
</Zoom> | ||
)} | ||
</HStack> | ||
|
||
{/* image description */} | ||
<VStack | ||
borderRadius={20} | ||
p={5} | ||
px={10} | ||
maxW={350} | ||
gap={5} | ||
alignItems="left" | ||
> | ||
{gameObjects[progression]["title"] && ( | ||
<VStack alignItems="left"> | ||
<Text color="gray.500" fontFamily="monospace"> | ||
Title | ||
</Text> | ||
<Text | ||
fontSize={18} | ||
fontWeight="600" | ||
color="brand.700" | ||
fontFamily="monospace" | ||
> | ||
{gameObjects[progression]["title"]} | ||
</Text> | ||
</VStack> | ||
)} | ||
{gameObjects[progression]["artistDisplayName"] && ( | ||
<VStack alignItems="left"> | ||
<Text color="gray.500" fontFamily="monospace"> | ||
Artist | ||
</Text> | ||
<Text | ||
fontSize={18} | ||
fontWeight="600" | ||
color="brand.700" | ||
fontFamily="monospace" | ||
> | ||
{gameObjects[progression]["artistDisplayName"]} | ||
</Text> | ||
</VStack> | ||
)} | ||
{gameObjects[progression]["medium"] && ( | ||
<VStack alignItems="left"> | ||
<Text color="gray.500" fontFamily="monospace"> | ||
Medium | ||
</Text> | ||
<Text | ||
fontSize={18} | ||
fontWeight="600" | ||
color="brand.700" | ||
fontFamily="monospace" | ||
> | ||
{gameObjects[progression]["medium"]} | ||
</Text> | ||
</VStack> | ||
)} | ||
{gameObjects[progression]["country"] && ( | ||
<VStack alignItems="left"> | ||
<Text color="gray.500" fontFamily="monospace"> | ||
Medium | ||
</Text> | ||
<Text | ||
fontSize={18} | ||
fontWeight="600" | ||
color="brand.700" | ||
fontFamily="monospace" | ||
> | ||
{gameObjects[progression]["country"]} | ||
</Text> | ||
</VStack> | ||
)} | ||
</VStack> | ||
</HStack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { Box, HStack, VStack, Icon, IconButton } from "@chakra-ui/react"; | ||
import { motion } from "framer-motion"; | ||
import { useEffect } from "react"; | ||
import { | ||
FiCheckCircle, | ||
FiChevronLeft, | ||
FiChevronRight, | ||
FiCircle, | ||
} from "react-icons/fi"; | ||
|
||
export default function GameProgress({ | ||
gameState, | ||
setGameState, | ||
progression, | ||
setProgression, | ||
}) { | ||
return ( | ||
<HStack gap={10} position="absolute" top={20}> | ||
<motion.div | ||
initial={{ opacity: 0, x: 15 }} // start state | ||
animate={{ opacity: 1, x: 0 }} // end state | ||
transition={{ | ||
duration: 1.2, | ||
delay: 0.6, | ||
ease: [0.6, -0.05, 0.01, 0.99], | ||
}} | ||
> | ||
<IconButton | ||
colorScheme="brand" | ||
boxShadow="md" | ||
borderRadius={25} | ||
onClick={() => { | ||
if (progression != 0) setProgression(progression - 1); | ||
}} | ||
icon={<Icon as={FiChevronLeft} />} | ||
/> | ||
</motion.div> | ||
|
||
<motion.div | ||
initial={{ opacity: 0, y: -25 }} // start state | ||
animate={{ opacity: 1, y: 0 }} // end state | ||
transition={{ | ||
duration: 1.2, | ||
delay: 0.4, | ||
ease: [0.6, -0.05, 0.01, 0.99], | ||
}} | ||
> | ||
<VStack bg="white" p={5} borderRadius={20} boxShadow="lg" width={300}> | ||
<HStack> | ||
{gameState["playerGuessed"].map((guessed, index) => { | ||
return ( | ||
<VStack w={8} key={index}> | ||
{guessed ? ( | ||
<Icon | ||
as={FiCheckCircle} | ||
boxSize={7} | ||
color={index == progression ? "yellow.500" : "brand.500"} | ||
onClick={() => { | ||
setProgression(index); | ||
}} | ||
_hover={{ cursor: "pointer" }} | ||
/> | ||
) : ( | ||
<Icon | ||
as={FiCircle} | ||
boxSize={7} | ||
color={index == progression ? "yellow.500" : "gray.500"} | ||
onClick={() => { | ||
setProgression(index); | ||
}} | ||
_hover={{ cursor: "pointer" }} | ||
/> | ||
)} | ||
</VStack> | ||
); | ||
})} | ||
</HStack> | ||
</VStack> | ||
</motion.div> | ||
|
||
<motion.div | ||
initial={{ opacity: 0, x: -15 }} // start state | ||
animate={{ opacity: 1, x: 0 }} // end state | ||
transition={{ | ||
duration: 1.2, | ||
delay: 0.6, | ||
ease: [0.6, -0.05, 0.01, 0.99], | ||
}} | ||
> | ||
<IconButton | ||
colorScheme="brand" | ||
boxShadow="md" | ||
borderRadius={25} | ||
onClick={() => { | ||
if (progression != 4) setProgression(progression + 1); | ||
}} | ||
icon={<Icon as={FiChevronRight} />} | ||
/> | ||
</motion.div> | ||
</HStack> | ||
); | ||
} |
Oops, something went wrong.