diff --git a/components/Card.tsx b/components/Card.tsx
index e6978d0..cbbf34d 100644
--- a/components/Card.tsx
+++ b/components/Card.tsx
@@ -1,6 +1,7 @@
'use client';
import { useState } from 'react';
+import TiltCard from '@/components/TiltCard';
import ToolTip from '@/components/ToolTip';
import StackTheDeck from '@/components/StackTheDeck';
import tarokkaCards from '@/constants/tarokkaCards';
@@ -57,8 +58,8 @@ export default function Card({
return (
-
-
+
);
}
diff --git a/components/TiltCard.tsx b/components/TiltCard.tsx
new file mode 100644
index 0000000..8c16b54
--- /dev/null
+++ b/components/TiltCard.tsx
@@ -0,0 +1,48 @@
+import { useRef } from 'react';
+
+export default function TiltCard({
+ children,
+ className = '',
+ onClick = () => {},
+}: {
+ children: React.ReactNode;
+ className?: string;
+ onClick: (event: React.MouseEvent) => void;
+}) {
+ const cardRef = useRef(null);
+
+ const handleMouseMove = (e: React.MouseEvent) => {
+ const card = cardRef.current;
+ if (!card) return;
+
+ const rect = card.getBoundingClientRect();
+ const x = e.clientX - rect.left;
+ const y = e.clientY - rect.top;
+ const centerX = rect.width / 2;
+ const centerY = rect.height / 2;
+
+ const rotateX = ((y - centerY) / centerY) * -20;
+ const rotateY = ((x - centerX) / centerX) * 20;
+
+ card.style.transform = `rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
+ };
+
+ const handleMouseLeave = () => {
+ const card = cardRef.current;
+ if (!card) return;
+ card.style.transform = `rotateX(0deg) rotateY(0deg)`;
+ };
+
+ return (
+
+ );
+}