Portal/rsconcept/frontend/src/components/control/submit-button.tsx

40 lines
976 B
TypeScript
Raw Normal View History

2024-06-07 20:17:03 +03:00
import clsx from 'clsx';
2025-02-20 20:22:05 +03:00
import { type Button } from '../props';
2024-06-07 20:17:03 +03:00
2025-02-20 20:22:05 +03:00
interface SubmitButtonProps extends 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.
*/
2025-02-07 10:53:49 +03:00
export function SubmitButton({ text = 'ОК', icon, disabled, loading, className, ...restProps }: SubmitButtonProps) {
2024-06-07 20:17:03 +03:00
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',
2025-04-07 22:25:53 +03:00
'select-none cursor-pointer disabled:cursor-auto',
2024-06-07 20:17:03 +03:00
loading && 'cursor-progress',
className
)}
2025-01-21 20:33:05 +03:00
disabled={disabled || loading}
2024-06-07 20:17:03 +03:00
{...restProps}
>
2025-03-09 21:57:21 +03:00
{icon ? icon : null}
2024-06-07 20:17:03 +03:00
{text ? <span>{text}</span> : null}
</button>
);
}