-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FE] feat: 좌측 상단에 경로를 표시하는 Breadcrumb 컴포넌트 구현 (#372)
* fix: Pretendard 폰트가 정상적으로 적용되도록 나눔고딕 제거 * chore: 오른쪽 화살표 이미지 추가 * feat: 경로 표시를 위한 Breadcrumb 컴포넌트 구현 * refactor: rightArrow 이미지를 '/'로 변경 * feat: 리뷰 목록 페이지에 Breadcrumb 컴포넌트 추가 * style: css 속성 순서 변경 * refactor: 경로 반환 로직을 useBreadcrumbPaths 훅으로 분리 * refactor: Breadcrumb 컴포넌트 렌더링을 App.tsx로 이동 * feat: 작성 완료 페이지 경로 추가 * refactor: path가 number, string일 경우를 명확히 구분하여 처리 * chore: 코드 컨벤션에 맞춰 배열 이름을 List로 변경 * refactor: 각 페이지별 경로 상수 처리 * refactor: 객체 키를 모두 소문자로 변경 * refactor: 경로 상수를 src/index.tsx에도 적용 * refactor: 카멜 케이스로 변경 후 적용
- Loading branch information
Showing
14 changed files
with
153 additions
and
49 deletions.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import { useNavigate } from 'react-router'; | ||
|
||
import * as S from './styles'; | ||
|
||
type PathType = string | number; | ||
|
||
export interface Path { | ||
pageName: string; | ||
path: PathType; | ||
} | ||
|
||
interface BreadcrumbProps { | ||
pathList: Path[]; | ||
} | ||
|
||
const Breadcrumb = ({ pathList }: BreadcrumbProps) => { | ||
const navigate = useNavigate(); | ||
|
||
const handleNavigation = (path: PathType) => { | ||
if (typeof path === 'number') { | ||
navigate(path); | ||
} else { | ||
navigate(path); | ||
} | ||
}; | ||
|
||
return ( | ||
<S.BreadcrumbList> | ||
{pathList.map(({ pageName, path }, index) => ( | ||
<S.BreadcrumbItem key={index} onClick={() => handleNavigation(path)}> | ||
{pageName} | ||
</S.BreadcrumbItem> | ||
))} | ||
</S.BreadcrumbList> | ||
); | ||
}; | ||
|
||
export default Breadcrumb; |
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,21 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const BreadcrumbList = styled.ul` | ||
display: flex; | ||
padding: 2rem 0 0 2.5rem; | ||
list-style: none; | ||
`; | ||
|
||
export const BreadcrumbItem = styled.li` | ||
cursor: pointer; | ||
&:not(:last-child)::after { | ||
content: '/'; | ||
margin: 0 2rem; | ||
} | ||
&:last-child { | ||
color: ${({ theme }) => theme.colors.primary}; | ||
text-decoration: underline; | ||
} | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const ROUTES = { | ||
home: '/', | ||
reviewList: 'user/review-list', | ||
reviewWriting: 'user/review-writing', | ||
reviewWritingComplete: 'user/review-writing-complete', | ||
detailedReview: 'user/detailed-review', | ||
}; |
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,35 @@ | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
import { Path } from '@/components/common/Breadcrumb'; | ||
import { ROUTES } from '@/constants/routes'; | ||
|
||
const useBreadcrumbPaths = () => { | ||
const { pathname } = useLocation(); | ||
|
||
const breadcrumbPathList: Path[] = [ | ||
{ pageName: '연결 페이지', path: ROUTES.home }, // TODO: 연결 페이지 경로 결정되면 수정 필요 | ||
]; | ||
|
||
if (pathname === `/${ROUTES.reviewList}`) { | ||
breadcrumbPathList.push({ pageName: '목록 페이지', path: pathname }); | ||
} | ||
|
||
if (pathname.includes(`/${ROUTES.reviewWriting}/`)) { | ||
breadcrumbPathList.push({ pageName: '작성 페이지', path: pathname }); | ||
} | ||
|
||
if (pathname === `/${ROUTES.reviewWritingComplete}`) { | ||
breadcrumbPathList.push({ pageName: '작성 페이지', path: -1 }, { pageName: '작성 완료 페이지', path: pathname }); | ||
} | ||
|
||
if (pathname.includes(ROUTES.detailedReview)) { | ||
breadcrumbPathList.push( | ||
{ pageName: '목록 페이지', path: ROUTES.reviewList }, | ||
{ pageName: '상세 페이지', path: pathname }, | ||
); | ||
} | ||
|
||
return breadcrumbPathList; | ||
}; | ||
|
||
export default useBreadcrumbPaths; |
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
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
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