-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor : tasklist 생성 모달을 parallel & intercepting routing 방식으로 변경 #173
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c97fa83
Feat : intercepting routes 방식 모달에 맞는 모달 컴포넌트 분리
KSJ27 e77ac26
Feat : intercepting routing 방식 모달의 라우팅 주소를 바꾸고, 렌더링 위치를 루트 레이아웃으로 변경
KSJ27 9ff07e6
Feat : 모달 안 열었을 때 기본 라우트 페이지 구현
KSJ27 57a0885
Refactor : tasklist 생성 모달 라우트 변경
KSJ27 93475d0
Fix : tasklist 생성 모달 경로 직접 방문 시 not found 렌더링
KSJ27 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
30 changes: 0 additions & 30 deletions
30
src/app/(content-layout)/[groupId]/(groupId)/@modal/(.)create/page.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
56 changes: 56 additions & 0 deletions
56
src/app/(content-layout)/[groupId]/(groupId)/create-tasklist/page.tsx
This file contains hidden or 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,56 @@ | ||
| 'use client'; | ||
| import { useState } from 'react'; | ||
| import { useParams } from 'next/navigation'; | ||
| import Button from '@/components/common/Button'; | ||
| import FormField from '@/components/common/formField'; | ||
| import Modal from '@/components/common/modal/newModal'; | ||
| import BouncingDots from '@/components/common/loading/BouncingDots'; | ||
| import { validateEmptyValue } from '@/utils/validators'; | ||
| import { createTasklistAction } from '@/app/(content-layout)/[groupId]/(groupId)/_[groupId]/Tasklists/actions'; | ||
|
|
||
| export default function Page() { | ||
| const { groupId } = useParams<{ groupId: string }>(); | ||
| const [name, setName] = useState(''); | ||
| const [isLoading, setIsLoading] = useState(false); | ||
|
|
||
| const handleChangeName = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| setName(e.target.value); | ||
| }; | ||
|
|
||
| const handleClickAddButton = async () => { | ||
| setIsLoading(true); | ||
| if (validateEmptyValue(name)) { | ||
| setIsLoading(false); | ||
| return; | ||
| } | ||
| createTasklistAction(Number(groupId), name).then(() => { | ||
| setIsLoading(false); | ||
| }); | ||
| }; | ||
|
|
||
| return ( | ||
| <main className="flex h-[calc(100vh-92px)] flex-col items-center justify-center"> | ||
| <div className="w-fit"> | ||
| <Modal.CloseButton /> | ||
| <div className="mb-6 w-70"> | ||
| <Modal.Heading className="mb-2">할 일 목록 추가</Modal.Heading> | ||
| <FormField | ||
| field="input" | ||
| placeholder="목록 이름을 입력해주세요." | ||
| isSuccess={!validateEmptyValue(name)} | ||
| isFailure={validateEmptyValue(name)} | ||
| errorMessage="이름을 입력해 주세요." | ||
| value={name} | ||
| onChange={handleChangeName} | ||
| disabled={isLoading} | ||
| /> | ||
| </div> | ||
| <Modal.Footer className="w-70"> | ||
| <Button onClick={handleClickAddButton} fontSize="16" size="fullWidth"> | ||
| {isLoading ? <BouncingDots /> : '만들기'} | ||
| </Button> | ||
| </Modal.Footer> | ||
| </div> | ||
| </main> | ||
| ); | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,58 @@ | ||
| 'use client'; | ||
| import { useState } from 'react'; | ||
| import { useParams, useRouter } from 'next/navigation'; | ||
| import Button from '@/components/common/Button'; | ||
| import FormField from '@/components/common/formField'; | ||
| import Modal from '@/components/common/modal/newModal'; | ||
| import BouncingDots from '@/components/common/loading/BouncingDots'; | ||
| import { validateEmptyValue } from '@/utils/validators'; | ||
| import { createTasklistAction } from '@/app/(content-layout)/[groupId]/(groupId)/_[groupId]/Tasklists/actions'; | ||
|
|
||
| export default function TasklistCreateModal() { | ||
| const { groupId } = useParams<{ groupId: string }>(); | ||
| const router = useRouter(); | ||
| const [name, setName] = useState(''); | ||
| const [isLoading, setIsLoading] = useState(false); | ||
|
|
||
| const handleChangeName = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| setName(e.target.value); | ||
| }; | ||
|
|
||
| const handleClickAddButton = async () => { | ||
| setIsLoading(true); | ||
| if (validateEmptyValue(name)) { | ||
| setIsLoading(false); | ||
| return; | ||
| } | ||
| createTasklistAction(Number(groupId), name).then(() => { | ||
| setIsLoading(false); | ||
| router.back(); | ||
| }); | ||
| }; | ||
|
|
||
| return ( | ||
| <Modal.Overlay> | ||
| <Modal.Container className="px-13 pt-12 pb-8 md:px-13 md:pt-12 md:pb-8"> | ||
| <Modal.CloseButton /> | ||
| <div className="mb-6 w-70"> | ||
| <Modal.Heading className="mb-2">할 일 목록 추가</Modal.Heading> | ||
| <FormField | ||
| field="input" | ||
| placeholder="목록 이름을 입력해주세요." | ||
| isSuccess={!validateEmptyValue(name)} | ||
| isFailure={validateEmptyValue(name)} | ||
| errorMessage="이름을 입력해 주세요." | ||
| value={name} | ||
| onChange={handleChangeName} | ||
| disabled={isLoading} | ||
| /> | ||
| </div> | ||
| <Modal.Footer className="w-70"> | ||
| <Button onClick={handleClickAddButton} fontSize="16" size="fullWidth"> | ||
| {isLoading ? <BouncingDots /> : '만들기'} | ||
| </Button> | ||
| </Modal.Footer> | ||
| </Modal.Container> | ||
| </Modal.Overlay> | ||
| ); | ||
| } |
File renamed without changes.
This file contains hidden or 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 hidden or 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,23 @@ | ||
| 'use client'; | ||
| import Image from 'next/image'; | ||
| import { useRouter } from 'next/navigation'; | ||
| import clsx from 'clsx'; | ||
|
|
||
| export default function ModalCloseButton({ | ||
| className, | ||
| onClick, | ||
| ...props | ||
| }: React.ComponentProps<'button'>) { | ||
| const router = useRouter(); | ||
|
|
||
| const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => { | ||
| onClick?.(e); | ||
| router.back(); | ||
| }; | ||
|
|
||
| return ( | ||
| <button className={clsx('absolute top-4 right-4', className)} onClick={handleClick} {...props}> | ||
| <Image width={24} height={24} alt="x" src={'/icons/x-icon.svg'} /> | ||
| </button> | ||
| ); | ||
| } |
This file contains hidden or 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,15 @@ | ||
| import clsx from 'clsx'; | ||
|
|
||
| export default function Container({ className, children, ...props }: React.ComponentProps<'div'>) { | ||
| return ( | ||
| <div | ||
| className={clsx( | ||
| 'bg-bg200 animate-slide-up md:animate-scale-in absolute bottom-0 flex h-fit w-full flex-col items-center rounded-t-xl px-5 py-8 shadow-2xl/30 md:relative md:w-fit md:rounded-b-xl md:px-6', | ||
| className | ||
| )} | ||
| {...props} | ||
| > | ||
| {children} | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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,15 @@ | ||
| import clsx from 'clsx'; | ||
|
|
||
| export default function Description({ className, children, ...props }: React.ComponentProps<'p'>) { | ||
| return ( | ||
| <p | ||
| className={clsx( | ||
| 'text-gray300 text-sm-md text-center break-keep whitespace-normal', | ||
| className | ||
| )} | ||
| {...props} | ||
| > | ||
| {children} | ||
| </p> | ||
| ); | ||
| } |
This file contains hidden or 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,9 @@ | ||
| import clsx from 'clsx'; | ||
|
|
||
| export default function Footer({ className, children, ...props }: React.ComponentProps<'div'>) { | ||
| return ( | ||
| <div className={clsx('flex justify-center gap-2', className)} {...props}> | ||
| {children} | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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,12 @@ | ||
| import clsx from 'clsx'; | ||
|
|
||
| export default function Heading({ className, children, ...props }: React.ComponentProps<'h2'>) { | ||
| return ( | ||
| <h2 | ||
| className={clsx('text-lg-md text-center break-keep whitespace-normal', className)} | ||
| {...props} | ||
| > | ||
| {children} | ||
| </h2> | ||
| ); | ||
| } |
This file contains hidden or 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,47 @@ | ||
| 'use client'; | ||
| import { useEffect } from 'react'; | ||
| import { useRouter } from 'next/navigation'; | ||
| import clsx from 'clsx'; | ||
|
|
||
| interface OverlayProps extends React.ComponentProps<'div'> { | ||
| disableOverlayClose?: boolean; | ||
| } | ||
|
|
||
| export default function Overlay({ | ||
| disableOverlayClose = false, | ||
| onClick, | ||
| className, | ||
| children, | ||
| ...props | ||
| }: OverlayProps) { | ||
| const router = useRouter(); | ||
|
|
||
| const handleClick = (e: React.MouseEvent<HTMLDivElement>) => { | ||
| if (e.target === e.currentTarget && !disableOverlayClose) { | ||
| onClick?.(e); | ||
| router.back(); | ||
| } | ||
| }; | ||
|
|
||
| useEffect(function lockBodyScroll() { | ||
| const originalStyle = window.getComputedStyle(document.body).overflow; | ||
| document.body.style.overflow = 'hidden'; | ||
|
|
||
| return () => { | ||
| document.body.style.overflow = originalStyle; | ||
| }; | ||
| }, []); | ||
|
|
||
| return ( | ||
| <div | ||
| className={clsx( | ||
| 'fixed inset-0 z-999 flex items-center justify-center bg-black/50 backdrop-blur-md transition', | ||
| className | ||
| )} | ||
| onClick={handleClick} | ||
| {...props} | ||
| > | ||
| {children} | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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,17 @@ | ||
| import CloseButton from './CloseButton'; | ||
| import Container from './Container'; | ||
| import Description from './Description'; | ||
| import Footer from './Footer'; | ||
| import Heading from './Heading'; | ||
| import Overlay from './Overlay'; | ||
|
|
||
| const Modal = { | ||
| CloseButton, | ||
| Container, | ||
| Description, | ||
| Footer, | ||
| Heading, | ||
| Overlay, | ||
| }; | ||
|
|
||
| export default Modal; |
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.
띄어쓰기 발견!!