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

48 lines
1.1 KiB
TypeScript
Raw Normal View History

import clsx from 'clsx';
import { IColorsProps, IControlProps } from './commonInterfaces';
2023-11-05 16:31:49 +03:00
2023-07-25 22:29:33 +03:00
interface ButtonProps
2023-11-05 16:31:49 +03:00
extends IControlProps, IColorsProps, Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'className' | 'children' | 'title'| 'type'> {
2023-07-15 17:46:19 +03:00
text?: string
icon?: React.ReactNode
2023-11-05 16:31:49 +03:00
2023-07-15 17:46:19 +03:00
dense?: boolean
loading?: boolean
}
2023-07-25 20:27:29 +03:00
function Button({
2023-10-06 14:39:32 +03:00
text, icon, tooltip,
2023-11-05 16:31:49 +03:00
dense, disabled, noBorder, noOutline,
colors = 'clr-btn-default',
dimensions = 'w-fit h-fit',
2023-10-06 14:39:32 +03:00
loading,
...restProps
2023-07-20 17:11:03 +03:00
}: ButtonProps) {
2023-07-15 17:46:19 +03:00
return (
<button type='button'
disabled={disabled ?? loading}
title={tooltip}
className={clsx(
'inline-flex gap-2 items-center justify-center',
'select-none disabled:cursor-not-allowed',
{
'border rounded': !noBorder,
'px-1': dense,
'px-3 py-2': !dense,
'cursor-progress': loading,
'cursor-pointer': !loading,
'outline-none': noOutline,
'clr-outline': !noOutline,
},
colors,
dimensions
)}
{...restProps}
>
{icon ? icon : null}
{text ? <span className='font-semibold'>{text}</span> : null}
</button>);
2023-07-15 17:46:19 +03:00
}
export default Button;