Portal/rsconcept/frontend/src/components/control/submit-button.tsx
2025-04-07 22:25:53 +03:00

40 lines
976 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import clsx from 'clsx';
import { type Button } from '../props';
interface SubmitButtonProps extends Button {
/** Text to display in the button. */
text?: string;
/** Icon to display in the button. */
icon?: React.ReactNode;
/** Indicates that loading is in progress. */
loading?: boolean;
}
/**
* Displays submit type button with icon and text.
*/
export 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',
'clr-btn-primary cc-animate-color',
'select-none cursor-pointer disabled:cursor-auto',
loading && 'cursor-progress',
className
)}
disabled={disabled || loading}
{...restProps}
>
{icon ? icon : null}
{text ? <span>{text}</span> : null}
</button>
);
}