import React, { FC, AnchorHTMLAttributes } from 'react';
import classNames from 'classnames';
export interface ForwardProps extends AnchorHTMLAttributes {
/** Classi aggiuntive da usare per il componente Forward */
className?: string;
/** Riferimento al nodo a cui scorrere quando premuto */
// scrollToRef: MutableRefObject;
testId?: string;
}
export const Forward: FC = ({ className, children, testId, ...attributes }) => {
const classes = classNames(className, 'forward');
return (
{
e.preventDefault();
if (attributes.href) {
const scrollToRef = document.querySelector(attributes.href);
if (scrollToRef) {
scrollToRef.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
}
}}
data-testid={testId}
{...attributes}
>
{children}
);
};