From 3ff4c37a7a2c40340c17f9e6c1754444bce0f839 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 31 Oct 2023 16:00:45 +0100 Subject: refactor(components): rewrite Modal component * add an optional close button * add an icon prop --- src/components/atoms/modal/modal.tsx | 49 ------------------------------------ 1 file changed, 49 deletions(-) delete mode 100644 src/components/atoms/modal/modal.tsx (limited to 'src/components/atoms/modal/modal.tsx') diff --git a/src/components/atoms/modal/modal.tsx b/src/components/atoms/modal/modal.tsx deleted file mode 100644 index 6f5506f..0000000 --- a/src/components/atoms/modal/modal.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { - type ForwardRefRenderFunction, - type HTMLAttributes, - type ReactElement, - type ReactNode, - forwardRef, -} from 'react'; -import type { HeadingProps } from '../heading'; -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); -- cgit v1.2.3