Skip to content

Commit c5faa57

Browse files
Adds drawer component to show/hide question details
1 parent ccdfd32 commit c5faa57

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import {
2+
Drawer,
3+
DrawerBody,
4+
DrawerHeader,
5+
DrawerOverlay,
6+
IconButton,
7+
useDisclosure,
8+
Text,
9+
DrawerContent,
10+
HStack,
11+
Tag,
12+
Divider,
13+
Center,
14+
VStack,
15+
Box,
16+
DrawerCloseButton,
17+
} from "@chakra-ui/react";
18+
import { Question } from "../../models/Quesiton.model";
19+
import { ArrowRightIcon } from "@chakra-ui/icons";
20+
import { qnLoader } from "../../pages/ViewQuestionPage/ViewQuestion.page";
21+
import { diffToScheme } from "../../helper/UIHelper";
22+
23+
interface qnProp {
24+
question: Question;
25+
size: "xs" | "sm" | "md" | "lg" | "xl" | "full";
26+
}
27+
28+
export const QnDrawer = (prop: qnProp) => {
29+
const { question, size } = prop;
30+
const { isOpen, onOpen, onClose } = useDisclosure();
31+
32+
return (
33+
<>
34+
<IconButton
35+
aria-label="Open Question description"
36+
position="fixed"
37+
bottom="50%"
38+
left="-5px"
39+
zIndex="900" // Adjust the z-index to control layering
40+
onClick={onOpen}
41+
icon={<ArrowRightIcon />}
42+
colorScheme="blue"
43+
boxShadow="xl"
44+
/>
45+
46+
<Drawer onClose={onClose} isOpen={isOpen} size={size} placement="left">
47+
<DrawerOverlay />
48+
<DrawerContent>
49+
<DrawerCloseButton />
50+
<DrawerHeader>
51+
{question.displayedQuestion}
52+
<HStack spacing={2}>
53+
<Tag colorScheme={diffToScheme(question.difficulty)}>
54+
Difficulty: {question.difficulty}
55+
</Tag>
56+
<Divider orientation="vertical" padding="2"></Divider>
57+
{question.categories.map((qnTag) => (
58+
<Tag>{qnTag}</Tag>
59+
))}
60+
</HStack>
61+
</DrawerHeader>
62+
<DrawerBody>
63+
<Box>
64+
{question.descMd.split("\n").map((txt) => (
65+
<Text>{txt}</Text>
66+
))}
67+
</Box>
68+
</DrawerBody>
69+
</DrawerContent>
70+
</Drawer>
71+
</>
72+
);
73+
};

0 commit comments

Comments
 (0)