Skip to content

Commit 05bb572

Browse files
web(ui): testing comp
1 parent 320719c commit 05bb572

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

app/testcomp/page.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import SlideCardStack from "@/components/ui/smart-card-stack";
2+
3+
export default function TestComp() {
4+
return (
5+
<div className="h-screen flex items-center justify-center">
6+
<SlideCardStack />
7+
</div>
8+
);
9+
}

components/ui/smart-card-stack.tsx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"use client";
2+
import { motion } from "motion/react";
3+
4+
const topCard = {
5+
rest: { rotate: 0 },
6+
hover: { rotate: 0 },
7+
};
8+
9+
const middleCard = {
10+
rest: { rotate: 0 },
11+
hover: { rotate: 6 },
12+
};
13+
14+
const bottomCard = {
15+
rest: { rotate: 0 },
16+
hover: { rotate: -6 },
17+
};
18+
19+
export default function SlideCardStack() {
20+
return (
21+
<motion.div
22+
initial="rest"
23+
whileHover="hover"
24+
className="border border-[#373737] h-96 w-96 rounded-2xl relative "
25+
>
26+
{/* Bottom card (tilts UP) */}
27+
<motion.div
28+
variants={bottomCard}
29+
transition={{ type: "spring", stiffness: 300, damping: 20 }}
30+
style={{ transformOrigin: "top left" }}
31+
className="absolute inset-0 m-auto w-72 h-44 translate-y-2 rounded-2xl border border-[#272628] bg-[#121212] p-6 text-[#848484] shadow-xl"
32+
>
33+
<h3 className="text-lg font-semibold">Bottom Card</h3>
34+
<p className="text-sm opacity-70">Tilts up on hover</p>
35+
36+
<div className="mt-5 h-3 bg-[#272628] rounded-sm" />
37+
<div className="mt-2 h-3 bg-[#272628] rounded-sm" />
38+
</motion.div>
39+
40+
{/* Middle card (tilts DOWN) */}
41+
<motion.div
42+
variants={middleCard}
43+
transition={{ type: "spring", stiffness: 300, damping: 20 }}
44+
style={{ transformOrigin: "top left" }}
45+
className="absolute inset-0 m-auto w-72 h-44 translate-y-1 rounded-2xl border border-[#272628] bg-[#121212] p-6 text-[#848484] shadow-xl"
46+
>
47+
<h3 className="text-lg font-semibold">Middle Card</h3>
48+
<p className="text-sm opacity-70">Tilts down on hover</p>
49+
50+
<div className="mt-5 h-3 bg-[#272628] rounded-sm" />
51+
<div className="mt-2 h-3 bg-[#272628] rounded-sm" />
52+
</motion.div>
53+
54+
{/* Top card (does NOTHING) */}
55+
<motion.div
56+
variants={topCard}
57+
transition={{ type: "spring", stiffness: 300, damping: 20 }}
58+
style={{ transformOrigin: "top left" }}
59+
className="absolute inset-0 m-auto w-72 h-44 rounded-2xl border border-[#272628] bg-[#121212] p-6 text-[#848484] shadow-xl"
60+
>
61+
<div className="text-lg font-semibold h-10 w-10 rounded-full bg-[#272628]"></div>
62+
<p className="text-sm opacity-70 bg-[#272628] h-3 w-12 rounded-md mt-3"></p>
63+
64+
<div className="mt-5 h-3 bg-[#272628] rounded-sm" />
65+
<div className="mt-2 h-3 bg-[#272628] rounded-sm" />
66+
</motion.div>
67+
</motion.div>
68+
);
69+
}

0 commit comments

Comments
 (0)