Frontend/src/core/helpers.ts
2022-07-18 11:38:44 +03:00

13 lines
439 B
TypeScript

export const handleScrollTo = (e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault();
const link: HTMLAnchorElement = e.currentTarget;
if (link.hash && link.hash != "") {
document
.getElementById(link.hash.substring(1, undefined))
?.scrollIntoView({ behavior: "smooth", block: "start" });
}
};
export function capitalization (str: string) {
return str.substring(0,1).toUpperCase() + str.substring(1);
}