feat : in intro component button andd scroll to products(configs) section(div)

This commit is contained in:
alij
2024-06-23 16:33:10 +04:30
parent d2f6242a5b
commit 8c91e5bf14
4 changed files with 34 additions and 4 deletions

View File

@@ -0,0 +1,22 @@
// components/SmoothScrollLink.tsx
import React from 'react';
import { ScrollLinkProps } from '../../types/props';
const SmoothScrollLink: React.FC<ScrollLinkProps> = ({ to, children }) => {
const handleClick = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
event.preventDefault();
const targetElement = document.querySelector(to);
if (targetElement) {
targetElement.scrollIntoView({ behavior: 'smooth' });
}
};
return (
<a href={to} onClick={handleClick}>
{children}
</a>
);
};
export default SmoothScrollLink;