el.xwx.moe/components/SubmitButton.tsx

36 lines
786 B
TypeScript
Raw Normal View History

2023-05-31 13:33:01 -05:00
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
2023-07-03 09:45:25 -05:00
import { IconProp } from "@fortawesome/fontawesome-svg-core";
2023-05-31 13:33:01 -05:00
type Props = {
onClick?: Function;
2023-07-03 09:45:25 -05:00
icon?: IconProp;
2023-05-31 13:33:01 -05:00
label: string;
loading: boolean;
2023-05-31 13:33:01 -05:00
className?: string;
type?: "button" | "submit" | "reset" | undefined;
2023-05-31 13:33:01 -05:00
};
export default function SubmitButton({
onClick,
icon,
label,
loading,
2023-05-31 13:33:01 -05:00
className,
type,
2023-05-31 13:33:01 -05:00
}: Props) {
return (
<button
type={type ? type : undefined}
className={`btn btn-primary text-white tracking-wider w-fit flex items-center gap-2 ${
className || ""
}`}
onClick={() => {
if (!loading && onClick) onClick();
}}
2023-05-31 13:33:01 -05:00
>
{icon && <FontAwesomeIcon icon={icon} className="h-5" />}
<p>{label}</p>
</button>
2023-05-31 13:33:01 -05:00
);
}