From 101847503cc2819ad2ce55eae800bf199feb264b Mon Sep 17 00:00:00 2001 From: QiShaoXuan Date: Fri, 9 Dec 2022 14:44:53 +0800 Subject: [PATCH] feat: modify modal component --- packages/app/src/ui/modal/modal.tsx | 32 +++++++++++++++++++++++++---- packages/app/src/ui/modal/styles.ts | 12 ++++++++--- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/packages/app/src/ui/modal/modal.tsx b/packages/app/src/ui/modal/modal.tsx index 31eb785761..c6c3cad278 100644 --- a/packages/app/src/ui/modal/modal.tsx +++ b/packages/app/src/ui/modal/modal.tsx @@ -1,5 +1,5 @@ import Fade from '@mui/material/Fade'; -import { StyledModal, StyledBackdrop } from './styles'; +import { StyledModal, StyledBackdrop, StyledWrapper } from './styles'; import { ModalUnstyledOwnProps } from '@mui/base/ModalUnstyled'; const Backdrop = ({ @@ -16,13 +16,37 @@ const Backdrop = ({ ); }; -export type ModalProps = ModalUnstyledOwnProps; +export type ModalProps = { + wrapperPosition?: ['top' | 'bottom' | 'center', 'left' | 'right' | 'center']; +} & ModalUnstyledOwnProps; + +const transformConfig = { + top: 'flex-start', + bottom: 'flex-end', + center: 'center', + left: 'flex-start', + right: 'flex-end', +}; export const Modal = (props: ModalProps) => { - const { components, open, children, ...otherProps } = props; + const { + wrapperPosition = ['center', 'center'], + components, + open, + children, + ...otherProps + } = props; + const [vertical, horizontal] = wrapperPosition; return ( - {children} + + + {children} + + ); }; diff --git a/packages/app/src/ui/modal/styles.ts b/packages/app/src/ui/modal/styles.ts index 304886768a..5495f27b81 100644 --- a/packages/app/src/ui/modal/styles.ts +++ b/packages/app/src/ui/modal/styles.ts @@ -1,6 +1,6 @@ -import { absoluteCenter, displayFlex, fixedCenter, styled } from '@/styles'; +import { styled } from '@/styles'; import ModalUnstyled from '@mui/base/ModalUnstyled'; -import { ModalCloseButtonProps } from '@/ui/modal/modal-close-button'; +import { Wrapper } from '@/ui/layout'; export const StyledBackdrop = styled.div<{ open?: boolean }>(({ open }) => { return { @@ -22,7 +22,6 @@ export const StyledModal = styled(ModalUnstyled)(({ theme }) => { left: '0', top: '0', zIndex: theme.zIndex.modal, - ...displayFlex('center', 'center'), '*': { WebkitTapHighlightColor: 'transparent', outline: 'none', @@ -30,3 +29,10 @@ export const StyledModal = styled(ModalUnstyled)(({ theme }) => { }; }); +export const StyledWrapper = styled(Wrapper)(() => { + return { + width: '100vw', + height: '100vh', + overflow: 'hidden', + }; +});