feat(ui): complete homepage overhaul with magicui animations, shiftable tools grid, bento grid, 3D visualizer, and marquee reviews
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { motion, useMotionValue, useSpring } from 'framer-motion';
|
||||
|
||||
export function SmoothCursor() {
|
||||
const [mounted, setMounted] = useState(false);
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
|
||||
const mouseX = useMotionValue(-100);
|
||||
const mouseY = useMotionValue(-100);
|
||||
|
||||
// Smooth spring physics for luxurious trailing movement
|
||||
const springConfig = { damping: 28, stiffness: 350, mass: 0.5 };
|
||||
const cursorX = useSpring(mouseX, springConfig);
|
||||
const cursorY = useSpring(mouseY, springConfig);
|
||||
|
||||
useEffect(() => {
|
||||
// Disable on touch devices
|
||||
if (typeof window === 'undefined') return;
|
||||
const isTouch = window.matchMedia('(pointer: coarse)').matches;
|
||||
if (isTouch) return;
|
||||
|
||||
setMounted(true);
|
||||
|
||||
const handleMouseMove = (e: MouseEvent) => {
|
||||
mouseX.set(e.clientX);
|
||||
mouseY.set(e.clientY);
|
||||
if (!isVisible) setIsVisible(true);
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => {
|
||||
setIsVisible(false);
|
||||
};
|
||||
|
||||
const handleMouseEnter = () => {
|
||||
setIsVisible(true);
|
||||
};
|
||||
|
||||
// Detect clickable/interactive hover targets
|
||||
const handleMouseOver = (e: MouseEvent) => {
|
||||
const target = e.target as HTMLElement | null;
|
||||
if (!target) return;
|
||||
const isInteractive = target.closest(
|
||||
'a, button, input, textarea, select, [role="button"], .cursor-pointer'
|
||||
);
|
||||
setIsHovered(!!isInteractive);
|
||||
};
|
||||
|
||||
window.addEventListener('mousemove', handleMouseMove);
|
||||
window.addEventListener('mouseleave', handleMouseLeave);
|
||||
window.addEventListener('mouseenter', handleMouseEnter);
|
||||
document.addEventListener('mouseover', handleMouseOver);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('mousemove', handleMouseMove);
|
||||
window.removeEventListener('mouseleave', handleMouseLeave);
|
||||
window.removeEventListener('mouseenter', handleMouseEnter);
|
||||
document.removeEventListener('mouseover', handleMouseOver);
|
||||
};
|
||||
}, [mouseX, mouseY, isVisible]);
|
||||
|
||||
if (!mounted || !isVisible) return null;
|
||||
|
||||
return (
|
||||
<div className="pointer-events-none fixed inset-0 z-[9999] overflow-hidden select-none">
|
||||
{/* Outer fluid halo aura */}
|
||||
<motion.div
|
||||
className="fixed top-0 left-0 rounded-full border border-blue-500/40 bg-blue-500/10 backdrop-blur-[1px]"
|
||||
style={{
|
||||
x: cursorX,
|
||||
y: cursorY,
|
||||
translateX: '-50%',
|
||||
translateY: '-50%',
|
||||
}}
|
||||
animate={{
|
||||
width: isHovered ? 48 : 28,
|
||||
height: isHovered ? 48 : 28,
|
||||
scale: isHovered ? 1.2 : 1,
|
||||
borderColor: isHovered ? 'rgba(59, 130, 246, 0.7)' : 'rgba(59, 130, 246, 0.35)',
|
||||
backgroundColor: isHovered ? 'rgba(59, 130, 246, 0.18)' : 'rgba(59, 130, 246, 0.08)',
|
||||
}}
|
||||
transition={{ type: 'spring', damping: 25, stiffness: 350 }}
|
||||
/>
|
||||
|
||||
{/* Inner sharp precision dot */}
|
||||
<motion.div
|
||||
className="fixed top-0 left-0 w-2 h-2 rounded-full bg-blue-600 shadow-sm"
|
||||
style={{
|
||||
x: mouseX,
|
||||
y: mouseY,
|
||||
translateX: '-50%',
|
||||
translateY: '-50%',
|
||||
}}
|
||||
animate={{
|
||||
scale: isHovered ? 0 : 1,
|
||||
opacity: isHovered ? 0 : 1,
|
||||
}}
|
||||
transition={{ duration: 0.15 }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user