-
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
[Feat] Route Nav 컴포넌트 구현 및 레이아웃 반영 #294
Changes from 7 commits
423fa8c
0a5aa51
5f736e4
3560fa6
c080969
9ebd061
cc0507a
242366d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { Suspense } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
import Button from '@/common/component/Button/Button'; | ||
import Flex from '@/common/component/Flex/Flex'; | ||
|
@@ -16,19 +15,15 @@ import ContentBox from '@/shared/component/ContentBox/ContentBox'; | |
import { useOpenModal } from '@/shared/store/modal'; | ||
|
||
const ArchivingPage = () => { | ||
const location = useLocation(); | ||
|
||
const sideBarRef = useOutsideClick(() => setSelectedBlock(undefined)); | ||
|
||
const { selectedBlock, setSelectedBlock, handleBlockClick } = useInteractTimeline(); | ||
|
||
const openModal = useOpenModal(); | ||
|
||
const teamId = new URLSearchParams(location.search).get('teamId'); | ||
|
||
if (!teamId) throw new Error('has no teamId'); | ||
const teamId = localStorage.getItem('teamId'); | ||
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. 이제 localStorage를 사용하는군요! |
||
|
||
const { ref, currentYear, currentMonth, handlePrevMonth, handleNextMonth, handleToday, endDay } = useDate(teamId); | ||
const { ref, currentYear, currentMonth, handlePrevMonth, handleNextMonth, handleToday, endDay } = useDate(teamId!); | ||
|
||
const handleOpenBlockModal = () => { | ||
openModal('create-block'); | ||
|
@@ -40,7 +35,7 @@ const ArchivingPage = () => { | |
variant="timeline" | ||
title="타임라인" | ||
headerOption={ | ||
<Button variant="secondary" size="small" onClick={handleOpenBlockModal}> | ||
<Button variant="secondary" onClick={handleOpenBlockModal}> | ||
타임블록 추가 | ||
</Button> | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,9 @@ const TimeLine = ( | |
{ selectedBlock, onBlockClick, currentYear, currentMonth, endDay }: TimeLineProps, | ||
ref: ForwardedRef<HTMLDivElement> | ||
) => { | ||
const teamId = new URLSearchParams(location.search).get('teamId'); | ||
if (!teamId) throw new Error('has no teamId'); | ||
const teamId = localStorage.getItem('teamId'); | ||
|
||
const { data } = useGetTimeBlockQuery(+teamId, 'executive', currentYear, currentMonth); | ||
const { data } = useGetTimeBlockQuery(+teamId!, 'executive', currentYear, currentMonth); | ||
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. 위에 Error 던지는 코드가 없어져서 요 ! 를 해준건가요? 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.
|
||
|
||
const timeBlocks: Block[] = data.timeBlocks; | ||
const blockFloors = alignBlocks(timeBlocks, endDay, currentMonth, currentYear); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { css } from '@emotion/react'; | ||
|
||
import { theme } from '@/common/style/theme/theme'; | ||
|
||
export const iconFillActiveStyle = (isActive: boolean) => | ||
css({ | ||
'& > path': { | ||
fill: isActive ? theme.colors.gray_800 : theme.colors.gray_500, | ||
}, | ||
}); | ||
|
||
export const iconStrokeActiveStyle = (isActive: boolean) => | ||
css({ | ||
'& > path': { | ||
stroke: isActive ? theme.colors.gray_800 : theme.colors.gray_500, | ||
}, | ||
}); | ||
|
||
export const navListStyle = css({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
gap: '8px', | ||
|
||
width: 'max-content', | ||
|
||
padding: '0.4rem', | ||
|
||
borderRadius: '8px', | ||
backgroundColor: theme.colors.gray_100, | ||
}); | ||
|
||
export const itemStyle = (isActive: boolean) => | ||
css({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
gap: '0.6rem', | ||
|
||
position: 'relative', | ||
padding: '0.6rem 0.8rem', | ||
|
||
backgroundColor: 'transparent', | ||
|
||
...theme.text.body08, | ||
color: isActive ? theme.colors.black : theme.colors.gray_500, | ||
|
||
whiteSpace: 'nowrap', | ||
|
||
zIndex: 2, | ||
}); | ||
|
||
export const indicatorStyle = css({ | ||
position: 'absolute', | ||
top: -2, | ||
|
||
width: '100%', | ||
height: '3.2rem', | ||
|
||
backgroundColor: theme.colors.white, | ||
|
||
borderRadius: '4px', | ||
|
||
zIndex: 1, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { motion } from 'framer-motion'; | ||
|
||
import { Link, useLocation } from 'react-router-dom'; | ||
|
||
import IcFolder from '@/common/asset/svg/ic_folder_copy.svg?react'; | ||
import IcHandOver from '@/common/asset/svg/ic_handover_empty.svg?react'; | ||
import IcTimeLine from '@/common/asset/svg/ic_nav_timeline.svg?react'; | ||
|
||
import { | ||
iconFillActiveStyle, | ||
iconStrokeActiveStyle, | ||
indicatorStyle, | ||
itemStyle, | ||
navListStyle, | ||
} from '@/shared/component/RouteNav/RouteNav.style'; | ||
import { PATH } from '@/shared/constant/path'; | ||
|
||
const RouteNav = () => { | ||
const { pathname } = useLocation(); | ||
|
||
const isDrivePage = pathname === PATH.DRIVE; | ||
const isArchivingPage = pathname === PATH.ARCHIVING; | ||
const isHandoverPage = pathname === PATH.HANDOVER; | ||
|
||
return ( | ||
<nav> | ||
<ul css={navListStyle}> | ||
<li css={{ position: 'relative' }}> | ||
<Link css={itemStyle(isDrivePage)} to={PATH.DRIVE}> | ||
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. Link 컴포넌트를 클릭하면 to 에 지정된 경로로 이동한다는 것은 알겠습니다. 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.
// router.tsx
return (
<BrowserRouter>
<Route path="..." element={<Home />} />
</BrowserRouter>
) 리액트 라우터에서 제공하는 브라우저라우터라는 태그 하위에 각각의 라우트 요소로 |
||
<IcFolder css={iconFillActiveStyle(isDrivePage)} width={16} height={16} /> | ||
파일 | ||
</Link> | ||
{isDrivePage && <motion.div layoutId="nav_indicator" css={indicatorStyle} />} | ||
</li> | ||
<li css={{ position: 'relative' }}> | ||
<Link css={itemStyle(isArchivingPage)} to={PATH.ARCHIVING}> | ||
<IcTimeLine css={iconStrokeActiveStyle(isArchivingPage)} width={16} height={16} /> | ||
타임라인 | ||
</Link> | ||
{isArchivingPage && <motion.div layoutId="nav_indicator" css={indicatorStyle} />} | ||
</li> | ||
<li css={{ position: 'relative' }}> | ||
<Link css={itemStyle(isHandoverPage)} to={PATH.HANDOVER}> | ||
<IcHandOver css={iconFillActiveStyle(isHandoverPage)} width={16} height={16} /> | ||
인수인계 노트 | ||
</Link> | ||
{isHandoverPage && <motion.div layoutId="nav_indicator" css={indicatorStyle} />} | ||
</li> | ||
</ul> | ||
</nav> | ||
); | ||
}; | ||
|
||
export default RouteNav; |
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.
처음 보는 친군데 이쁘네요!