Skip to content

Commit 8d9d0b6

Browse files
authored
Merge pull request #1 from pintoderian/main
Scroll in to view
2 parents cd3b744 + 12c83eb commit 8d9d0b6

File tree

1 file changed

+17
-12
lines changed
  • app/components/header/_children

1 file changed

+17
-12
lines changed

app/components/header/_children/menu.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import useTranslate from '@/hooks/useTranslate';
44
import { useMenuStore } from '@/store/menu';
5-
import Link from 'next/link';
65
import { useCallback } from 'react';
76

87
const 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
);

0 commit comments

Comments
 (0)