225 lines
11 KiB
TypeScript
225 lines
11 KiB
TypeScript
import Link from "next/link";
|
|
import { login } from "@/features/auth/actions";
|
|
import FormMessage from "@/components/form-message";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Label } from "@/components/ui/label";
|
|
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from "@/components/ui/card";
|
|
import { Checkbox } from "@/components/ui/checkbox";
|
|
import { Separator } from "@/components/ui/separator";
|
|
|
|
/**
|
|
* [로그인 페이지 컴포넌트]
|
|
*
|
|
* Modern UI with glassmorphism effect (유리 형태 디자인)
|
|
* - 투명 배경 + 블러 효과로 깊이감 표현
|
|
* - 그라디언트 배경으로 생동감 추가
|
|
* - shadcn/ui 컴포넌트로 일관된 디자인 시스템 유지
|
|
*
|
|
* @param searchParams - URL 쿼리 파라미터 (에러 메시지 전달용)
|
|
*/
|
|
export default async function LoginPage({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<{ message: string }>;
|
|
}) {
|
|
// URL에서 메시지 파라미터 추출 (로그인 실패 시 에러 메시지 표시)
|
|
const { message } = await searchParams;
|
|
|
|
return (
|
|
<div className="relative flex min-h-screen items-center justify-center overflow-hidden bg-gradient-to-br from-indigo-50 via-purple-50 to-pink-50 px-4 py-12 dark:from-gray-950 dark:via-indigo-950 dark:to-purple-950">
|
|
{/* ========== 배경 그라디언트 레이어 ========== */}
|
|
{/* 웹 페이지 전체 배경을 그라디언트로 채웁니다 */}
|
|
{/* 라이트 모드: 부드러운 파스텔 톤 (indigo → purple → pink) */}
|
|
{/* 다크 모드: 진한 어두운 톤으로 눈부심 방지 */}
|
|
|
|
{/* 추가 그라디언트 효과 1: 우상단에서 시작하는 원형 그라디언트 */}
|
|
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_top_right,_var(--tw-gradient-stops))] from-indigo-200/40 via-purple-200/20 to-transparent dark:from-indigo-900/30 dark:via-purple-900/20" />
|
|
|
|
{/* 추가 그라디언트 효과 2: 좌하단에서 시작하는 원형 그라디언트 */}
|
|
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_bottom_left,_var(--tw-gradient-stops))] from-pink-200/40 via-purple-200/20 to-transparent dark:from-pink-900/30 dark:via-purple-900/20" />
|
|
|
|
{/* ========== 애니메이션 블러 효과 ========== */}
|
|
{/* 부드럽게 깜빡이는 원형 블러로 생동감 표현 */}
|
|
{/* animate-pulse: 1.5초 주기로 opacity 변화 */}
|
|
<div className="absolute left-1/4 top-1/4 h-64 w-64 animate-pulse rounded-full bg-indigo-400/30 blur-3xl dark:bg-indigo-600/20" />
|
|
{/* delay-700: 700ms 지연으로 교차 애니메이션 효과 */}
|
|
<div className="absolute bottom-1/4 right-1/4 h-64 w-64 animate-pulse rounded-full bg-purple-400/30 blur-3xl delay-700 dark:bg-purple-600/20" />
|
|
|
|
{/* ========== 메인 콘텐츠 영역 ========== */}
|
|
{/* z-10: 배경보다 위에 표시 */}
|
|
{/* animate-in: 페이지 로드 시 fade-in + slide-up 애니메이션 */}
|
|
<div className="relative z-10 w-full max-w-md animate-in fade-in slide-in-from-bottom-4 duration-700">
|
|
{/* 에러/성공 메시지 표시 영역 */}
|
|
{/* URL 파라미터에 message가 있으면 표시됨 */}
|
|
<FormMessage message={message} />
|
|
|
|
{/* ========== 로그인 카드 (Glassmorphism) ========== */}
|
|
{/* bg-white/70: 70% 투명도의 흰색 배경 */}
|
|
{/* backdrop-blur-xl: 배경 블러 효과 (유리 느낌) */}
|
|
<Card className="border-white/20 bg-white/70 shadow-2xl backdrop-blur-xl dark:border-white/10 dark:bg-gray-900/70">
|
|
{/* ========== 카드 헤더 영역 ========== */}
|
|
<CardHeader className="space-y-3 text-center">
|
|
{/* 아이콘 배경: 그라디언트 원형 */}
|
|
<div className="mx-auto mb-2 flex h-16 w-16 items-center justify-center rounded-2xl bg-gradient-to-br from-indigo-500 to-purple-600 shadow-lg">
|
|
<span className="text-4xl">👋</span>
|
|
</div>
|
|
{/* 페이지 제목 */}
|
|
<CardTitle className="text-3xl font-bold tracking-tight">
|
|
환영합니다!
|
|
</CardTitle>
|
|
{/* 페이지 설명 */}
|
|
<CardDescription className="text-base">
|
|
서비스 이용을 위해 로그인해 주세요.
|
|
</CardDescription>
|
|
</CardHeader>
|
|
|
|
{/* ========== 카드 콘텐츠 영역 (폼) ========== */}
|
|
<CardContent className="space-y-6">
|
|
{/* 로그인 폼 - formAction으로 서버 액션(login) 연결 */}
|
|
<form className="space-y-5">
|
|
{/* ========== 이메일 입력 필드 ========== */}
|
|
<div className="space-y-2">
|
|
{/* htmlFor와 Input의 id 연결로 접근성 향상 */}
|
|
<Label htmlFor="email" className="text-sm font-medium">
|
|
이메일
|
|
</Label>
|
|
{/* autoComplete="email": 브라우저 자동완성 기능 활성화 */}
|
|
{/* required: HTML5 필수 입력 검증 */}
|
|
<Input
|
|
id="email"
|
|
name="email"
|
|
type="email"
|
|
placeholder="your@email.com"
|
|
autoComplete="email"
|
|
required
|
|
className="h-11 transition-all duration-200"
|
|
/>
|
|
</div>
|
|
|
|
{/* ========== 비밀번호 입력 필드 ========== */}
|
|
<div className="space-y-2">
|
|
<Label htmlFor="password" className="text-sm font-medium">
|
|
비밀번호
|
|
</Label>
|
|
{/* pattern: 최소 8자, 대문자, 소문자, 숫자, 특수문자 각 1개 이상 */}
|
|
{/* 참고: HTML pattern에서는 <, >, {, } 등 일부 특수문자 사용 시 브라우저 호환성 문제 발생 */}
|
|
<Input
|
|
id="password"
|
|
name="password"
|
|
type="password"
|
|
placeholder="••••••••"
|
|
autoComplete="current-password"
|
|
required
|
|
minLength={8}
|
|
pattern="^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*]).{8,}$"
|
|
title="비밀번호는 최소 8자 이상, 대문자, 소문자, 숫자, 특수문자를 각각 1개 이상 포함해야 합니다."
|
|
className="h-11 transition-all duration-200"
|
|
/>
|
|
</div>
|
|
|
|
{/* 로그인 유지 & 비밀번호 찾기 */}
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center space-x-2">
|
|
<Checkbox id="remember" name="remember-me" />
|
|
<Label
|
|
htmlFor="remember"
|
|
className="cursor-pointer text-sm font-normal leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
>
|
|
로그인 유지
|
|
</Label>
|
|
</div>
|
|
{/* 비밀번호 찾기 링크 */}
|
|
<Link
|
|
href="/forgot-password"
|
|
className="text-sm font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300"
|
|
>
|
|
비밀번호 찾기
|
|
</Link>
|
|
</div>
|
|
|
|
{/* 로그인 버튼 */}
|
|
<Button
|
|
formAction={login}
|
|
type="submit"
|
|
className="h-11 w-full bg-gradient-to-r from-indigo-600 to-purple-600 font-semibold shadow-lg transition-all duration-200 hover:from-indigo-700 hover:to-purple-700 hover:shadow-xl"
|
|
size="lg"
|
|
>
|
|
로그인
|
|
</Button>
|
|
|
|
{/* 회원가입 링크 */}
|
|
<p className="text-center text-sm text-gray-600 dark:text-gray-400">
|
|
계정이 없으신가요?{" "}
|
|
<Link
|
|
href="/signup"
|
|
className="font-semibold text-indigo-600 transition-colors hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300"
|
|
>
|
|
회원가입 하기
|
|
</Link>
|
|
</p>
|
|
</form>
|
|
|
|
{/* 소셜 로그인 구분선 */}
|
|
<div className="relative">
|
|
<Separator className="my-6" />
|
|
<span className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white px-3 text-xs font-medium text-gray-500 dark:bg-gray-900 dark:text-gray-400">
|
|
또는 소셜 로그인
|
|
</span>
|
|
</div>
|
|
|
|
{/* 소셜 로그인 버튼들 */}
|
|
<div className="grid grid-cols-2 gap-3">
|
|
<Button
|
|
type="button"
|
|
variant="outline"
|
|
className="h-11 border-gray-200 bg-white shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-750"
|
|
>
|
|
<svg className="mr-2 h-5 w-5" viewBox="0 0 24 24">
|
|
<path
|
|
fill="currentColor"
|
|
d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
|
|
/>
|
|
<path
|
|
fill="currentColor"
|
|
d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
|
|
/>
|
|
<path
|
|
fill="currentColor"
|
|
d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"
|
|
/>
|
|
<path
|
|
fill="currentColor"
|
|
d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
|
|
/>
|
|
</svg>
|
|
Google
|
|
</Button>
|
|
<Button
|
|
type="button"
|
|
variant="outline"
|
|
className="h-11 border-none bg-[#FEE500] font-semibold text-[#3C1E1E] shadow-sm transition-all duration-200 hover:bg-[#FDD835] hover:shadow-md"
|
|
>
|
|
<svg
|
|
className="mr-2 h-5 w-5"
|
|
viewBox="0 0 24 24"
|
|
fill="currentColor"
|
|
>
|
|
<path d="M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9 9-4.03 9-9-4.03-9-9-9zm-1.5 14.5h-3v-9h3v9zm3 0h-3v-5h3v5zm0-6h-3v-3h3v3z" />
|
|
</svg>
|
|
Kakao
|
|
</Button>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|