Skip to content

Commit

Permalink
정답 조회 페이지 작업하기 (#18)
Browse files Browse the repository at this point in the history
* feat: 헤더 컴포넌트 분리 작업

* feat: 임시 404페이지 구성

* style: outline 제거
  • Loading branch information
jgjgill authored Dec 21, 2023
1 parent 93f9645 commit e13f1b2
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 13 deletions.
25 changes: 14 additions & 11 deletions app/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Image from 'next/image';
import { QuizCard } from '@/components/quiz/quiz-card';
import FullButton from '@/components/common/buttons/full-button';
import Button from '@/components/common/buttons/button';
import Header from '@/components/header';

export default async function Page() {
const cookieStore = cookies();
Expand All @@ -24,26 +25,28 @@ export default async function Page() {
await supabase.auth.signOut();
};

const HeaderRightArea = user ? (
<form action={signOut}>
<Button className="h-full">로그아웃</Button>
</form>
) : (
<KakaoButton />
);

return (
<>
<header className="sticky top-0 z-50 h-16 border-b-2 border-slate-50 bg-white">
<div className="flex justify-between">
<Header
leftArea={
<Image
src={TypeTimeLogo}
alt="타입타임 로고"
width={158}
height={63}
priority
/>
{user ? (
<form action={signOut}>
<Button className="h-full">로그아웃</Button>
</form>
) : (
<KakaoButton />
)}
</div>
</header>
}
rightArea={HeaderRightArea}
/>

<main>
<div className="flex flex-col gap-6">
Expand Down
7 changes: 7 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
@tailwind components;
@tailwind utilities;

@layer base {
input,
textarea {
@apply focus:outline-none;
}
}

#background {
@apply fixed h-full w-full bg-slate-50 lg:bg-gradient-to-r lg:from-sky-400 lg:to-indigo-400;
}
Expand Down
23 changes: 23 additions & 0 deletions app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import BackButton from '@/components/common/buttons/back-button';
import Header from '@/components/header';
import Image from 'next/image';
import Link from 'next/link';
import TypeTime from '@/assets/images/type-time.png';

export default function NotFound() {
return (
<>
<Header leftArea={<BackButton />} />
<div className="mt-40 flex max-w-md flex-col items-center gap-4">
<Image src={TypeTime} alt="로고" priority width={160} height={160} />
<p className="text-lg">페이지를 찾을 수 없습니다.</p>
<Link
href="/"
className="rounded bg-blue-600 px-4 py-2 text-2xl font-bold text-white"
>
홈으로 이동하기
</Link>
</div>
</>
);
}
24 changes: 24 additions & 0 deletions app/quizzes/[id]/answer/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import BackButton from '@/components/common/buttons/back-button';
import Header from '@/components/header';
import Link from 'next/link';
import UserProfile from '@/assets/images/user-profile.png';
import Image from 'next/image';

export default function Page() {
return (
<>
<Header
leftArea={<BackButton />}
centerArea={
<h1 className="text-xl font-bold text-blue-700">TypeTime</h1>
}
rightArea={
<Link href="/">
<Image src={UserProfile} width={50} height={50} alt="유저 프로필" />
</Link>
}
/>
<div>{'수정 예정'}</div>
</>
);
}
Binary file added assets/images/type-time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/user-profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions components/common/buttons/back-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use client';

import { useRouter } from 'next/navigation';
import Button from './button';

export default function BackButton() {
const router = useRouter();

return <Button onClick={() => router.back()}>뒤로가기</Button>;
}
2 changes: 1 addition & 1 deletion components/common/buttons/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { twMerge } from 'tailwind-merge';
type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> &
VariantProps<typeof button>;

const button = cva(['rounded border text-white'], {
const button = cva(['rounded text-white'], {
variants: {
intent: {
primary: ['bg-blue-600', 'hover:bg-blue-700'],
Expand Down
27 changes: 27 additions & 0 deletions components/header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
type HeaderProps = {
leftArea?: JSX.Element;
centerArea?: JSX.Element;
rightArea?: JSX.Element;
};

export default function Header({
leftArea,
centerArea,
rightArea,
}: HeaderProps) {
return (
<header className="sticky top-0 z-50 h-16 border-b-2 border-slate-50 bg-white">
<div className="relative h-full">
<div className="absolute left-0 top-1/2 -translate-y-1/2">
{leftArea}
</div>
<div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2">
{centerArea}
</div>
<div className="absolute right-0 top-1/2 -translate-y-1/2">
{rightArea}
</div>
</div>
</header>
);
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e13f1b2

Please sign in to comment.