import React, { ReactNode } from "react";
import {
  CustomInfoPanel,
  InfoPanelTitle,
  PurpleLineBreak,
  Overlay,
  InfoPanelContainer,
} from "./RooInfoPanelStyles";

export interface CustomInfoPanelProps {
  isShowPanel?: boolean;
  title?: string;
  panelBody?: ReactNode;
  onClosePanel?: () => void;
}

const close = new URL("./assets/close.svg", import.meta.url).href;

export const RooInfoPanel: React.FC<CustomInfoPanelProps> = (props) => {
  const { title, panelBody, isShowPanel, onClosePanel } = props;
  return (
    <>
      <InfoPanelContainer isShowPanel={isShowPanel}>
        <Overlay />
        <CustomInfoPanel {...props}>
          <InfoPanelTitle>
            {title}
            <img
              src={close}
              onClick={() => (onClosePanel ? onClosePanel() : null)}
            />
          </InfoPanelTitle>
          <PurpleLineBreak />
          {panelBody}
        </CustomInfoPanel>
      </InfoPanelContainer>
    </>
  );
};
