Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

Auth.tsx

59 lines1.7 KB

1import type { JSX } from 'solid-js'
2​
3export function Auth({
4 actionText,
5 onSubmit,
6 status,
7 afterSubmit,
8}: {
9 actionText: string
10 onSubmit: (e: HTMLFormElement) => void
11 status: 'pending' | 'idle' | 'success' | 'error'
12 afterSubmit?: () => JSX.Element
13}) {
14 return (
15 <div class="fixed inset-0 bg-white dark:bg-black flex items-start justify-center p-8">
16 <div class="bg-white dark:bg-gray-900 p-8 rounded-lg shadow-lg">
17 <h1 class="text-2xl font-bold mb-4">{actionText}</h1>
18 <form
19 onSubmit={(e: any) => {
20 e.preventDefault()
21 onSubmit(e)
22 }}
23 class="space-y-4"
24 >
25 <div>
26 <label for="email" class="block text-xs">
27 Email
28 </label>
29 <input
30 type="email"
31 name="email"
32 id="email"
33 class="px-2 py-1 w-full rounded-sm border border-gray-500/20 bg-white dark:bg-gray-800"
34 />
35 </div>
36 <div>
37 <label for="password" class="block text-xs">
38 Password
39 </label>
40 <input
41 type="password"
42 name="password"
43 id="password"
44 class="px-2 py-1 w-full rounded-sm border border-gray-500/20 bg-white dark:bg-gray-800"
45 />
46 </div>
47 <button
48 type="submit"
49 class="w-full bg-cyan-600 text-white rounded-sm py-2 font-black uppercase"
50 disabled={status === 'pending'}
51 >
52 {status === 'pending' ? '...' : actionText}
53 </button>
54 {afterSubmit ? afterSubmit() : null}
55 </form>
56 </div>
57 </div>
58 )