-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathlogin.tsx
66 lines (62 loc) · 1.8 KB
/
login.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { createForm, email, minLength, required } from '@modular-forms/solid';
import { FormFooter, FormHeader, TextInput, Title } from '~/components';
type LoginForm = {
email: string;
password: string;
};
export default function LoginPage() {
// Create login form
const [loginForm, { Form, Field }] = createForm<LoginForm>();
return (
<>
<Title>Login form</Title>
<Form
class="space-y-12 md:space-y-14 lg:space-y-16"
onSubmit={(values) => alert(JSON.stringify(values, null, 4))}
>
<FormHeader of={loginForm} heading="Login form" />
<div class="space-y-8 md:space-y-10 lg:space-y-12">
<Field
name="email"
validate={[
required('Please enter your email.'),
email('The email address is badly formatted.'),
]}
>
{(field, props) => (
<TextInput
{...props}
value={field.value}
error={field.error}
type="email"
label="Email"
placeholder="example@email.com"
required
/>
)}
</Field>
<Field
name="password"
validate={[
required('Please enter your password.'),
minLength(8, 'You password must have 8 characters or more.'),
]}
>
{(field, props) => (
<TextInput
{...props}
value={field.value}
error={field.error}
type="password"
label="Password"
placeholder="********"
required
/>
)}
</Field>
</div>
<FormFooter of={loginForm} />
</Form>
</>
);
}