-
Notifications
You must be signed in to change notification settings - Fork 6
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
홈 화면 - 네비게이션 바 + 태그 추가 개발 w/ 공용 훅 #140
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3248bed
feat: mypage RouterPathType 추가
hyesungoh 0a250db
feat: HomeNavigationBar 컴포넌트 개발
hyesungoh d3dddde
design: global, layout 높이 삭제
hyesungoh a11503d
fix: TagForm 오타 수정
hyesungoh 93a3285
feat: NavigationBar backLinkScrollOption prop 추가
hyesungoh 977aeea
feat: usePreventScroll hook 개발
hyesungoh 88ada71
feat: useRouterQuery hook 개발
hyesungoh a577280
chore: RouterPathType 추가
hyesungoh 128daa1
chore: home/AppendButton z-index 수정
hyesungoh cd314c5
feat: 홈 태그 추가 (/tag) Route as Modal 적용
hyesungoh cc6ee85
chore: dynamic import 태그 route as modal
hyesungoh 79c5a87
feat: filteredTags 전역 상태 추가
hyesungoh b63dc1f
chore: /tag route filteredTags 사용으로 변경
hyesungoh 237e0ae
Merge remote-tracking branch 'origin/main' into issue/134
hyesungoh 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 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]); | ||
} | ||
Comment on lines
+3
to
+13
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. 오호~! 이 훅 좋은 방법인 것 같아요!! 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. 추가해주셔서 감사합니다 :) |
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.
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.
👍🏻👍🏻👍🏻👍🏻👍🏻👍🏻