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

27 lines
808 B
TypeScript
Raw Normal View History

interface SubmitButtonProps
extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'className' | 'children' | 'title'> {
text?: string
tooltip?: string
loading?: boolean
icon?: React.ReactNode
widthClass?: string
2023-07-15 17:46:19 +03:00
}
function SubmitButton({
text = 'ОК', icon, disabled, tooltip, loading,
widthClass = 'w-fit h-fit'
}: SubmitButtonProps) {
2023-07-15 17:46:19 +03:00
return (
<button type='submit'
title={tooltip}
2023-09-07 16:30:43 +03:00
className={`px-4 py-2 inline-flex items-center gap-2 align-middle justify-center font-semibold select-none disabled:cursor-not-allowed border rounded clr-btn-primary ${widthClass} ${loading ? ' cursor-progress' : ''}`}
2023-07-25 22:29:33 +03:00
disabled={disabled ?? loading}
2023-07-15 17:46:19 +03:00
>
{icon && <span>{icon}</span>}
{text && <span>{text}</span>}
2023-07-15 17:46:19 +03:00
</button>
)
}
2023-07-25 20:27:29 +03:00
export default SubmitButton;