-
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: 뒤로 가기 버튼 구현 #1040
[FE] feat: 뒤로 가기 버튼 구현 #1040
Changes from 5 commits
dfe6b54
21edb08
940069f
233babc
3f26cdb
bb4ae5a
43788d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import { NavigateOptions, useNavigate } from 'react-router'; | ||
|
||
import BackButtonIcon from '@/assets/backButton.svg'; | ||
|
||
import * as S from './styles'; | ||
|
||
interface BackButtonProps { | ||
prevPath: string; | ||
options?: NavigateOptions; | ||
buttonStyle?: React.CSSProperties; | ||
wrapperStyle?: React.CSSProperties; | ||
} | ||
|
||
const BackButton = ({ prevPath, options, buttonStyle, wrapperStyle }: BackButtonProps) => { | ||
const navigate = useNavigate(); | ||
|
||
const handleBackButtonClick = () => { | ||
navigate(prevPath, options); | ||
}; | ||
|
||
return ( | ||
<S.BackButtonWrapper $style={wrapperStyle}> | ||
<S.BackButton onClick={handleBackButtonClick} $style={buttonStyle}> | ||
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. 지금은 BackButton을 레이아웃과 엮어서 사용하고 있지만, Wrapper 없이 딱 BackButton만 필요할 때도 있을 것 같아요. 둘을 분리하는 것에 대해 어떻게 생각하시나요? (Checkbox와 CheckboxItem처럼) '뒤로가기' 자체가 레이아웃과 엮일 일이 많으니 그냥 묶어둬도 좋을 것 같고... 😶 그리고 버튼 type은 굳이 지정하지 않아도 되는지 궁금해요! 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. 원래는 레이아웃으로 만들려고 했던 만큼, 뒤로 가기 버튼을 사용하게 된다면 거의 레이아웃 용도로 사용하게 될 것 같아요. 만약 BackButton 자체만 필요한 경우가 생긴다면 그때 두 가지를 모두 지원하는 것은 어떨까요? 버튼 type의 경우 기본값이 submit이기 때문에 button으로 지정했습니다! 👍 |
||
<img src={BackButtonIcon} alt="뒤로가기 버튼" /> | ||
</S.BackButton> | ||
</S.BackButtonWrapper> | ||
); | ||
}; | ||
|
||
export default BackButton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import styled from '@emotion/styled'; | ||
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. 올라온 styles.tsx에 BackButtonWrapper는 없네요 😲 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. 헉 스타일 코드가 빠졌네요.. 누락된 코드 추가했습니다 |
||
|
||
interface BackButtonStyleProps { | ||
$style?: React.CSSProperties; | ||
} | ||
|
||
export const BackButtonWrapper = styled.div<BackButtonStyleProps>` | ||
display: flex; | ||
justify-content: flex-start; | ||
width: 100%; | ||
|
||
${({ $style }) => $style && { ...$style }} | ||
`; | ||
|
||
export const BackButton = styled.button<BackButtonStyleProps>` | ||
width: 3.5rem; | ||
height: 3.5rem; | ||
|
||
${({ $style }) => $style && { ...$style }} | ||
`; |
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.
navigateOptions라고 명시하면 BackButton을 사용할 때 무엇을 전달해야 하는지 고민하지 않아도 될 것 같아요!
(이걸 보니 제 로그인 버튼 스타일 이름을 확실히 고쳐야겠다는 생각이 드네요ㅋㅋㅋ)
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.
명시하는 것이 나을 것 같네요!