el.xwx.moe/components/SubmitButton.tsx

35 lines
866 B
TypeScript
Raw Normal View History

2023-05-31 13:33:01 -05:00
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { IconDefinition } from "@fortawesome/free-regular-svg-icons";
type Props = {
onClick: Function;
icon?: IconDefinition;
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
? "bg-sky-400 cursor-auto"
: "bg-sky-500 hover:bg-sky-400 cursor-pointer"
} ${className}`}
onClick={() => {
if (!loading) onClick();
}}
2023-05-31 13:33:01 -05:00
>
{icon && <FontAwesomeIcon icon={icon} className="h-5" />}
<p className="text-center w-full">{label}</p>
2023-05-31 13:33:01 -05:00
</div>
);
}