import { FC, ReactNode, useContext, useMemo } from 'react'; import { DialogContext } from './Dialog'; import IconButton from '../IconButton'; import { PanelHeader } from '../Panels'; import sxstring from '../../lib/sxstring'; import { HeaderText } from '../Text'; const DialogHeader: FC = (props) => { const { children, showClose } = props; const dialogContext = useContext(DialogContext); const title = useMemo( () => sxstring(children, HeaderText), [children], ); const close = useMemo( () => showClose && ( { dialogContext?.setOpen(false); }} size="small" /> ), [dialogContext, showClose], ); return ( {title} {close} ); }; export default DialogHeader;