Skip to content

Commit 58a2dcb

Browse files
committed
Animate AddQuestion modal
1 parent e66823a commit 58a2dcb

File tree

5 files changed

+63
-16
lines changed

5 files changed

+63
-16
lines changed

frontend/package-lock.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"class-variance-authority": "^0.7.0",
2626
"clsx": "^2.1.1",
2727
"cmdk": "^1.0.0",
28+
"framer-motion": "^11.9.0",
2829
"js-cookie": "^3.0.5",
2930
"lucide-react": "^0.445.0",
3031
"next": "14.2.11",

frontend/src/app/(auth)/leetcode-dashboard/AddQuestionDialog.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const AddQuestionDialog = ({ setClose }: AddQuestionDialogProp) => {
8888
}
8989

9090
return (
91-
<div className="bg-primary-700 p-10 w-[40vw] h-[80vh] rounded-lg">
91+
<div className="bg-primary-700 p-10 w-[60vw] h-[80vh] rounded-lg">
9292
<div className="text-[32px] font-semibold text-yellow-500">
9393
Add Question
9494
</div>
@@ -172,7 +172,8 @@ const AddQuestionDialog = ({ setClose }: AddQuestionDialogProp) => {
172172
<Textarea
173173
placeholder="Type your description here."
174174
className="text-white bg-primary-800"
175-
{...field} // Bind the Textarea to form control
175+
rows={6}
176+
{...field}
176177
/>
177178
</FormControl>
178179
<FormMessage />

frontend/src/app/(auth)/leetcode-dashboard/page.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Container from "@/components/ui/Container";
77
import { PlusIcon } from "lucide-react";
88
import { useState } from "react";
99
import Modal from "react-modal";
10+
import { motion } from "framer-motion";
1011

1112
const LeetcodeDashboardHeader = () => {
1213
return (
@@ -34,6 +35,13 @@ const LeetcodeDashboard = () => {
3435
setIsOpen(false);
3536
}
3637

38+
// Define modal animation
39+
const modalAnimation = {
40+
hidden: { opacity: 0, scale: 0.9 },
41+
visible: { opacity: 1, scale: 1 },
42+
exit: { opacity: 0, scale: 0.9 },
43+
};
44+
3745
return (
3846
<Container>
3947
<LeetcodeDashboardHeader />
@@ -48,14 +56,24 @@ const LeetcodeDashboard = () => {
4856
<Modal
4957
isOpen={modalIsOpen}
5058
onRequestClose={closeModal}
51-
className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"
59+
ariaHideApp={false}
60+
className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-none"
5261
style={{
5362
overlay: {
5463
backgroundColor: "rgba(29, 36, 51, 0.8)",
5564
},
5665
}}
5766
>
58-
<AddQuestionDialog setClose={closeModal} />
67+
{/* Animated modal content */}
68+
<motion.div
69+
initial="hidden"
70+
animate="visible"
71+
exit="exit"
72+
variants={modalAnimation}
73+
transition={{ duration: 0.3 }}
74+
>
75+
<AddQuestionDialog setClose={closeModal} />
76+
</motion.div>
5977
</Modal>
6078
</div>
6179
<LeetcodeDashboardTable />

frontend/src/components/ui/button.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import * as React from "react"
2-
import { Slot } from "@radix-ui/react-slot"
3-
import { cva, type VariantProps } from "class-variance-authority"
1+
import * as React from "react";
2+
import { Slot } from "@radix-ui/react-slot";
3+
import { cva, type VariantProps } from "class-variance-authority";
44

5-
import { cn } from "@/lib/utils"
5+
import { cn } from "@/lib/utils";
66

77
const buttonVariants = cva(
88
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
99
{
1010
variants: {
1111
variant: {
12-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
12+
default:
13+
"bg-yellow-500 text-black hover:bg-yellow-300 hover:text-primary-700",
1314
destructive:
1415
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
1516
outline:
@@ -31,26 +32,26 @@ const buttonVariants = cva(
3132
size: "default",
3233
},
3334
}
34-
)
35+
);
3536

3637
export interface ButtonProps
3738
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
3839
VariantProps<typeof buttonVariants> {
39-
asChild?: boolean
40+
asChild?: boolean;
4041
}
4142

4243
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
4344
({ className, variant, size, asChild = false, ...props }, ref) => {
44-
const Comp = asChild ? Slot : "button"
45+
const Comp = asChild ? Slot : "button";
4546
return (
4647
<Comp
4748
className={cn(buttonVariants({ variant, size, className }))}
4849
ref={ref}
4950
{...props}
5051
/>
51-
)
52+
);
5253
}
53-
)
54-
Button.displayName = "Button"
54+
);
55+
Button.displayName = "Button";
5556

56-
export { Button, buttonVariants }
57+
export { Button, buttonVariants };

0 commit comments

Comments
 (0)