added scrollintoview
This commit is contained in:
parent
350fc82533
commit
905517a690
|
|
@ -19,6 +19,13 @@ export default function Navbar({ theme, setTheme }: Props) {
|
||||||
'Contact',
|
'Contact',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function scrollToSection(section: string): void {
|
||||||
|
const element = document.getElementById(section);
|
||||||
|
if (element) {
|
||||||
|
element.scrollIntoView({ behavior: 'smooth' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="navbar">
|
<div className="navbar">
|
||||||
<div className="navbar__name">{personalConfig.name}</div>
|
<div className="navbar__name">{personalConfig.name}</div>
|
||||||
|
|
@ -26,7 +33,7 @@ export default function Navbar({ theme, setTheme }: Props) {
|
||||||
{menuItems.map((item) => (
|
{menuItems.map((item) => (
|
||||||
<button
|
<button
|
||||||
key={item}
|
key={item}
|
||||||
/* onClick={() => scrollToSection(item.toLowerCase())} */
|
onClick={() => scrollToSection(item.toLowerCase())}
|
||||||
className="navbar__container__button"
|
className="navbar__container__button"
|
||||||
>
|
>
|
||||||
{item}
|
{item}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue