el.xwx.moe/components/SubmitButton.tsx

35 lines
876 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;
};
export default function SubmitButton({
onClick,
icon,
label,
loading,
2023-05-31 13:33:01 -05:00
className,
}: Props) {
return (
<div
className={`text-white flex items-center gap-2 py-2 px-5 rounded-md text-lg tracking-wide select-none font-semibold duration-100 w-fit ${
loading
2023-07-22 16:49:09 -05:00
? "bg-sky-600 cursor-auto"
: "bg-sky-700 hover:bg-sky-600 cursor-pointer"
} ${className}`}
onClick={() => {
if (!loading) onClick();
}}
2023-05-31 13:33:01 -05:00
>
{icon && <FontAwesomeIcon icon={icon} className="h-5 select-none" />}
<p className="text-center w-full select-none">{label}</p>
2023-05-31 13:33:01 -05:00
</div>
);
}