comicbox/components/Button.tsx

53 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-07-25 17:31:20 +00:00
import {
AnchorHTMLAttributes,
ButtonHTMLAttributes,
DetailedHTMLProps,
RefAttributes,
} from 'react';
import Link, { LinkProps } from 'next/link';
interface CustomProps {
noDefaultColous?: boolean;
}
2022-07-25 17:31:20 +00:00
export default function Button({
className,
noDefaultColous,
2022-07-25 17:31:20 +00:00
...props
}: DetailedHTMLProps<
ButtonHTMLAttributes<HTMLButtonElement>,
HTMLButtonElement
> &
CustomProps) {
const classes = [className];
classes.push(
'p-2',
'rounded',
'shadow',
'shadow-slate-800',
'transition-colors'
2022-07-25 17:31:20 +00:00
);
if (!noDefaultColous) {
2022-07-26 21:02:44 +00:00
classes.push('bg-slate-600', 'text-slate-50', 'hover:bg-slate-500', 'disabled:bg-slate-900', 'disabled:text-slate-200');
}
return <button className={classes.join(' ')} {...props} />;
}
2022-07-25 17:31:20 +00:00
type LinkButtonProps = Omit<
AnchorHTMLAttributes<HTMLAnchorElement>,
keyof LinkProps
> &
LinkProps & {
children?: React.ReactNode;
} & RefAttributes<HTMLAnchorElement>;
export function LinkButton({ className, children, ...props }: LinkButtonProps) {
2022-07-25 17:31:20 +00:00
return (
<Link {...props}>
<a className={'text-blue-200 hover:underline ' + (className || '')}>
{children}
</a>
</Link>
);
}