umami/src/components/common/LinkButton.tsx

31 lines
699 B
TypeScript
Raw Normal View History

2023-10-03 18:45:02 +02:00
import classNames from 'classnames';
2023-07-30 09:11:26 +02:00
import Link from 'next/link';
2023-10-03 18:45:02 +02:00
import { useLocale } from 'components/hooks';
2023-10-08 03:55:14 +02:00
import styles from './LinkButton.module.css';
2023-11-13 23:12:05 +01:00
import { ReactNode } from 'react';
2023-10-03 18:45:02 +02:00
2023-11-13 23:12:05 +01:00
export interface LinkButtonProps {
href: string;
2023-11-14 06:36:52 +01:00
className?: string;
2023-11-13 23:12:05 +01:00
variant?: string;
scroll?: boolean;
children?: ReactNode;
}
export function LinkButton({ href, className, variant, scroll = true, children }: LinkButtonProps) {
2023-10-03 18:45:02 +02:00
const { dir } = useLocale();
2023-07-30 09:11:26 +02:00
return (
2023-10-15 22:12:29 +02:00
<Link
className={classNames(styles.button, className, { [styles[variant]]: true })}
href={href}
dir={dir}
2023-10-17 20:27:35 +02:00
scroll={scroll}
2023-10-15 22:12:29 +02:00
>
2023-10-08 03:55:14 +02:00
{children}
2023-07-30 09:11:26 +02:00
</Link>
);
}
export default LinkButton;