Portal/rsconcept/frontend/src/components/ui/SubmitButton.tsx

42 lines
1001 B
TypeScript
Raw Normal View History

2024-06-07 20:17:03 +03:00
import clsx from 'clsx';
import { CProps } from '../props';
interface SubmitButtonProps extends CProps.Button {
/** Text to display in the button. */
2024-06-07 20:17:03 +03:00
text?: string;
/** Icon to display in the button. */
2024-06-07 20:17:03 +03:00
icon?: React.ReactNode;
/** Indicates that loading is in progress. */
loading?: boolean;
2024-06-07 20:17:03 +03:00
}
/**
* Displays submit type button with icon and text.
*/
2024-06-07 20:17:03 +03:00
function SubmitButton({ text = 'ОК', icon, disabled, loading, className, ...restProps }: SubmitButtonProps) {
return (
<button
type='submit'
className={clsx(
'px-3 py-1 flex gap-2 items-center justify-center',
'border',
'font-medium',
2024-12-17 11:37:42 +03:00
'clr-btn-primary cc-animate-color',
2024-06-18 15:19:04 +03:00
'select-none disabled:cursor-auto',
2024-06-07 20:17:03 +03:00
loading && 'cursor-progress',
className
)}
disabled={disabled ?? loading}
{...restProps}
>
{icon ? <span>{icon}</span> : null}
{text ? <span>{text}</span> : null}
</button>
);
}
export default SubmitButton;