button.tsx 767 B

123456789101112131415161718192021222324252627282930313233
  1. import { Button as BootstrapButton } from 'react-bootstrap-5'
  2. import type { ButtonProps } from '@/features/ui/components/types/button-props'
  3. const sizeClasses = new Map<ButtonProps['size'], string>([
  4. ['small', 'btn-sm'],
  5. ['default', ''],
  6. ['large', 'btn-lg'],
  7. ])
  8. // TODO: Display a spinner when `loading` is true
  9. function Button({
  10. variant = 'primary',
  11. size = 'default',
  12. disabled = false,
  13. loading = false,
  14. children,
  15. className,
  16. }: ButtonProps) {
  17. const sizeClass = sizeClasses.get(size)
  18. return (
  19. <BootstrapButton
  20. className={sizeClass + ' ' + className}
  21. variant={variant}
  22. disabled={disabled}
  23. {...(loading ? { 'data-ol-loading': true } : null)}
  24. >
  25. {children}
  26. </BootstrapButton>
  27. )
  28. }
  29. export default Button