Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main feature/105 gamecard component #119

Merged
merged 2 commits into from
Sep 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
</>
);
};