Skip to content

Commit

Permalink
[frontend] Add login page ui
Browse files Browse the repository at this point in the history
  • Loading branch information
usatie committed Nov 10, 2023
1 parent 6ca5778 commit 1937935
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
11 changes: 11 additions & 0 deletions frontend/app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import LoginForm from '@/app/ui/login-form';

export default function LoginPage() {
return (
<main className="flex items-center justify-center md:h-screen">
<div className="relative mx-auto flex w-full max-w-[400px] flex-col space-y-2.5 p-4 md:-mt-32">
<LoginForm />
</div>
</main>
);
}
65 changes: 65 additions & 0 deletions frontend/app/ui/login-form.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
'use client';

import { useFormState, useFormStatus } from 'react-dom';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Card, CardHeader, CardTitle, CardContent, CardFooter } from '@/components/ui/card';

export default function LoginForm() {
return (
<>
<Card className="w-[300px]">
<CardHeader>
<CardTitle className="text-center">Pong</CardTitle>
</CardHeader>
<CardContent>
<Form />
</CardContent>
</Card>
</>
);
}

function login() {
// TODO: implement login
console.log("login");
}

function Form() {
return (
<form action={login}>
<div className="grid w-full items-center gap-8">
<div className="flex flex-col space-y-1.5">
<Label htmlFor="email">Email</Label>
<Input
id="email"
type="email"
name="email"
placeholder="Enter your email address"
/>
</div>
<div className="flex flex-col space-y-1.5">
<Label htmlFor="password">Password</Label>
<Input
id="password"
type="password"
name="password"
placeholder="Enter your password"
/>
</div>
<LoginButton />
</div>
</form>
);
}

function LoginButton() {
const { pending } = useFormStatus();

return (
<Button type="submit" aria-disabled={pending}>
Log in
</Button>
);
}

0 comments on commit 1937935

Please sign in to comment.