2022-07-25 17:31:20 +00:00
|
|
|
import {
|
|
|
|
AnchorHTMLAttributes,
|
|
|
|
ButtonHTMLAttributes,
|
|
|
|
DetailedHTMLProps,
|
|
|
|
} from 'react';
|
2022-07-27 21:10:23 +00:00
|
|
|
import Link from 'next/link';
|
2022-08-01 16:17:59 +00:00
|
|
|
import { UrlObject } from 'url';
|
2022-07-25 17:22:59 +00:00
|
|
|
|
2022-07-26 14:32:57 +00:00
|
|
|
interface CustomProps {
|
|
|
|
noDefaultColous?: boolean;
|
|
|
|
}
|
|
|
|
|
2022-07-25 17:31:20 +00:00
|
|
|
export default function Button({
|
|
|
|
className,
|
2022-07-26 14:32:57 +00:00
|
|
|
noDefaultColous,
|
2022-07-25 17:31:20 +00:00
|
|
|
...props
|
|
|
|
}: DetailedHTMLProps<
|
|
|
|
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
|
|
HTMLButtonElement
|
2022-07-26 14:32:57 +00:00
|
|
|
> &
|
|
|
|
CustomProps) {
|
|
|
|
const classes = [className];
|
|
|
|
classes.push(
|
|
|
|
'p-2',
|
|
|
|
'rounded',
|
|
|
|
'shadow',
|
|
|
|
'shadow-slate-800',
|
|
|
|
'transition-colors'
|
2022-07-25 17:31:20 +00:00
|
|
|
);
|
2022-07-26 14:32:57 +00:00
|
|
|
if (!noDefaultColous) {
|
2022-07-26 21:18:54 +00:00
|
|
|
classes.push(
|
|
|
|
'bg-slate-600',
|
|
|
|
'text-slate-50',
|
|
|
|
'hover:bg-slate-500',
|
|
|
|
'disabled:bg-slate-900',
|
|
|
|
'disabled:text-slate-200'
|
|
|
|
);
|
2022-07-26 14:32:57 +00:00
|
|
|
}
|
|
|
|
return <button className={classes.join(' ')} {...props} />;
|
2022-07-25 17:22:59 +00:00
|
|
|
}
|
|
|
|
|
2022-08-01 16:17:59 +00:00
|
|
|
type LinkButtonProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> & {
|
|
|
|
href: string | UrlObject;
|
|
|
|
};
|
2022-07-25 17:22:59 +00:00
|
|
|
|
2022-08-01 16:20:29 +00:00
|
|
|
export function LinkButton({
|
|
|
|
className,
|
|
|
|
children,
|
|
|
|
href,
|
|
|
|
...props
|
|
|
|
}: LinkButtonProps) {
|
2022-07-25 17:31:20 +00:00
|
|
|
return (
|
2022-08-01 16:17:59 +00:00
|
|
|
<Link href={href}>
|
2022-07-27 21:10:23 +00:00
|
|
|
<a
|
|
|
|
className={'text-blue-200 hover:underline ' + (className || '')}
|
|
|
|
{...props}
|
|
|
|
>
|
2022-07-25 17:31:20 +00:00
|
|
|
{children}
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
);
|
2022-07-25 17:22:59 +00:00
|
|
|
}
|