Skip to content
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
merged 14 commits into from
May 8, 2022

Conversation

hyesungoh
Copy link
Member

@hyesungoh hyesungoh commented May 8, 2022

⛳️작업 내용

작업 기간이 기간이니,,, 나눠서 개발할 수도 있었지만 개발 진척도를 위해 뭉쳐서 개발했슴다

홈화면에 대한 부분

  • /tag route를 홈 화면에서 사용되는 태그 관리 route로 사용했습니다 + Route as modal로써 사용했습니다
  • components/home/TagFormRouteAsModal 에서 query param을 기준으로 모달을 보여주었습니다. (children으로 page 컴포넌트를 렌더링합니다)

공통되는 부분

  • TagFormTagFrom으로 돼 있어서 오타 수정했슴다
  • 자료형 보장을 함께 할 수 있는 useQueryParam 훅을 개발했습니다
  • Route as modal등에서 body의 스크롤 방지를 위한 usePreventScroll 훅을 개발했슴니다

📸스크린샷

⚡️사용 방법

  • useQueryParam
const foo = useQueryParam('foo'); // string | undefined
const num = useQueryParam('num', Number); // number | undefined
const barNum = useQueryParam('foo-num', Number) ?? -1; // number
  • usePreventScroll
const foo = useQueryParam('foo');

usePreventScroll(Boolean(foo)); // 안에 조건을 넣어주면 됨니다

📎공유

  • 리팩토링? 수정? 가능하다고 생각되는 부분은 NOTE: 달아놨어용
  • 현재 홈 화면 태그 추가에서도 전역 상태인 appliedTags를 사용하고 있어요. 영감 추가나 편집시에 태그가 비어있어야 한다면 특정 라우트 진입하거나, 언마운트시에 리셋하는 로직을 추가해야합니다!! (리코일 리셋 훅)

@hyesungoh hyesungoh added feat 새로운 기능 추가 style CSS 및 UI 디자인 변경 labels May 8, 2022
@hyesungoh hyesungoh added this to In progress in v1.0 via automation May 8, 2022
@hyesungoh hyesungoh self-assigned this May 8, 2022
@codecov
Copy link

codecov bot commented May 8, 2022

Codecov Report

Merging #140 (237e0ae) into main (2955f7c) will decrease coverage by 0.82%.
The diff coverage is 4.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #140      +/-   ##
==========================================
- Coverage   15.58%   14.76%   -0.83%     
==========================================
  Files         108      118      +10     
  Lines         943     1009      +66     
  Branches      143      152       +9     
==========================================
+ Hits          147      149       +2     
- Misses        771      829      +58     
- Partials       25       31       +6     
Impacted Files Coverage Δ
src/components/TagForm/index.tsx 0.00% <0.00%> (ø)
src/components/home/AppendButton.tsx 0.00% <ø> (ø)
src/components/home/HomeNavigationBar.tsx 0.00% <0.00%> (ø)
src/components/home/TagFormRouteAsModal.tsx 0.00% <0.00%> (ø)
src/hooks/common/useInternalRouter.ts 75.00% <ø> (ø)
src/hooks/common/usePreventScroll/index.ts 0.00% <0.00%> (ø)
.../hooks/common/usePreventScroll/usePreventScroll.ts 0.00% <0.00%> (ø)
src/hooks/common/useRouterQuery/index.ts 0.00% <0.00%> (ø)
src/hooks/common/useRouterQuery/useRouterQuery.ts 0.00% <0.00%> (ø)
src/pages/_app.tsx 0.00% <ø> (ø)
... and 9 more

Comment on lines +3 to +13
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]);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호~! 이 훅 좋은 방법인 것 같아요!!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추가해주셔서 감사합니다 :)

Copy link
Collaborator

@ddarkr ddarkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍👍👍👍👍 LGTM~!

@hyesungoh hyesungoh linked an issue May 8, 2022 that may be closed by this pull request
@hyesungoh hyesungoh added this to the Sprint 3 milestone May 8, 2022
@hyesungoh
Copy link
Member Author

filteredTags 변경

@cloudflare-pages
Copy link

cloudflare-pages bot commented May 8, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 237e0ae
Status: ✅  Deploy successful!
Preview URL: https://f227f162.ygt.pages.dev

View logs

Copy link
Member

@positiveko positiveko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다 :)

export default function HomeNavigationBar() {
return (
<nav css={navCss}>
<Link href="/?modal=tag" as="/tag" scroll={false}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻👍🏻👍🏻👍🏻👍🏻👍🏻

Comment on lines +3 to +13
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]);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추가해주셔서 감사합니다 :)

@hyesungoh hyesungoh merged commit 02d66b3 into main May 8, 2022
v1.0 automation moved this from In progress to Done May 8, 2022
@positiveko positiveko deleted the issue/134 branch May 12, 2022 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat 새로운 기능 추가 style CSS 및 UI 디자인 변경
Projects
v1.0
Done
Development

Successfully merging this pull request may close these issues.

홈 화면 - 네비게이션 바 개발
3 participants