import {
ForwardRefRenderFunction,
HTMLAttributes,
ReactElement,
ReactNode,
forwardRef,
} from 'react';
import { HeadingProps } from '../headings';
import styles from './modal.module.scss';
export type ModalProps = HTMLAttributes & {
/**
* The modal body.
*/
children: ReactNode;
/**
* The modal title.
*/
heading?: ReactElement;
/**
* The modal kind.
*
* @default 'primary'
*/
kind?: 'primary' | 'secondary';
};
const ModalWithRef: ForwardRefRenderFunction = (
{ children, className = '', heading, kind = 'primary', ...props },
ref
) => {
const headingModifier = heading ? 'modal--has-title' : '';
const kindModifier = `modal--${kind}`;
const modalClass = `${styles.modal} ${styles[headingModifier]} ${styles[kindModifier]} ${className}`;
return (
{heading ?
{heading}
: null}
{children}
);
};
/**
* Modal component
*
* Render a modal component.
*/
export const Modal = forwardRef(ModalWithRef);