11import { motion } from "framer-motion" ;
2- import { useState } from "react" ;
2+ import { useState , useRef } from "react" ;
3+
34
45const steps = [
56 {
@@ -33,6 +34,8 @@ const steps = [
3334
3435export default function GalleryFeatures ( ) {
3536 const [ activeStep , setActiveStep ] = useState < number | null > ( null ) ;
37+ const hoverTimers = useRef < Record < number , number | null > > ( { } ) ;
38+
3639
3740 return (
3841 < section className = "py-20 bg-gray-50 dark:bg-black transition-colors duration-300" >
@@ -51,17 +54,25 @@ export default function GalleryFeatures() {
5154 whileHover = { { y : - 5 } }
5255 >
5356 < div
54- className = { `bg-white dark:bg-[#121212] /* Off-Black Card */
55- rounded-xl border border-gray-200 dark:border-gray-800
56- shadow-md hover:shadow-lg
57- p-6 cursor-pointer h-full /* Change cursor to pointer on hover */
58- transition-all duration-300
59- relative
60- ${ activeStep === index ? 'ring-2 ring-pink-500 dark:ring-pink-400' : '' } ` }
61- onClick = { ( ) => setActiveStep ( activeStep === index ? null : index ) }
62- style = { {
63- cursor : `url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"%3E%3Ctext x="10" y="40" font-size="40"%3E${ encodeURIComponent ( step . icon ) } %3C/text%3E%3C/svg%3E'), auto`
57+ onMouseEnter = { ( ) => {
58+ // start a 1s timer to set active only if remains hovered
59+ hoverTimers . current [ index ] = window . setTimeout ( ( ) => {
60+ setActiveStep ( index ) ;
61+ hoverTimers . current [ index ] = null ;
62+ } , 1000 ) ;
6463 } }
64+ onMouseLeave = { ( ) => {
65+ // cancel timer if leaving early; if already active, hide immediately
66+ const t = hoverTimers . current [ index ] ;
67+ if ( t ) {
68+ clearTimeout ( t ) ;
69+ hoverTimers . current [ index ] = null ;
70+ }
71+ if ( activeStep === index ) setActiveStep ( null ) ;
72+ } }
73+
74+ className = { `bg-white dark:bg-[#121212] rounded-xl border border-gray-200 dark:border-gray-800 shadow-md hover:shadow-lg p-6 cursor-pointer h-full transition-all duration-300 relative ${ activeStep === index ? 'ring-2 ring-pink-500 dark:ring-pink-400' : '' } ` }
75+
6576 >
6677 { /* Step Number Badge */ }
6778 < div className = "absolute -top-4 left-4 bg-gradient-to-br from-yellow-500 to-green-600 dark:from-green-400 dark:to-yellow-500 text-white rounded-full w-10 h-10 flex items-center justify-center shadow-lg" >
0 commit comments