diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx new file mode 100644 index 0000000..5506de2 --- /dev/null +++ b/src/components/Modal.tsx @@ -0,0 +1,50 @@ +import React from 'react'; + +export interface IModalProps { + isOpen: boolean; + onClose: () => void; + title?: string; + children: React.ReactNode; +} + +export const Modal: React.FunctionComponent = (props) => { + const { isOpen, onClose, title, children } = props; + + const modalStyles: React.CSSProperties = { + display: isOpen ? 'block' : 'none', + position: 'fixed', + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + zIndex: 1000, + backgroundColor: '#fff', + padding: '20px', + boxShadow: '0 4px 8px rgba(0, 0, 0, 0.2)', + color: 'black' + }; + + const overlayStyles: React.CSSProperties = { + display: isOpen ? 'block' : 'none', + position: 'fixed', + top: 0, + left: 0, + width: '100%', + height: '100%', + backgroundColor: 'rgba(0, 0, 0, 0.5)', + zIndex: 999 + }; + + return ( +
+ {/* Overlay */} +
+ + {/* Modal */} +
+
{title &&

{title}

}
+
{children}
+ +
+
+ ); +}; diff --git a/src/components/index.ts b/src/components/index.ts index 8b166a8..227f9d4 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1 +1,2 @@ export * from './Button'; +export * from './Modal' ;