pradipp commited on
Commit
71dda7b
·
verified ·
1 Parent(s): af5e445

Upload components/LoginForm.jsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/LoginForm.jsx +124 -0
components/LoginForm.jsx ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState } from 'react'
2
+
3
+ export default function LoginForm({ onSubmit, isLoading, error }) {
4
+ const [email, setEmail] = useState('')
5
+ const [password, setPassword] = useState('')
6
+ const [showPassword, setShowPassword] = useState(false)
7
+
8
+ const handleSubmit = (e) => {
9
+ e.preventDefault()
10
+ onSubmit(email, password)
11
+ }
12
+
13
+ return (
14
+ <form className="space-y-6" onSubmit={handleSubmit}>
15
+ {error && (
16
+ <div className="rounded-md bg-red-50 p-4">
17
+ <div className="flex">
18
+ <div className="flex-shrink-0">
19
+ <svg className="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor">
20
+ <path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clipRule="evenodd" />
21
+ </svg>
22
+ </div>
23
+ <div className="ml-3">
24
+ <h3 className="text-sm font-medium text-red-800">
25
+ {error}
26
+ </h3>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ )}
31
+
32
+ <div>
33
+ <label htmlFor="email" className="block text-sm font-medium text-gray-700">
34
+ Email address
35
+ </label>
36
+ <div className="mt-1">
37
+ <input
38
+ id="email"
39
+ name="email"
40
+ type="email"
41
+ autoComplete="email"
42
+ required
43
+ value={email}
44
+ onChange={(e) => setEmail(e.target.value)}
45
+ className="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-google-blue focus:border-google-blue sm:text-sm transition-colors"
46
+ placeholder="Enter your email"
47
+ />
48
+ </div>
49
+ </div>
50
+
51
+ <div>
52
+ <label htmlFor="password" className="block text-sm font-medium text-gray-700">
53
+ Password
54
+ </label>
55
+ <div className="mt-1 relative">
56
+ <input
57
+ id="password"
58
+ name="password"
59
+ type={showPassword ? 'text' : 'password'}
60
+ autoComplete="current-password"
61
+ required
62
+ value={password}
63
+ onChange={(e) => setPassword(e.target.value)}
64
+ className="appearance-none block w-full px-3 py-2 pr-10 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-google-blue focus:border-google-blue sm:text-sm transition-colors"
65
+ placeholder="Enter your password"
66
+ />
67
+ <button
68
+ type="button"
69
+ className="absolute inset-y-0 right-0 pr-3 flex items-center"
70
+ onClick={() => setShowPassword(!showPassword)}
71
+ >
72
+ {showPassword ? (
73
+ <svg className="h-5 w-5 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
74
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />
75
+ </svg>
76
+ ) : (
77
+ <svg className="h-5 w-5 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
78
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
79
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
80
+ </svg>
81
+ )}
82
+ </button>
83
+ </div>
84
+ </div>
85
+
86
+ <div className="flex items-center justify-between">
87
+ <div className="flex items-center">
88
+ <input
89
+ id="remember-me"
90
+ name="remember-me"
91
+ type="checkbox"
92
+ className="h-4 w-4 text-google-blue focus:ring-google-blue border-gray-300 rounded"
93
+ />
94
+ <label htmlFor="remember-me" className="ml-2 block text-sm text-gray-900">
95
+ Remember me
96
+ </label>
97
+ </div>
98
+
99
+ <div className="text-sm">
100
+ <a href="#" className="font-medium text-google-blue hover:text-google-blue/80">
101
+ Forgot your password?
102
+ </a>
103
+ </div>
104
+ </div>
105
+
106
+ <div>
107
+ <button
108
+ type="submit"
109
+ disabled={isLoading}
110
+ className="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-google-blue hover:bg-google-blue/700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-google-blue disabled:opacity-50 disabled:cursor-not-allowed transition-all"
111
+ >
112
+ {isLoading ? (
113
+ <svg className="animate-spin h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
114
+ <circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
115
+ <path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
116
+ </svg>
117
+ ) : (
118
+ 'Sign in'
119
+ )}
120
+ </button>
121
+ </div>
122
+ </form>
123
+ )
124
+ }