import React, { FunctionComponent } from "react"; import { X } from "react-feather"; import { useOverlayContext } from "../../../../common/context/OverlayContext"; import { useLockBodyScroll } from "../../../../common/hooks/useLockBodyScroll"; import { IconError, IconSuccess } from "../../Icon"; export interface OverlayContentProps { className?: string; title: string; isSuccess?: boolean; children?: React.ReactNode; crossStyle?: string; maxHeight?: number; } /** * OverlayContent is a component to display overlay contents. * @param className className for the overlay content container * @param title displays the title for the overlay contents * @param isSuccess a boolean, if true will display a green tick on the left of the title, if false will display a red cross on the left of the title, if undefined will not display anything * @param children children component for this component * @param crossStyle className for the 'X' button to close the overlay * @param maxHeight maxHeight for overlay content */ export const OverlayContent: FunctionComponent = ({ className, title, isSuccess, children, crossStyle, maxHeight, ...props }) => { const { isOverlayVisible, closeOverlay } = useOverlayContext(); useLockBodyScroll(); const style = { width: "calc(100vw - (15px * 2))", ...(maxHeight && { maxHeight: `${maxHeight}px` }), }; return ( <> {isOverlayVisible && (
{isSuccess !== undefined && (
{isSuccess ? ( ) : ( )}
)}

{title}

{children}
)} ); };