-
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: NavigationTab 컴포넌트 구현 #1037
base: develop
Are you sure you want to change the base?
Changes from 1 commit
95ab269
eae4a64
b63b771
513334c
604298f
f55421a
9d4f0ea
85c67c2
5afd4ed
521eb6b
52edf28
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,17 @@ | ||
import * as S from './styles'; | ||
|
||
interface NavItemProps { | ||
label: string; | ||
$isSelected: boolean; | ||
onClick: () => void; | ||
} | ||
|
||
const NavItem = ({ label, $isSelected, onClick }: NavItemProps) => { | ||
return ( | ||
<S.NavItem $isSelected={$isSelected}> | ||
<button onClick={onClick}>{label}</button> | ||
</S.NavItem> | ||
); | ||
}; | ||
|
||
export default NavItem; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
import media from '@/utils/media'; | ||
|
||
interface NavItemProps { | ||
$isSelected: boolean; | ||
} | ||
|
||
export const NavItem = styled.li<NavItemProps>` | ||
border-bottom: 0.3rem solid ${({ theme, $isSelected }) => ($isSelected ? theme.colors.primary : 'none')}; | ||
padding: 0 1rem 1.3rem 1rem; | ||
|
||
button { | ||
font-weight: ${({ theme }) => theme.fontWeight.semibold}; | ||
color: ${({ theme, $isSelected }) => ($isSelected ? theme.colors.black : theme.colors.disabled)}; | ||
|
||
&:hover { | ||
color: ${({ theme }) => theme.colors.black}; | ||
} | ||
} | ||
|
||
${media.xSmall} { | ||
display: flex; | ||
flex: 1; | ||
justify-content: center; | ||
|
||
margin: 0 2rem; | ||
} | ||
|
||
${media.xxSmall} { | ||
margin: 0 1.6rem; | ||
} | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useLocation, useNavigate } from 'react-router'; | ||
|
||
const useNavigationTabs = () => { | ||
const { pathname } = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
const navigateReviewLinkManagementPage = () => { | ||
navigate('/user/review-link-management'); | ||
}; | ||
|
||
const navigateWrittenReviewConfirmPage = () => { | ||
navigate('/user/written-review-confirm'); | ||
}; | ||
|
||
const tabList = [ | ||
{ | ||
label: '리뷰 링크 관리', | ||
path: '/user/review-link-management', | ||
handleTabClick: navigateReviewLinkManagementPage, | ||
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. tabList의 요소안에 path가 있으니, tabList 사용시 onClick={()=> navigate(tab.path)}로 해도 될 것 같은데, tabList에 handleTabClick으로 선언한 이유가 있을까요? 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. 저도 같은 의문이 있었는데, navigate 코드에 더해 페이지 방문 amplitude 코드를 추가한다고 생각하면 nav 함수를 따로 파도 괜찮을 것 같아요. 지금 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.
amplitude 코드 추가될 것 같아서 함수 따로 팠어요~
맞아요. |
||
}, | ||
{ | ||
label: '작성한 리뷰 확인', | ||
path: '/user/written-review-confirm', | ||
handleTabClick: navigateWrittenReviewConfirmPage, | ||
}, | ||
]; | ||
|
||
const currentTabIndex = tabList.findIndex((tab) => tab.path === pathname); | ||
|
||
return { currentTabIndex, tabList }; | ||
}; | ||
|
||
export default useNavigationTabs; |
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.
아직 path가 확정이 아니라서, ROUTE 상수를 이용하지 않은 건가요?
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.
넵,,, 일단 임시로,, 넣어놨어요
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.
경로 거의 확정된 것 같아서 추가했습니다~