2022-12-13 20:56:09 +00:00
|
|
|
import clsx from 'clsx';
|
2022-12-07 14:51:20 +00:00
|
|
|
import { ComponentProps } from 'react';
|
|
|
|
|
|
|
|
import { Button } from './buttons';
|
|
|
|
import { Link } from './Link';
|
|
|
|
|
|
|
|
export function LinkButton({
|
|
|
|
to,
|
|
|
|
params,
|
|
|
|
disabled,
|
|
|
|
children,
|
2022-12-13 20:56:09 +00:00
|
|
|
className,
|
2022-12-07 14:51:20 +00:00
|
|
|
...props
|
|
|
|
}: ComponentProps<typeof Button> & ComponentProps<typeof Link>) {
|
|
|
|
const button = (
|
|
|
|
<Button
|
|
|
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
|
|
{...props}
|
2022-12-13 20:56:09 +00:00
|
|
|
className={clsx(className, '!m-0')}
|
2022-12-07 14:51:20 +00:00
|
|
|
size="medium"
|
|
|
|
disabled={disabled}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
|
|
|
|
if (disabled) {
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Link to={to} params={params} className="text-inherit hover:no-underline">
|
|
|
|
{button}
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
}
|