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

Auth.tsx

54 lines1.6 KB

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