File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 1
1
import clsx from 'clsx' ;
2
+ import { MouseEvent } from 'react' ;
2
3
import { Link } from 'react-router-dom' ;
3
4
4
5
import Button from './Button' ;
@@ -36,6 +37,17 @@ const NavigationMenu = ({ openState }: { openState: boolean }) => {
36
37
element . click ( ) ;
37
38
} ;
38
39
40
+ const handelNavigation = ( e : MouseEvent < HTMLAnchorElement > ) => {
41
+ e . preventDefault ( ) ;
42
+ const path = ( e . target as HTMLAnchorElement ) . getAttribute ( 'href' ) ;
43
+ if ( ! path ) return ;
44
+ document . querySelector ( path ) ?. scrollIntoView ( {
45
+ behavior : 'smooth' ,
46
+ block : 'start' ,
47
+ inline : 'start' ,
48
+ } ) ;
49
+ } ;
50
+
39
51
return (
40
52
< >
41
53
{ /* Desktop Navbar */ }
@@ -44,9 +56,13 @@ const NavigationMenu = ({ openState }: { openState: boolean }) => {
44
56
< ul className = "flex gap-4" >
45
57
{ menuItems . map ( item => (
46
58
< li key = { item . id } >
47
- < Link to = { item . path } className = "font-medium text-white" >
59
+ < a
60
+ href = { item . path }
61
+ className = "font-medium text-white"
62
+ onClick = { handelNavigation }
63
+ >
48
64
{ item . itemName }
49
- </ Link >
65
+ </ a >
50
66
</ li >
51
67
) ) }
52
68
</ ul >
You can’t perform that action at this time.
0 commit comments