File tree Expand file tree Collapse file tree 1 file changed +17
-12
lines changed
Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change 22
33import useTranslate from '@/hooks/useTranslate' ;
44import { useMenuStore } from '@/store/menu' ;
5- import Link from 'next/link' ;
65import { useCallback } from 'react' ;
76
87const Menu = ( { className } ) => {
@@ -18,27 +17,33 @@ const Menu = ({ className }) => {
1817 [ active ]
1918 ) ;
2019
20+ const handleAction = useCallback (
21+ ( value ) => {
22+ setActive ( value ) ;
23+ const element = document ?. getElementById ( value ) ;
24+ element ?. scrollIntoView ( {
25+ behavior : 'smooth'
26+ } ) ;
27+ } ,
28+ [ setActive ]
29+ ) ;
30+
2131 return (
2232 < ul className = { `gap-4 ${ className } ` } >
2333 < li className = { activeClass ( 'about' ) } >
24- < Link href = "#about" onClick = { ( ) => setActive ( 'about' ) } >
34+ < button onClick = { ( ) => handleAction ( 'about' ) } >
2535 { translate ( 'about' ) }
26- </ Link >
36+ </ button >
2737 </ li >
2838 < li className = { activeClass ( 'experience' ) } >
29- < Link href = "#experience" onClick = { ( ) => setActive ( 'experience' ) } >
39+ < button onClick = { ( ) => handleAction ( 'experience' ) } >
3040 { translate ( 'experience' ) }
31- </ Link >
41+ </ button >
3242 </ li >
33- { /*<li className={activeClass('proyects')}>
34- <Link href="#proyects" onClick={() => setActive('proyects')}>
35- {translate('proyects')}
36- </Link>
37- </li>*/ }
3843 < li className = { activeClass ( 'skills' ) } >
39- < Link href = "#skills" onClick = { ( ) => setActive ( 'skills' ) } >
44+ < button onClick = { ( ) => handleAction ( 'skills' ) } >
4045 { translate ( 'skills' ) }
41- </ Link >
46+ </ button >
4247 </ li >
4348 </ ul >
4449 ) ;
You can’t perform that action at this time.
0 commit comments