-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 취소/등록 버튼 컴포넌트 구현
- Loading branch information
Showing
4 changed files
with
86 additions
and
1 deletion.
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(); | ||
return; | ||
} | ||
navigate(-1); // 기본 동작 -> 이전 페이지 이동 | ||
console.log('취소 버튼 클릭'); | ||
}; | ||
|
||
const handleSubmit = () => { | ||
if (onSubmit) { | ||
onSubmit(); | ||
return; | ||
} | ||
// 등록 완료 페이지로 이동 | ||
// navigate('/success'); // 등록 완료 페이지 경로 설정 필요 | ||
console.log('등록 완료 페이지로 이동'); | ||
}; | ||
|
||
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; | ||
} |