-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToolCard.tsx
More file actions
63 lines (57 loc) · 1.39 KB
/
ToolCard.tsx
File metadata and controls
63 lines (57 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"use client";
import { FramerMotionSVGProps } from "@/utils/types/svg";
import { motion } from "framer-motion";
import { ComponentType, useState } from "react";
type ToolCardProps = {
index: number;
icon: ComponentType<FramerMotionSVGProps>;
title: string;
};
export function ToolCard(props: ToolCardProps) {
const [hovered, setHovered] = useState(false);
const cardAnimations = {
initial: {
opacity: 0,
y: -20,
},
whileInView: {
opacity: 1,
y: 0,
transition: {
ease: "easeOut",
duration: 0.5,
delay: props.index * 0.1,
},
},
whileHover: {
scale: 1.05,
},
};
const iconAnimations = {
initial: {
opacity: 0,
y: -20,
},
whileInView: {
opacity: 1,
y: 0,
},
};
return (
<motion.div
className="bg-dark-500 flex aspect-square h-full w-full cursor-pointer flex-col items-center justify-center rounded-xl"
onHoverStart={() => setHovered(true)}
onHoverEnd={() => setHovered(false)}
onTap={() => setHovered(!hovered)}
{...cardAnimations}
>
{hovered ? (
<motion.span className="text-light-500 text-xl font-bold" {...iconAnimations}>
{props.title}
</motion.span>
) : (
<props.icon className="fill-light-500 stroke-dark-500 min-w-20 w-1/2" {...iconAnimations} />
)}
</motion.div>
);
}