Skip to content

Commit

Permalink
chore: 리뷰 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrevile committed Jul 26, 2024
1 parent 80cbf5b commit 69893bb
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions packages/web-domains/src/common/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ import { createPortal } from 'react-dom';

export interface ModalProps extends HTMLAttributes<HTMLDivElement> {
isOpen: boolean;
width?: number;
footer?: ReactNode;
onClose?: () => void;
}

export const Modal = ({ isOpen, width, onClose, children, footer, ...rest }: PropsWithChildren<ModalProps>) => {
export const Modal = ({ isOpen, onClose, children, footer, ...rest }: PropsWithChildren<ModalProps>) => {
const [element, setElement] = useState<HTMLElement | null>(null);

const modalWidth = width ? `${width}px` : '100%';

const handleClose = () => {
onClose?.();
};
Expand All @@ -36,18 +33,10 @@ export const Modal = ({ isOpen, width, onClose, children, footer, ...rest }: Pro
};
}, [isOpen]);

if (typeof window === 'undefined') {
return <></>;
}

if (!element) {
if (typeof window === 'undefined' || !element || !isOpen) {
return <></>;
}

if (!isOpen) {
return null;
}

return createPortal(
<div
css={{ width: '100%', height: '100%', background: '#00000066', position: 'fixed', top: 0 }}
Expand All @@ -57,15 +46,13 @@ export const Modal = ({ isOpen, width, onClose, children, footer, ...rest }: Pro
id="modal"
css={{
padding: '20px',
width: modalWidth,
maxWidth: '335px',
width: '335px',
position: 'fixed',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
backgroundColor: colors.white,
borderRadius: borderRadiusVariants.medium,
zIndex: '10000',
}}
{...rest}
>
Expand Down

0 comments on commit 69893bb

Please sign in to comment.