Skip to content

Commit

Permalink
[ refactor ] extract basic object on Modal styles
Browse files Browse the repository at this point in the history
  • Loading branch information
leeJooHaem committed Feb 24, 2023
1 parent cfed6dc commit 62dc662
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/@components/@common/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ export default function Modal(props: PropsWithChildren<ModalContents>) {

return (
<ModalPortal>
<St.Root>
<St.Modal>
<St.DefaultRoot>
<St.DefaultModal>
<St.CloseBtn type="button" className={closeBtnClassName} onClick={closeHandler}>
<IcModalCloseBtn />
</St.CloseBtn>
<St.ModalContents>{children}</St.ModalContents>
</St.Modal>
</St.Root>
</St.DefaultModal>
</St.DefaultRoot>
</ModalPortal>
);
}
24 changes: 6 additions & 18 deletions src/@components/@common/Modal/style.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from "styled-components";

const WhiteRoot = styled.div`
const Root = styled.div`
height: 100vh;
position: absolute;
Expand All @@ -14,19 +14,9 @@ const WhiteRoot = styled.div`
align-items: center;
`;

const Root = styled.div`
height: 100vh;
position: absolute;
left: 0;
right: 0;
top: 0;
z-index: 10;
background-color: rgb(0, 0, 0, 0.5);
display: flex;
align-items: center;
const WhiteRoot = styled(Root)``;

const DefaultRoot = styled(Root)`
padding: 1.6rem;
`;

Expand All @@ -36,17 +26,15 @@ const WhiteModal = styled.section`
background-color: ${({ theme }) => theme.newColors.white};
padding: 2rem 0 0;
width: 100%;
`;

const Modal = styled.section`
const DefaultModal = styled.section`
position: relative;
background-color: ${({ theme }) => theme.colors.sub_green5};
border-radius: 2rem;
padding: 2rem 1.6rem;
width: 100%;
`;

const CloseBtn = styled.button`
Expand All @@ -69,8 +57,8 @@ const ModalContents = styled.main`
const St = {
WhiteRoot,
WhiteModal,
Root,
Modal,
DefaultRoot,
DefaultModal,
CloseBtn,
ModalContents,
};
Expand Down

0 comments on commit 62dc662

Please sign in to comment.