ol-close-button.tsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
  2. import { CloseButton, CloseButtonProps } from 'react-bootstrap-5'
  3. import classNames from 'classnames'
  4. import { useTranslation } from 'react-i18next'
  5. import { forwardRef } from 'react'
  6. const OLCloseButton = forwardRef<HTMLButtonElement, CloseButtonProps>(
  7. (props, ref) => {
  8. const { t } = useTranslation()
  9. const bs3CloseButtonProps: React.ButtonHTMLAttributes<HTMLButtonElement> = {
  10. className: classNames('close', props.className),
  11. onClick: props.onClick,
  12. onMouseOver: props.onMouseOver,
  13. onMouseOut: props.onMouseOut,
  14. 'aria-label': t('close'),
  15. }
  16. return (
  17. <BootstrapVersionSwitcher
  18. bs3={
  19. <button {...bs3CloseButtonProps}>
  20. <span aria-hidden="true">&times;</span>
  21. </button>
  22. }
  23. bs5={<CloseButton ref={ref} {...props} />}
  24. />
  25. )
  26. }
  27. )
  28. OLCloseButton.displayName = 'OLCloseButton'
  29. export default OLCloseButton