ol-notification.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import Notification from '@/shared/components/notification'
  2. import { Alert, AlertProps } from 'react-bootstrap'
  3. import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
  4. import classnames from 'classnames'
  5. type OLNotificationProps = React.ComponentProps<typeof Notification> & {
  6. bs3Props?: {
  7. icon?: React.ReactElement
  8. className?: string
  9. }
  10. }
  11. function OLNotification(props: OLNotificationProps) {
  12. const { bs3Props, ...notificationProps } = props
  13. const alertProps = {
  14. // Map `error` to `danger`
  15. bsStyle:
  16. notificationProps.type === 'error' ? 'danger' : notificationProps.type,
  17. className: classnames(notificationProps.className, bs3Props?.className),
  18. onDismiss: notificationProps.onDismiss,
  19. } as const satisfies AlertProps
  20. return (
  21. <BootstrapVersionSwitcher
  22. bs3={
  23. <Alert {...alertProps}>
  24. {bs3Props?.icon}
  25. {bs3Props?.icon && ' '}
  26. {notificationProps.content}
  27. {notificationProps.action}
  28. </Alert>
  29. }
  30. bs5={
  31. <div className="notification-list">
  32. <Notification {...notificationProps} />
  33. </div>
  34. }
  35. />
  36. )
  37. }
  38. export default OLNotification