{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "smart-hover-card-shadcnui", "type": "registry:component", "title": "Smart Hover Card", "description": "Card that detects cursor direction and reveals content from that side", "registryDependencies": [ "button", "card" ], "dependencies": [ "framer-motion", "react" ], "files": [ { "path": "@uitripled/react-shadcn/src/components/motion-core/smart-hover-card.tsx", "content": "\"use client\";\n\nimport { motion } from \"framer-motion\";\nimport { MouseEvent, useRef, useState } from \"react\";\n\ntype Direction = \"top\" | \"bottom\" | \"left\" | \"right\";\n\ntype SmartHoverCardProps = {\n title?: string;\n description?: string;\n children?: React.ReactNode;\n};\n\nexport function SmartHoverCard({\n title = \"Smart Hover Card\",\n description = \"Hover from different directions to see content reveal\",\n children,\n}: SmartHoverCardProps) {\n const [direction, setDirection] = useState(\"top\");\n const cardRef = useRef(null);\n\n const handleMouseEnter = (e: MouseEvent) => {\n if (!cardRef.current) return;\n\n const rect = cardRef.current.getBoundingClientRect();\n const centerX = rect.left + rect.width / 2;\n const centerY = rect.top + rect.height / 2;\n const mouseX = e.clientX;\n const mouseY = e.clientY;\n\n const deltaX = mouseX - centerX;\n const deltaY = mouseY - centerY;\n\n if (Math.abs(deltaX) > Math.abs(deltaY)) {\n setDirection(deltaX > 0 ? \"right\" : \"left\");\n } else {\n setDirection(deltaY > 0 ? \"bottom\" : \"top\");\n }\n };\n\n const cardVariants = {\n top: {\n clipPath: \"inset(0% 0% 50% 0%)\",\n y: -20,\n opacity: 0,\n },\n bottom: {\n clipPath: \"inset(50% 0% 0% 0%)\",\n y: 20,\n opacity: 0,\n },\n left: {\n clipPath: \"inset(0% 50% 0% 0%)\",\n x: -20,\n opacity: 0,\n },\n right: {\n clipPath: \"inset(0% 0% 0% 50%)\",\n x: 20,\n opacity: 0,\n },\n };\n\n const revealVariants = {\n top: { clipPath: \"inset(0% 0% 0% 0%)\", y: 0, opacity: 1 },\n bottom: { clipPath: \"inset(0% 0% 0% 0%)\", y: 0, opacity: 1 },\n left: { clipPath: \"inset(0% 0% 0% 0%)\", x: 0, opacity: 1 },\n right: { clipPath: \"inset(0% 0% 0% 0%)\", x: 0, opacity: 1 },\n };\n\n return (\n \n
\n
\n

{title}

\n

{description}

\n
\n
\n\n \n {children || (\n
\n
\n

Revealed Content

\n

\n Direction: {direction}\n

\n
\n )}\n \n \n );\n}\n", "type": "registry:component", "target": "components/uitripled/smart-hover-card-shadcnui.tsx" } ] }