diff --git a/app/quizzes/[id]/layout.tsx b/app/quizzes/[id]/layout.tsx new file mode 100644 index 0000000..a9f56a0 --- /dev/null +++ b/app/quizzes/[id]/layout.tsx @@ -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 ( +
+
+ + 퀴즈 + + + 질문 + +
+ {children} +
+ ); +} diff --git a/app/quizzes/[id]/loading.tsx b/app/quizzes/[id]/loading.tsx new file mode 100644 index 0000000..73f9e20 --- /dev/null +++ b/app/quizzes/[id]/loading.tsx @@ -0,0 +1,9 @@ +import LoadingSpinner from '@/components/common/loading-spinner/loading-spinner'; + +export default function Loading() { + return ( +
+ +
+ ); +} diff --git a/app/quizzes/[id]/page.tsx b/app/quizzes/[id]/page.tsx index 24adb93..6d27a55 100644 --- a/app/quizzes/[id]/page.tsx +++ b/app/quizzes/[id]/page.tsx @@ -22,49 +22,47 @@ export default async function Page({ params }: { params: { id: string } }) { return ( -
-
-

출제자

- {/* TODO: 추후 상세 유저 페이지 라우팅 경로로 변경하기 */} - - {quiz?.users?.name} - -
+
+

출제자

+ {/* TODO: 추후 상세 유저 페이지 라우팅 경로로 변경하기 */} + + {quiz?.users?.name} + +
-
-

문제

- - {String(children).replace(/\n$/, '')} - - ) : ( - - {children} - - ); - }, - }} - > - {quiz?.description} - -
+
+

문제

+ + {String(children).replace(/\n$/, '')} + + ) : ( + + {children} + + ); + }, + }} + > + {quiz?.description} + +
-
- -
-
+
+ +
); } diff --git a/app/quizzes/[id]/questions/page.tsx b/app/quizzes/[id]/questions/page.tsx new file mode 100644 index 0000000..08ad9ea --- /dev/null +++ b/app/quizzes/[id]/questions/page.tsx @@ -0,0 +1,5 @@ +export default async function Page({ params }: { params: { id: string } }) { + const quizId = Number(params.id) ?? 0; + + return
{quizId}번 퀴즈에 대한 질문 페이지
; +} diff --git a/components/common/link/nav-link.tsx b/components/common/link/nav-link.tsx new file mode 100644 index 0000000..9745a34 --- /dev/null +++ b/components/common/link/nav-link.tsx @@ -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 & + VariantProps; + +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 +) { + const pathname = usePathname(); + const isActive = pathname === href; + + return ( + + {children} + + ); +}); diff --git a/components/common/loading-spinner/loading-spinner.tsx b/components/common/loading-spinner/loading-spinner.tsx index 51506f7..1616cda 100644 --- a/components/common/loading-spinner/loading-spinner.tsx +++ b/components/common/loading-spinner/loading-spinner.tsx @@ -1,6 +1,6 @@ +import { cn } from '@/libs/utils'; import { cva, type VariantProps } from 'class-variance-authority'; import { forwardRef, type Ref } from 'react'; -import { twMerge } from 'tailwind-merge'; type LoadingSpinnerProps = React.HTMLAttributes & VariantProps; @@ -36,7 +36,7 @@ export default forwardRef(function LoadingSpinner( return (
);