aboutsummaryrefslogtreecommitdiff
path: root/packages/ui/components/cardClick.tsx
blob: 2109c497f4354667ee4d1e0735ccaa3c9af35e48 (plain) (blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"use client";

import { cn } from "@repo/ui/lib/utils";
import { AnimatePresence, motion } from "framer-motion";
import React from "react";

export const CardClick = ({
	tab,
	handleClickIndex,
	items,
}: {
	tab: number;
	handleClickIndex: (tab: number) => void;
	items: {
		title: string;
		description: string;
		svg: React.ReactNode;
	}[];
}) => {
	return (
		<div className={cn("flex flex-col")}>
			{items.map((item, idx) => (
				<div
					key={idx}
					className="group relative  block h-full w-full cursor-pointer rounded-2xl p-2 border border-transparent hover:bg-page-gradient  hover:border hover:border-white/20 rounded-3xl mt-1"
					onMouseDown={() => handleClickIndex(idx)}
				>
					<AnimatePresence>
						{tab === idx && (
							<motion.span
								className="absolute inset-0 -z-[1] block h-full w-full rounded-3xl bg-page-gradient [background:linear-gradient(#2E2E32,#2E2E32),linear-gradient(120deg,theme(colors.zinc.700),theme(colors.zinc.700/0),theme(colors.zinc.700))]"
								layoutId="hoverBackground"
								initial={{ opacity: 0 }}
								animate={{
									opacity: 1,
									transition: { duration: 0.15 },
								}}
								exit={{
									opacity: 0,
									transition: { duration: 0.15, delay: 0.2 },
								}}
							/>
						)}
					</AnimatePresence>
					<Card
						title={item.title}
						description={item.description}
						svg={item.svg}
					/>
				</div>
			))}
		</div>
	);
};

export const Card = ({
	title,
	description,
	svg,
}: {
	title: string;
	description: string;
	svg: React.ReactNode;
}) => {
	return (
		<div
			className={`flex items-center rounded-2xl border border-transparent px-6 py-4 text-left`}
		>
			{svg}
			<div>
				<div className="font-inter-tight mb-1 text-lg font-semibold text-zinc-200">
					{title}
				</div>
				<div className="text-zinc-500">{description}</div>
			</div>
		</div>
	);
};