-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: NavLink 컴포넌트 작성 * feat: NavLink 컴포넌트 사용 * refactor: QuizLinkTab 컴포넌트로 분리 * refactor: QuizLinkTab 제거 후 레이아웃 활용하는 방식으로 변경 * feat: 로딩 화면 작성 * style: twMerge 대신 cn으로 변경 * style: loaddingSpinner에 twMerge 대신 cn 적용
- Loading branch information
1 parent
5fa7d31
commit 2730c7e
Showing
6 changed files
with
127 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import NavLink from '@/components/common/link/nav-link'; | ||
import React from 'react'; | ||
|
||
interface LayoutProps { | ||
children: React.ReactNode; | ||
params: { | ||
id: string; | ||
}; | ||
} | ||
|
||
export default function Layout({ children, params }: LayoutProps) { | ||
const quizId = Number(params.id) ?? 0; | ||
|
||
return ( | ||
<section className="p-4"> | ||
<article className="mb-4 flex w-full"> | ||
<NavLink className="grow" href={`/quizzes/${quizId}`}> | ||
퀴즈 | ||
</NavLink> | ||
<NavLink className="grow" href={`/quizzes/${quizId}/questions`}> | ||
질문 | ||
</NavLink> | ||
</article> | ||
{children} | ||
</section> | ||
); | ||
} |
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,9 @@ | ||
import LoadingSpinner from '@/components/common/loading-spinner/loading-spinner'; | ||
|
||
export default function Loading() { | ||
return ( | ||
<section className="flex min-h-[90vh] items-center justify-center overflow-hidden"> | ||
<LoadingSpinner size="3xl" className="text-blue-600" /> | ||
</section> | ||
); | ||
} |
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,5 @@ | ||
export default async function Page({ params }: { params: { id: string } }) { | ||
const quizId = Number(params.id) ?? 0; | ||
|
||
return <section>{quizId}번 퀴즈에 대한 질문 페이지</section>; | ||
} |
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,45 @@ | ||
'use client'; | ||
|
||
import Link from 'next/link'; | ||
import { cva, type VariantProps } from 'class-variance-authority'; | ||
import { forwardRef, type Ref } from 'react'; | ||
import { usePathname } from 'next/navigation'; | ||
import { cn } from '@/libs/utils'; | ||
|
||
type NavLinkProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & | ||
VariantProps<typeof navLink>; | ||
|
||
const navLink = cva( | ||
['border-b-2 border-b-neutral-300 pb-2 text-center text-neutral-300'], | ||
{ | ||
variants: { | ||
intent: { | ||
primary: ['text-[#3077C6] ', 'border-b-[#3077C6]'], | ||
secondary: ['text-red-600', 'border-b-red-600'], | ||
}, | ||
}, | ||
defaultVariants: { intent: 'primary' }, | ||
} | ||
); | ||
|
||
export default forwardRef(function NavLink( | ||
{ children, className, intent, href, ...props }: NavLinkProps, | ||
forwardedRef: Ref<HTMLAnchorElement> | ||
) { | ||
const pathname = usePathname(); | ||
const isActive = pathname === href; | ||
|
||
return ( | ||
<Link | ||
ref={forwardedRef} | ||
href={href ?? '#'} | ||
className={cn( | ||
navLink({ intent: isActive ? intent : null, className }), | ||
isActive ? 'border-b-4 font-bold' : null | ||
)} | ||
{...props} | ||
> | ||
{children} | ||
</Link> | ||
); | ||
}); |
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