-
Notifications
You must be signed in to change notification settings - Fork 1
Feat: 헤더 컴포넌트 인터페이스 추가 구현 #34
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7d10186
feat: 아이콘 패키지 설치
Yeonseo-Jo a9962c5
fix: header 컴포넌트 인터페이스 추가
Yeonseo-Jo d2f4518
fix: header 예시 컴포넌트 수정
Yeonseo-Jo 16b0bbe
chore: header 컴포넌트 설명 주석 추가
Yeonseo-Jo 553e5ff
fix: 오타 수정
Yeonseo-Jo 65424b5
fix: ??로 수정
Yeonseo-Jo 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,19 +1,86 @@ | ||||||||||||||
| import styled from "@emotion/styled"; | ||||||||||||||
| import { ChevronLeftIcon } from "@radix-ui/react-icons"; | ||||||||||||||
| import type { ReactElement } from "react"; | ||||||||||||||
| import { useNavigate } from "react-router"; | ||||||||||||||
| import { Z_INDEX } from "../constants/zIndex"; | ||||||||||||||
| import { rem } from "../utils/rem"; | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Header 컴포넌트 Props | ||||||||||||||
| * | ||||||||||||||
| * 우선순위: render* > backButton, title > 기본 뒤로가기 버튼 | ||||||||||||||
| */ | ||||||||||||||
| interface HeaderProps { | ||||||||||||||
| left?: ReactElement | string; | ||||||||||||||
| center: ReactElement | string; | ||||||||||||||
| right?: ReactElement | string; | ||||||||||||||
| /** 백 버튼 커스터마이징 */ | ||||||||||||||
| backButton?: { | ||||||||||||||
| renderIcon?: () => ReactElement; | ||||||||||||||
| onClick?: () => void; | ||||||||||||||
| }; | ||||||||||||||
| /** 헤더 제목 */ | ||||||||||||||
| title?: string; | ||||||||||||||
| /** 왼쪽 섹션 커스터마이징 */ | ||||||||||||||
| renderLeft?: () => ReactElement; | ||||||||||||||
| /** 중앙 섹션 커스터마이징 */ | ||||||||||||||
| renderCenter?: () => ReactElement; | ||||||||||||||
| /** 오른쪽 섹션 커스터마이징 */ | ||||||||||||||
| renderRight?: () => ReactElement; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| function Header({ left, center, right }: HeaderProps) { | ||||||||||||||
| /** | ||||||||||||||
| * 페이지 헤더 컴포넌트 | ||||||||||||||
| * | ||||||||||||||
| * @example | ||||||||||||||
| * ```tsx | ||||||||||||||
| * // default (backButton, title) | ||||||||||||||
| * <Header title="홈" /> | ||||||||||||||
| * | ||||||||||||||
| * // backButton ui, 이벤트 커스터마이징 | ||||||||||||||
| * <Header title="설정" backButton={{ onClick: () => navigate('/') }} /> | ||||||||||||||
| * | ||||||||||||||
| * // 섹션별 커스터마이징 (renderLeft, renderCenter, renderRight) | ||||||||||||||
| * <Header renderCenter={() => <SearchBar />} /> | ||||||||||||||
| * ``` | ||||||||||||||
| */ | ||||||||||||||
| function Header({ backButton, title, renderLeft, renderCenter, renderRight }: HeaderProps) { | ||||||||||||||
| const navigate = useNavigate(); | ||||||||||||||
|
|
||||||||||||||
| const renderBackButton = () => { | ||||||||||||||
| const onClickBackButton = () => { | ||||||||||||||
| if (backButton && "onClick" in backButton && backButton.onClick) { | ||||||||||||||
| backButton.onClick(); | ||||||||||||||
| return; | ||||||||||||||
| } | ||||||||||||||
| // default behavior | ||||||||||||||
| navigate(-1); | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| return ( | ||||||||||||||
| <button type="button" onClick={onClickBackButton}> | ||||||||||||||
|
||||||||||||||
| <button type="button" onClick={onClickBackButton}> | |
| <button | |
| type="button" | |
| onClick={onClickBackButton} | |
| aria-label={backButton?.ariaLabel || "뒤로가기"} // Default accessible name | |
| > |
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.
연서한테 구두로 설명받았습니다~!