Files
overleaf-cep/services/web/frontend/js/features/ui/components/bootstrap-5/button.tsx
T
Rebeka Dekany 21b5e44c50 Merge pull request #16925 from overleaf/rd-dropdown-bootstrap5
Bootstrap-5 Dropdown menu component

GitOrigin-RevId: 8a74f2341eebf953367ab73946d72e8aa7bd3c13
2024-02-26 09:03:05 +00:00

34 lines
767 B
TypeScript

import { Button as BootstrapButton } from 'react-bootstrap-5'
import type { ButtonProps } from '@/features/ui/components/types/button-props'
const sizeClasses = new Map<ButtonProps['size'], string>([
['small', 'btn-sm'],
['default', ''],
['large', 'btn-lg'],
])
// TODO: Display a spinner when `loading` is true
function Button({
variant = 'primary',
size = 'default',
disabled = false,
loading = false,
children,
className,
}: ButtonProps) {
const sizeClass = sizeClasses.get(size)
return (
<BootstrapButton
className={sizeClass + ' ' + className}
variant={variant}
disabled={disabled}
{...(loading ? { 'data-ol-loading': true } : null)}
>
{children}
</BootstrapButton>
)
}
export default Button