ds-button.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { forwardRef, ReactNode } from 'react'
  2. import { Button, ButtonProps } from 'react-bootstrap'
  3. type DSButtonProps = Pick<
  4. ButtonProps,
  5. | 'children'
  6. | 'disabled'
  7. | 'href'
  8. | 'id'
  9. | 'target'
  10. | 'rel'
  11. | 'onClick'
  12. | 'onMouseDown'
  13. | 'onMouseOver'
  14. | 'onMouseOut'
  15. | 'onFocus'
  16. | 'onBlur'
  17. | 'size'
  18. | 'active'
  19. | 'type'
  20. > & {
  21. leadingIcon?: ReactNode
  22. trailingIcon?: ReactNode
  23. variant?: 'primary' | 'secondary' | 'tertiary' | 'danger'
  24. }
  25. const DSButton = forwardRef<HTMLButtonElement, DSButtonProps>(
  26. (
  27. {
  28. children,
  29. leadingIcon,
  30. trailingIcon,
  31. variant = 'primary',
  32. size,
  33. ...props
  34. },
  35. ref
  36. ) => {
  37. return (
  38. <Button
  39. className="d-inline-grid btn-ds"
  40. variant={variant}
  41. size={size}
  42. {...props}
  43. ref={ref}
  44. role={undefined}
  45. >
  46. <span className="button-content">
  47. {leadingIcon}
  48. {children}
  49. {trailingIcon}
  50. </span>
  51. </Button>
  52. )
  53. }
  54. )
  55. DSButton.displayName = 'DSButton'
  56. export default DSButton