openreplay/frontend/app/components/ui/Popover/Popover.tsx
Andrey Babushkin fd5c0c9747
Add lokalisation (#3092)
* applied eslint

* add locales and lint the project

* removed error boundary

* updated locales

* fix min files

* fix locales
2025-03-06 17:43:15 +01:00

43 lines
871 B
TypeScript

import React from 'react';
import { Popover as AntPopover } from 'antd';
interface Props {
render: React.ReactNode | ((args: { close: () => void }) => React.ReactNode);
placement?: string;
children: React.ReactNode;
onOpen?: () => void;
onClose?: () => void;
}
function Popover({
children,
render,
placement = 'top',
onOpen,
onClose,
}: Props) {
const [visible, setVisible] = React.useState(false);
const handleOpen = () => {
setVisible(true);
onOpen?.();
};
const handleClose = () => {
setVisible(false);
onClose?.();
};
return (
<AntPopover
placement={placement}
open={visible}
content={() => render({ close: handleClose })}
trigger="click"
onOpenChange={(visible) => (visible ? handleOpen() : handleClose())}
>
{children}
</AntPopover>
);
}
export default Popover;