Skip to content
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
merged 7 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/components/button/ButtonGroup.tsx
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;
24 changes: 24 additions & 0 deletions src/components/button/buttonGroup.module.scss
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;
}
10 changes: 9 additions & 1 deletion src/pages/test/Test.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { useState } from 'react';

import classNames from 'classnames';
import styles from './test.module.scss';

//버튼그룹 test
import ButtonGroup from '../../components/button/ButtonGroup.tsx';

export const Test = () => {
const [clicked, setClicked] = useState(false);

const handleClickButton = () => {
setClicked(!clicked);
};

return (
<div className={classNames(styles.container)}>
테스트 페이지입니다.
Expand All @@ -18,6 +22,10 @@ export const Test = () => {
onClick={handleClickButton}>
테스트 버튼
</button>
{/* 버튼그룹 test */}
<div className={styles.buttonGroupWrapper}>
<ButtonGroup />
</div>
</div>
);
};
5 changes: 5 additions & 0 deletions src/pages/test/test.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@
.clicked {
background-color: orange;
}

.buttonGroupWrapper {
@include flex-center;
gap: 10px;
}
Loading