ConceptPortal-public/rsconcept/frontend/src/components/Common/SubmitButton.tsx

34 lines
802 B
TypeScript
Raw Normal View History

import clsx from 'clsx';
import { CProps } from '../props';
2023-12-28 14:04:44 +03:00
interface SubmitButtonProps extends CProps.Button {
text?: string;
loading?: boolean;
icon?: React.ReactNode;
2023-07-15 17:46:19 +03:00
}
2023-12-28 14:04:44 +03:00
function SubmitButton({ text = 'ОК', icon, disabled, loading, className, ...restProps }: SubmitButtonProps) {
2023-07-15 17:46:19 +03:00
return (
2023-12-28 14:04:44 +03:00
<button
type='submit'
className={clsx(
2023-12-30 19:43:24 +03:00
'px-3 py-1 flex gap-2 items-center justify-center',
2023-12-28 14:04:44 +03:00
'border',
2023-12-30 19:43:24 +03:00
'font-medium',
2023-12-28 14:04:44 +03:00
'clr-btn-primary',
'select-none disabled:cursor-not-allowed',
loading && 'cursor-progress',
className
)}
disabled={disabled ?? loading}
{...restProps}
>
{icon ? <span>{icon}</span> : null}
{text ? <span>{text}</span> : null}
</button>
);
2023-07-15 17:46:19 +03:00
}
2023-12-28 14:04:44 +03:00
export default SubmitButton;