17 lines
569 B
TypeScript
Executable File
17 lines
569 B
TypeScript
Executable File
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);
|
|
}
|
|
|
|
export function formatNumber(num: number) {
|
|
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1 ');
|
|
} |