-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Wip] 공통 컴포넌트 제작 (9) MyModal #46
Merged
Merged
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b076fdd
:sparkles: MyModal 컴포넌트 기초 레이아웃 생성
loevray 688a4a3
:lipstick: 테마파일에 modal관련 스타일 정의
loevray 505edea
:lipstick: MyModal컴포넌트 레이아웃 전부 완료
loevray 7773f2b
:lipstick: MyModal header, 푸터쪽 버튼 폰트색상 수정
loevray c54d1f5
:truck: src/app폴더 생성및 App.tsx파일 이동
loevray db8b4f1
:heavy_plus_sign: redux-toolkit과 react-redux 패키지 추가
loevray 60fb01d
:sparkles: redux-toolkit store추가
loevray 97a3850
:sparkles: useSelector, useDispatch훅 useAppSelector, useAppDispatch로 추상화
loevray 83ce9ab
:sparkles: myModalSlice추가
loevray d84653d
:art: App감싸는 reduxProvider추가
loevray 241f686
:art: MyModal 컴포넌트 props로 모달 상태 받아오게 변경
loevray 3a9e3d2
:fire: redux관련 로직 전부 삭제
loevray edd78a3
:heavy_minus_sign: redux-toolkit, react-redux 패키지 제거
loevray 2cd1c93
:sparkles: MyModal storybook 수정 및 스토리 추가
loevray 28ddb0f
:lipstick: MyModal컴포넌트의 헤더 color변경
loevray 131838b
:lipstick: MyModal컴포넌트 footer버튼 텍스트 크기 조절
loevray e62c8bd
:art: MyModal컴포넌트 ...props로 받아오게 추가
loevray 809c9d4
Merge branch 'dev' of https://github.com/prgrms-fe-devcourse/FEDC5_do…
loevray b0704a2
:art: MyModal 컴포넌트 onSubmit프롭스를 onButtonClick으로 변경 및 스토리북에도 수정사항 적용
loevray fbf9cf2
:art: MyModal컴포넌트 불필요한 프래그먼트 삭제
loevray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { | ||
Button, | ||
Heading, | ||
Modal, | ||
ModalBody, | ||
ModalCloseButton, | ||
ModalContent, | ||
ModalFooter, | ||
ModalOverlay, | ||
ModalProps, | ||
Portal, | ||
} from '@chakra-ui/react'; | ||
import { ReactNode } from 'react'; | ||
|
||
interface MyModal extends ModalProps { | ||
onClose(): void; | ||
isOpen: boolean; | ||
title: string; | ||
children: ReactNode; | ||
buttonText: string; | ||
onButtonClick: () => void; | ||
} | ||
|
||
const MyModal = ({ | ||
isOpen, | ||
onClose, | ||
title, | ||
children, | ||
buttonText, | ||
onButtonClick, | ||
...props | ||
}: MyModal) => { | ||
return ( | ||
<> | ||
<Portal> | ||
<Modal isOpen={isOpen} onClose={onClose} {...props}> | ||
<ModalOverlay /> | ||
<ModalContent maxW="modal.w" h="modal.h" borderRadius="10px"> | ||
<Heading | ||
display="flex" | ||
justifyContent="center" | ||
alignItems="center" | ||
fontSize="1.6rem" | ||
bg="pink.300" | ||
h="modal.header.h" | ||
borderTopRadius="10px" | ||
color="white" | ||
> | ||
{title} | ||
</Heading> | ||
<ModalCloseButton /> | ||
<ModalBody>{children}</ModalBody> | ||
<ModalFooter justifyContent="center"> | ||
<Button | ||
h="modal.button.h" | ||
w="modal.button.w" | ||
bg="pink.100" | ||
onClick={onButtonClick} | ||
mb="28px" | ||
color="pink.300" | ||
fontSize="1.4rem" | ||
> | ||
{buttonText} | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
</Portal> | ||
</> | ||
); | ||
}; | ||
|
||
export default MyModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import MyModal from '@/components/common/MyModal'; | ||
import { Button, Text, useDisclosure } from '@chakra-ui/react'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
|
||
const meta: Meta<typeof MyModal> = { | ||
component: MyModal, | ||
argTypes: { | ||
isOpen: { | ||
control: 'boolean', | ||
}, | ||
onClose: { | ||
type: 'function', | ||
}, | ||
title: { | ||
control: 'text', | ||
}, | ||
buttonText: { | ||
control: 'text', | ||
}, | ||
onButtonClick: { | ||
type: 'function', | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof MyModal>; | ||
|
||
const ModalTest = () => { | ||
const { isOpen, onOpen, onClose } = useDisclosure(); | ||
return ( | ||
<> | ||
<Button onClick={onOpen}>모달 켜세용</Button> | ||
<MyModal | ||
title="테스트 모달 제목" | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
buttonText="누르면 알림창" | ||
onButtonClick={() => alert('하이')} | ||
> | ||
<Text align="center" fontSize="2rem"> | ||
하이 아임내용 | ||
</Text> | ||
</MyModal> | ||
</> | ||
); | ||
}; | ||
|
||
export const Deafult: Story = { | ||
render: () => <ModalTest />, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,17 @@ export const theme = extendTheme({ | |
}, | ||
sizes: { | ||
icon: '2.4rem', | ||
modal: { | ||
h: '343px', | ||
w: '392px', | ||
header: { | ||
h: '54px', | ||
}, | ||
button: { | ||
w: '178px', | ||
h: '36px', | ||
}, | ||
}, | ||
Comment on lines
+69
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 전역적으로 사이즈 지정해서 사용하는 것 너무 좋네요 ㅎㅎ 👍 |
||
}, | ||
zIndices: { | ||
normal: 100, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fragment
는 제거해도 괜찮지 않을까요 ?!! 👀🧐혹시 따로 사용해 주신 이유가 있으실까요 ?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어엇 Button넣고 테스트하다가 감빢햇네요 이거 지우고 merge하겠습니다 ㅎㅎ