mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
|
import { Overlay, OverlayProps } from 'react-bootstrap-5'
|
||
|
import {
|
||
|
Overlay as BS3Overlay,
|
||
|
OverlayProps as BS3OverlayProps,
|
||
|
} from 'react-bootstrap'
|
||
|
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
||
|
|
||
|
type OLOverlayProps = OverlayProps & {
|
||
|
bs3Props?: BS3OverlayProps
|
||
|
}
|
||
|
|
||
|
function OLOverlay(props: OLOverlayProps) {
|
||
|
const { bs3Props, ...bs5Props } = props
|
||
|
|
||
|
let bs3OverlayProps: BS3OverlayProps = {
|
||
|
children: bs5Props.children,
|
||
|
target: bs5Props.target as BS3OverlayProps['target'],
|
||
|
container: bs5Props.container,
|
||
|
containerPadding: bs5Props.containerPadding,
|
||
|
show: bs5Props.show,
|
||
|
rootClose: bs5Props.rootClose,
|
||
|
animation: bs5Props.transition,
|
||
|
onHide: bs5Props.onHide as BS3OverlayProps['onHide'],
|
||
|
onEnter: bs5Props.onEnter as BS3OverlayProps['onEnter'],
|
||
|
onEntering: bs5Props.onEntering as BS3OverlayProps['onEntering'],
|
||
|
onEntered: bs5Props.onEntered as BS3OverlayProps['onEntered'],
|
||
|
onExit: bs5Props.onExit as BS3OverlayProps['onExit'],
|
||
|
onExiting: bs5Props.onExiting as BS3OverlayProps['onExiting'],
|
||
|
onExited: bs5Props.onExited as BS3OverlayProps['onExited'],
|
||
|
}
|
||
|
|
||
|
if (bs5Props.placement) {
|
||
|
const bs3PlacementOptions = [
|
||
|
'top',
|
||
|
'right',
|
||
|
'bottom',
|
||
|
'left',
|
||
|
] satisfies Array<
|
||
|
Extract<OverlayProps['placement'], BS3OverlayProps['placement']>
|
||
|
>
|
||
|
|
||
|
for (const placement of bs3PlacementOptions) {
|
||
|
if (placement === bs5Props.placement) {
|
||
|
bs3OverlayProps.placement = bs5Props.placement
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
bs3OverlayProps = { ...bs3OverlayProps, ...bs3Props }
|
||
|
|
||
|
return (
|
||
|
<BootstrapVersionSwitcher
|
||
|
bs3={<BS3Overlay {...bs3OverlayProps} />}
|
||
|
bs5={<Overlay {...bs5Props} />}
|
||
|
/>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
export default OLOverlay
|