overleaf/services/web/frontend/js/features/ui/components/ol/ol-notification.tsx
Rebeka Dekany f78e619d87 Merge pull request #18331 from overleaf/rd-bs5-renaming
[web ] Bootstrap 5 - rename the wrapper components and restructure

GitOrigin-RevId: 7a76903df81cd546e9e469f24c4f203ea6a61672
2024-05-16 08:05:31 +00:00

42 lines
1.2 KiB
TypeScript

import Notification from '@/shared/components/notification'
import { Alert, AlertProps } from 'react-bootstrap'
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
import classnames from 'classnames'
type OLNotificationProps = React.ComponentProps<typeof Notification> & {
bs3Props?: {
icon?: React.ReactElement
className?: string
}
}
function OLNotification(props: OLNotificationProps) {
const { bs3Props, ...notificationProps } = props
const alertProps = {
// Map `error` to `danger`
bsStyle:
notificationProps.type === 'error' ? 'danger' : notificationProps.type,
className: classnames(notificationProps.className, bs3Props?.className),
onDismiss: notificationProps.onDismiss,
} as const satisfies AlertProps
return (
<BootstrapVersionSwitcher
bs3={
<Alert {...alertProps}>
{bs3Props?.icon}
{bs3Props?.icon && ' '}
{notificationProps.content}
</Alert>
}
bs5={
<div className="notification-list">
<Notification {...notificationProps} />
</div>
}
/>
)
}
export default OLNotification