-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: 취소/등록 버튼 컴포넌트 구현 #9
Merged
hyuke81
merged 7 commits into
BrainPix:develop
from
hyuke81:feature/cancle_register_button
Jan 12, 2025
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
14f09ac
feat: 취소/등록 공통 버튼 컴포넌트
hyuke81 fc650be
test: 공통 버튼 컴포넌트 테스트
hyuke81 0710759
feat: 취소 버튼 클릭시 이전 페이지로 이동
hyuke81 cc53a1c
feat: 등록 버튼 클릭시 등록 완료 페이지 이동
hyuke81 3ebfa57
Test setup: Preparing environment for testing
hyuke81 31df1e3
test: lint 재설정
hyuke81 628adf0
refactor: early return문 적용
hyuke81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import styles from './buttonGroup.module.scss'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
interface ButtonGroupProps { | ||
onCancel?: () => void; | ||
onSubmit?: () => void; | ||
} | ||
|
||
const ButtonGroup: React.FC<ButtonGroupProps> = ({ onCancel, onSubmit }) => { | ||
const navigate = useNavigate(); | ||
|
||
const handleCancel = () => { | ||
if (onCancel) { | ||
onCancel(); | ||
} else { | ||
navigate(-1); //기본 동작 -> 이전페이지 이동 | ||
console.log('취소 버튼 클릭'); | ||
} | ||
}; | ||
|
||
const handleSubmit = () => { | ||
if (onSubmit) { | ||
onSubmit(); | ||
} else { | ||
// 등록 완료 페이지로 이동 | ||
// navigate('/success'); // 등록 완료 페이지 경로 설정 필요 | ||
console.log('등록 완료 페이지로 이동'); | ||
} | ||
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. 이것두요! |
||
}; | ||
|
||
return ( | ||
<div className={styles.buttonGroup}> | ||
<button | ||
className={styles.cancelButton} | ||
onClick={handleCancel}> | ||
취소 | ||
</button> | ||
<button | ||
className={styles.submitButton} | ||
onClick={handleSubmit}> | ||
등록 | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ButtonGroup; |
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 @@ | ||
.buttonGroup { | ||
@include flex-center; // flexbox 중앙 정렬 | ||
gap: 10px; // 버튼 간격 | ||
} | ||
|
||
.cancelButton { | ||
background-color: #ffffff; | ||
color: #616161; | ||
border: none; | ||
padding: 10px 20px; | ||
cursor: pointer; | ||
font-size: 28px; | ||
} | ||
|
||
.submitButton { | ||
background-color: #424242; | ||
color: #ffffff; | ||
border: none; | ||
width: 125px; | ||
height: 50px; | ||
border-radius: 25px; | ||
cursor: pointer; | ||
font-size: 28px; | ||
} |
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 |
---|---|---|
|
@@ -14,3 +14,8 @@ | |
.clicked { | ||
background-color: orange; | ||
} | ||
|
||
.buttonGroupWrapper { | ||
@include flex-center; | ||
gap: 10px; | ||
} |
Oops, something went wrong.
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.
if else 문보다 early return 문을 사용하시는 건 어떠신가용
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.
early return문 적용했슴니당!