feat : in intro component button andd scroll to products(configs) section(div)
This commit is contained in:
22
src/components/scrollLink/index.tsx
Normal file
22
src/components/scrollLink/index.tsx
Normal 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;
|
||||
Reference in New Issue
Block a user