Feat: 헤더 컴포넌트 인터페이스 추가 구현 - #34
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the Header component to introduce a more flexible interface with customizable back button and section renderers, applies default styling updates, and updates dependent usage and dependencies.
- Replaces
left,center,rightprops withbackButton,title, andrenderLeft/renderCenter/renderRightcallbacks - Implements default back-button behavior using React Router’s
useNavigateand adds box-shadow style - Updates menu page to use new
titleprop and bumps@radix-ui/react-iconsdependency
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/common/components/Header.tsx | Refactored props, added back button logic, default styles |
| src/Menu/page.tsx | Updated Header usage to the new interface |
| package.json | Added @radix-ui/react-icons dependency and formatted lint-staged config |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)
src/common/components/Header.tsx:70
- Typo in function name
renderCentnerElement; rename torenderCenterElementfor consistency and clarity.
const renderCentnerElement = () => renderCenter && <CenterElement as="div">{renderCenter()}</CenterElement>;
src/common/components/Header.tsx:47
- [nitpick] Consider adding unit tests for
renderBackButtonto cover default navigation, customonClick, and customrenderIconscenarios.
const renderBackButton = () => {
| }; | ||
|
|
||
| return ( | ||
| <button type="button" onClick={onClickBackButton}> |
There was a problem hiding this comment.
Add an accessible name (e.g., aria-label="뒤로가기") to the back button so screen readers can identify its purpose.
Suggested change
| <button type="button" onClick={onClickBackButton}> | |
| <button | |
| type="button" | |
| onClick={onClickBackButton} | |
| aria-label={backButton?.ariaLabel || "뒤로가기"} // Default accessible name | |
| > |
jungwoo3490
reviewed
Jul 6, 2025
|
|
||
| const renderBackButton = () => { | ||
| const onClickBackButton = () => { | ||
| if (backButton && "onClick" in backButton && backButton.onClick) { |
Member
There was a problem hiding this comment.
"onClick" in backButton // backButton에 onClick prop이 있는지 확인
backButton.onClick // onClick에 nullish한 값이 들어오지는 않았는지 검증 용도연서한테 구두로 설명받았습니다~!
| <CenterElement as={typeof center === "string" ? "h1" : "div"}>{center}</CenterElement> | ||
| <RightElement>{right}</RightElement> | ||
| <LeftElement>{renderLeft?.() ?? renderBackButton()}</LeftElement> | ||
| {renderCenterElement() || renderTitleElement()} |
Member
There was a problem hiding this comment.
요기는 ?? 대신 || 사용해준 이유가 있는지 궁금해요!!!
Contributor
Author
There was a problem hiding this comment.
??가 더 적절하겠네유 수정했습니당!
seobbang
approved these changes
Aug 17, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
close #33
☑️ 완료 태스크
🔎 PR 내용
Header 컴포넌트의 인터페이스를 완전히 리팩토링하여 더 유연하고 직관적인 사용이 가능하도록 개선했습니다.
기존 인터페이스:
새로운 인터페이스:
📷 스크린샷