Skip to content

Commit

Permalink
Merge pull request #119 from frontendcafe/main-feature/105-gamecard-c…
Browse files Browse the repository at this point in the history
…omponent

Main feature/105 gamecard component
  • Loading branch information
dafnecaneda authored Sep 2, 2022
2 parents 2f22b38 + f410b43 commit ddcb2b1
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions modules/shared/components/studySession/GameCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import React, { useState } from "react";
import { Box, Text } from "@chakra-ui/react";
import { motion } from "framer-motion";

interface CardSide {
image?: string;
text: string;
}

interface GameCardPops {
sideA: CardSide;
sideB: CardSide;
}

export const GameCard: React.FC<GameCardPops> = ({ sideA, sideB }) => {
const [flip, setFlip] = useState(false);
const MotionBox = motion(Box);

return (
<>
<Box>
<MotionBox
onClick={() => setFlip(!flip)}
borderRadius="10px"
width={{ base: "250px", md: "500px" }}
height="300px"
position="relative"
cursor="pointer"
>
<MotionBox
bg="white"
//
border="2px"
borderColor="gray.50"
position="absolute"
width="100%"
height="100%"
borderRadius="10px"
display="flex"
flexDirection="column"
justifyContent="center"
alignItems="center"
//
style={{
backfaceVisibility: "hidden",
}}
animate={{ rotateY: flip ? [0, 360] : [360, 0] }}
transition={{ duration: 1 }}
>
{sideA.image && <img src={sideA.image} width={150} height={150} />}
<Text mt={10} fontWeight={600}>
{sideA.text}
</Text>
</MotionBox>
<MotionBox
bg="white"
//
border="2px"
borderColor="gray.50"
position="absolute"
width="100%"
height="100%"
borderRadius="10px"
display="flex"
flexDirection="column"
justifyContent="center"
alignItems="center"
//
style={{
backfaceVisibility: "hidden",
}}
animate={{ rotateY: flip ? [180, 0] : [0, 180] }}
transition={{ duration: 1 }}
>
{sideB.image && <img src={sideB.image} width={150} height={150} />}
<Text mt={10} fontWeight={600}>
{sideB.text}
</Text>
</MotionBox>
</MotionBox>
</Box>
</>
);
};

0 comments on commit ddcb2b1

Please sign in to comment.