-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
홈 화면 - 네비게이션 바 + 태그 추가 개발 w/ 공용 훅 (#140)
* feat: mypage RouterPathType 추가 * feat: HomeNavigationBar 컴포넌트 개발 * design: global, layout 높이 삭제 * fix: TagForm 오타 수정 * feat: NavigationBar backLinkScrollOption prop 추가 * feat: usePreventScroll hook 개발 * feat: useRouterQuery hook 개발 * chore: RouterPathType 추가 * chore: home/AppendButton z-index 수정 * feat: 홈 태그 추가 (/tag) Route as Modal 적용 * chore: dynamic import 태그 route as modal * feat: filteredTags 전역 상태 추가 * chore: /tag route filteredTags 사용으로 변경
- Loading branch information
Showing
19 changed files
with
280 additions
and
68 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Link from 'next/link'; | ||
import { css, Theme } from '@emotion/react'; | ||
|
||
import { FilterIcon, SettingsIcon } from '../common/icons'; | ||
import InternalLink from '../common/InternalLink'; | ||
|
||
export default function HomeNavigationBar() { | ||
return ( | ||
<nav css={navCss}> | ||
<Link href="/?modal=tag" as="/tag" scroll={false}> | ||
<a> | ||
<FilterIcon css={iconCss} /> | ||
</a> | ||
</Link> | ||
<InternalLink href="/my"> | ||
<a> | ||
<SettingsIcon css={iconCss} /> | ||
</a> | ||
</InternalLink> | ||
</nav> | ||
); | ||
} | ||
|
||
const navCss = (theme: Theme) => css` | ||
position: sticky; | ||
top: 0; | ||
width: 100%; | ||
height: 44px; | ||
background-color: ${theme.color.background}; | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: center; | ||
gap: 4px; | ||
`; | ||
|
||
const iconCss = (theme: Theme) => css` | ||
margin: 10px; | ||
color: ${theme.color.gray05}; | ||
`; |
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 { css, Theme } from '@emotion/react'; | ||
|
||
import PortalWrapper from '~/components/common/PortalWrapper'; | ||
import usePreventScroll from '~/hooks/common/usePreventScroll'; | ||
import useQueryParam from '~/hooks/common/useRouterQuery'; | ||
import TagPage from '~/pages/tag'; | ||
|
||
export default function TagFormRouteAsModal() { | ||
const query = useQueryParam('modal', String); | ||
|
||
usePreventScroll(Boolean(query)); | ||
|
||
return ( | ||
<PortalWrapper isShowing={Boolean(query)}> | ||
<div css={wrapperCss}> | ||
<TagPage /> | ||
</div> | ||
</PortalWrapper> | ||
); | ||
} | ||
|
||
const wrapperCss = (theme: Theme) => css` | ||
position: fixed; | ||
top: 0; | ||
/* 가로 가운데 정렬 */ | ||
left: 50%; | ||
transform: translateX(-50%); | ||
width: 100%; | ||
max-width: ${theme.size.maxWidth}; | ||
height: 100vh; | ||
background-color: ${theme.color.background}; | ||
padding: ${theme.size.layoutPadding}; | ||
z-index: 1000; | ||
`; |
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 @@ | ||
export { default } from './usePreventScroll'; |
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,13 @@ | ||
import { useEffect } from 'react'; | ||
|
||
export default function usePreventScroll(condition: boolean = true) { | ||
useEffect(() => { | ||
if (typeof document === 'undefined') return; | ||
if (condition) document.body.style.overflow = 'hidden'; | ||
else document.body.style.overflow = 'unset'; | ||
|
||
return () => { | ||
document.body.style.overflow = 'unset'; | ||
}; | ||
}, [condition]); | ||
} |
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 @@ | ||
export { default } from './useRouterQuery'; |
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,19 @@ | ||
import { useRouter } from 'next/router'; | ||
|
||
function useQueryParam(key: string): string | string[] | undefined; | ||
|
||
function useQueryParam<T>(key: string, parser: (value: string | string[]) => T): T | undefined; | ||
|
||
function useQueryParam<T>( | ||
key: string, | ||
parser?: (value: string | string[]) => T | ||
): (string | string[] | T) | undefined { | ||
const { query } = useRouter(); | ||
const result = query[key]; | ||
|
||
if (result === undefined) return undefined; | ||
if (parser) return parser(result); | ||
return result; | ||
} | ||
|
||
export default useQueryParam; |
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
Oops, something went wrong.