-
Notifications
You must be signed in to change notification settings - Fork 2
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
[FE] feat: Alert Modal과 Error Alert Modal 컴포넌트 구현 및 Button 컴포넌트 확장 #165
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
bf001e4
refactor: 공통 버튼 컴포넌트가 children과 style을 받도록 수정
chysis ff6c62f
chore: error alert modal에서 사용할 primary 색상의 경고 삼각형 추가
chysis 271fc9e
feat: ErrorAlertModal 컴포넌트 구현
chysis 2501775
feat: AlertModal 컴포넌트 구현
chysis c30fb62
chore: 변경된 Button 컴포넌트의 구조에 맞게 코드 수정
chysis 281d650
fix: AlertModal이 Esc 또는 background의 클릭으로 닫히지 않도록 수정
chysis d19c304
chore: AlertModal과 ErrorAlertModal export
chysis 658cd36
Merge branch 'develop' of https://github.com/woowacourse-teams/2024-r…
chysis 949bad9
refactor: Button 컴포넌트가 type을 별도로 받도록 수정 및 기존의 buttonType을 styleType으로 변경
chysis c20d25d
refactor: background 클릭 또는 Esc 키를 통해 모달을 닫는 것을 분리
chysis 31c9f16
refactor: AlertModal의 모달 닫는 정책을 props로 선택 가능하도록 수정
chysis 2374c37
refactor: ErrorAlertModal을 AlertModal을 사용해 구현
chysis c8d3867
refactor: 닫기 버튼 이외의 방법으로 모달을 닫을 수 있는지 여부와 handler를 props로 전달받도록 변경
chysis aa03b2a
Merge branch 'develop' of https://github.com/woowacourse-teams/2024-r…
chysis 1f8cbc7
refactor: 비어있는 스타일 컴포넌트 제거
chysis 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
45 changes: 45 additions & 0 deletions
45
frontend/src/components/common/modals/AlertModal/index.tsx
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,45 @@ | ||
import { ButtonStyleType, EssentialPropsWithChildren } from '@/types'; | ||
|
||
import Button from '../../Button'; | ||
import ModalBackground from '../ModalBackground'; | ||
import ModalPortal from '../ModalPortal'; | ||
|
||
import * as S from './styles'; | ||
|
||
interface CloseButton { | ||
type: ButtonStyleType; | ||
handleClick: () => void; | ||
content: React.ReactNode; | ||
} | ||
|
||
interface AlertModalProps { | ||
closeButton: CloseButton; | ||
isClosableOnBackground: boolean; | ||
handleClose: (() => void) | null; | ||
} | ||
|
||
const AlertModal = ({ | ||
closeButton, | ||
isClosableOnBackground, | ||
handleClose, | ||
children, | ||
}: EssentialPropsWithChildren<AlertModalProps>) => { | ||
return ( | ||
<ModalPortal> | ||
<ModalBackground closeModal={isClosableOnBackground ? handleClose : null}> | ||
<S.AlertModalContainer> | ||
<S.Contents>{children}</S.Contents> | ||
<Button | ||
styleType={closeButton.type} | ||
onClick={closeButton.handleClick} | ||
style={{ width: '100%', minWidth: '30rem', height: '4rem' }} | ||
> | ||
{closeButton.content} | ||
</Button> | ||
</S.AlertModalContainer> | ||
</ModalBackground> | ||
</ModalPortal> | ||
); | ||
}; | ||
|
||
export default AlertModal; |
24 changes: 24 additions & 0 deletions
24
frontend/src/components/common/modals/AlertModal/styles.ts
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,24 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const AlertModalContainer = styled.div` | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
|
||
display: flex; | ||
flex-direction: column; | ||
gap: 3.2rem; | ||
align-items: center; | ||
justify-content: space-between; | ||
|
||
max-height: 80vh; | ||
padding: 3.2rem; | ||
|
||
background-color: ${({ theme }) => theme.colors.white}; | ||
border-radius: ${({ theme }) => theme.borderRadius.basic}; | ||
`; | ||
|
||
export const Contents = styled.div` | ||
display: flex; | ||
`; |
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
31 changes: 31 additions & 0 deletions
31
frontend/src/components/common/modals/ErrorAlertModal/index.tsx
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,31 @@ | ||
import AlertTrianglePrimaryIcon from '@/assets/alertTrianglePrimary.svg'; | ||
import { ButtonStyleType } from '@/types'; | ||
|
||
import AlertModal from '../AlertModal'; | ||
|
||
import * as S from './styles'; | ||
|
||
interface CloseButton { | ||
type: ButtonStyleType; | ||
handleClick: () => void; | ||
content: React.ReactNode; | ||
} | ||
|
||
interface ErrorAlertModalProps { | ||
closeButton: CloseButton; | ||
errorText: string; | ||
handleClose: () => void; | ||
} | ||
|
||
const ErrorAlertModal = ({ closeButton, errorText, handleClose }: ErrorAlertModalProps) => { | ||
return ( | ||
<AlertModal closeButton={closeButton} isClosableOnBackground={true} handleClose={handleClose}> | ||
<S.Contents> | ||
<S.AlertTriangle src={AlertTrianglePrimaryIcon} alt="경고 마크" /> | ||
<p>{errorText}</p> | ||
</S.Contents> | ||
</AlertModal> | ||
); | ||
}; | ||
|
||
export default ErrorAlertModal; |
12 changes: 12 additions & 0 deletions
12
frontend/src/components/common/modals/ErrorAlertModal/styles.ts
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,12 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const Contents = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
`; | ||
|
||
export const AlertTriangle = styled.img` | ||
width: 6rem; | ||
height: 6rem; | ||
`; |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export { default as SideModal } from './SideModal'; | ||
export { default as ConfirmModal } from './ConfirmModal'; | ||
export { default as AlertModal } from './AlertModal'; | ||
export { default as ErrorAlertModal } from './ErrorAlertModal'; |
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
export type ButtonType = 'primary' | 'secondary' | 'disabled'; | ||
export type ButtonStyleType = 'primary' | 'secondary' | 'disabled'; |
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.
확장성면에서
children
사용한 거 너무 좋은 것 같아요!!