@rqdhw3n/react-auth-flow 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,7 +69,7 @@ function Header() {
69
69
 
70
70
  ## Usage Examples
71
71
 
72
- ### LoginForm Component
72
+ ### LoginForm Component with Tailwind CSS
73
73
 
74
74
  ```tsx
75
75
  import { LoginForm } from '@rqdhw3n/react-auth-flow';
@@ -79,52 +79,74 @@ function LoginPage() {
79
79
  const navigate = useNavigate();
80
80
 
81
81
  return (
82
- <LoginForm
83
- className="my-login-form"
84
- labels={{
85
- email: 'Email Address',
86
- password: 'Password',
87
- rememberMe: 'Keep me signed in',
88
- }}
89
- placeholders={{
90
- email: 'name@example.com',
91
- password: 'Enter your password',
92
- }}
93
- submitButtonText="Sign In"
94
- onSuccess={(user) => {
95
- console.log('Logged in:', user);
96
- navigate('/dashboard');
97
- }}
98
- onError={(error) => {
99
- console.error('Login failed:', error);
100
- }}
101
- />
82
+ <div className="flex min-h-screen items-center justify-center bg-slate-50 px-4 py-12">
83
+ <LoginForm
84
+ title="Welcome back"
85
+ subtitle="Sign in to your account"
86
+ className="w-full max-w-md rounded-2xl border border-slate-200 bg-white p-8 shadow-lg"
87
+ formClassName="space-y-5"
88
+ fieldClassName="space-y-2"
89
+ labelClassName="block text-sm font-medium text-slate-700"
90
+ inputClassName="w-full rounded-lg border border-slate-300 px-4 py-2 text-sm focus:border-blue-500 focus:ring-4 focus:ring-blue-100"
91
+ buttonClassName="w-full rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-semibold text-white hover:bg-blue-700"
92
+ submitButtonText="Sign In"
93
+ loadingText="Signing in..."
94
+ labels={{
95
+ email: 'Email Address',
96
+ password: 'Password',
97
+ rememberMe: 'Keep me signed in',
98
+ }}
99
+ placeholders={{
100
+ email: 'you@example.com',
101
+ password: 'Enter your password',
102
+ }}
103
+ onSuccess={() => navigate('/dashboard')}
104
+ onError={(error) => console.error(error.message)}
105
+ />
106
+ </div>
102
107
  );
103
108
  }
104
109
  ```
105
110
 
106
- ### RegisterForm Component
111
+ ### RegisterForm Component with Tailwind CSS
107
112
 
108
113
  ```tsx
109
114
  import { RegisterForm } from '@rqdhw3n/react-auth-flow';
115
+ import { useNavigate, Link } from 'react-router-dom';
110
116
 
111
117
  function SignUpPage() {
118
+ const navigate = useNavigate();
119
+
112
120
  return (
113
- <RegisterForm
114
- submitButtonText="Create Account"
115
- labels={{
116
- name: 'Full Name',
117
- email: 'Email Address',
118
- password: 'Password',
119
- confirmPassword: 'Confirm Password',
120
- }}
121
- onSuccess={() => {
122
- // Navigate to email verification or login
123
- }}
124
- onError={(error) => {
125
- alert(error.message);
126
- }}
127
- />
121
+ <div className="flex min-h-screen items-center justify-center bg-slate-50 px-4 py-12">
122
+ <div className="w-full max-w-md">
123
+ <RegisterForm
124
+ title="Create your account"
125
+ subtitle="Get started in seconds"
126
+ className="rounded-2xl border border-slate-200 bg-white p-8 shadow-lg"
127
+ formClassName="space-y-5"
128
+ fieldClassName="space-y-2"
129
+ labelClassName="block text-sm font-medium text-slate-700"
130
+ inputClassName="w-full rounded-lg border border-slate-300 px-4 py-2 text-sm focus:border-blue-500 focus:ring-4 focus:ring-blue-100"
131
+ buttonClassName="w-full rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-semibold text-white hover:bg-blue-700"
132
+ submitButtonText="Create Account"
133
+ loadingText="Creating..."
134
+ labels={{
135
+ name: 'Full Name',
136
+ email: 'Email',
137
+ password: 'Password',
138
+ confirmPassword: 'Confirm Password',
139
+ }}
140
+ onSuccess={() => navigate('/email-verify')}
141
+ />
142
+ <p className="mt-4 text-center text-sm text-slate-600">
143
+ Already have an account?{' '}
144
+ <Link to="/login" className="font-semibold text-blue-600 hover:text-blue-700">
145
+ Sign in
146
+ </Link>
147
+ </p>
148
+ </div>
149
+ </div>
128
150
  );
129
151
  }
130
152
  ```
@@ -136,15 +158,25 @@ import { ForgotPasswordForm } from '@rqdhw3n/react-auth-flow';
136
158
 
137
159
  function ForgotPasswordPage() {
138
160
  return (
139
- <ForgotPasswordForm
140
- submitButtonText="Send Recovery Email"
141
- labels={{
142
- email: 'Enter your email address',
143
- }}
144
- onSuccess={() => {
145
- alert('Recovery email sent! Check your inbox.');
146
- }}
147
- />
161
+ <div className="flex min-h-screen items-center justify-center bg-slate-50 px-4 py-12">
162
+ <ForgotPasswordForm
163
+ title="Reset your password"
164
+ subtitle="Enter your email to receive a reset link"
165
+ className="w-full max-w-md rounded-2xl border border-slate-200 bg-white p-8 shadow-lg"
166
+ formClassName="space-y-5"
167
+ fieldClassName="space-y-2"
168
+ labelClassName="block text-sm font-medium text-slate-700"
169
+ inputClassName="w-full rounded-lg border border-slate-300 px-4 py-2 text-sm focus:border-blue-500 focus:ring-4 focus:ring-blue-100"
170
+ buttonClassName="w-full rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-semibold text-white hover:bg-blue-700"
171
+ errorClassName="rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-600"
172
+ successClassName="rounded-lg border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-700"
173
+ submitButtonText="Send Reset Link"
174
+ loadingText="Sending..."
175
+ onSuccess={() => {
176
+ alert('Check your email for reset link');
177
+ }}
178
+ />
179
+ </div>
148
180
  );
149
181
  }
150
182
  ```
@@ -153,21 +185,30 @@ function ForgotPasswordPage() {
153
185
 
154
186
  ```tsx
155
187
  import { ResetPasswordForm } from '@rqdhw3n/react-auth-flow';
156
- import { useSearchParams } from 'react-router-dom';
188
+ import { useSearchParams, useNavigate } from 'react-router-dom';
157
189
 
158
190
  function ResetPasswordPage() {
159
191
  const [searchParams] = useSearchParams();
192
+ const navigate = useNavigate();
160
193
  const token = searchParams.get('token') || '';
161
194
 
162
195
  return (
163
- <ResetPasswordForm
164
- token={token}
165
- submitButtonText="Update Password"
166
- onSuccess={() => {
167
- alert('Password updated successfully!');
168
- // Navigate to login
169
- }}
170
- />
196
+ <div className="flex min-h-screen items-center justify-center bg-slate-50 px-4 py-12">
197
+ <ResetPasswordForm
198
+ token={token}
199
+ title="Create new password"
200
+ subtitle="Enter your new password below"
201
+ className="w-full max-w-md rounded-2xl border border-slate-200 bg-white p-8 shadow-lg"
202
+ formClassName="space-y-5"
203
+ fieldClassName="space-y-2"
204
+ labelClassName="block text-sm font-medium text-slate-700"
205
+ inputClassName="w-full rounded-lg border border-slate-300 px-4 py-2 text-sm focus:border-blue-500 focus:ring-4 focus:ring-blue-100"
206
+ buttonClassName="w-full rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-semibold text-white hover:bg-blue-700"
207
+ submitButtonText="Update Password"
208
+ loadingText="Updating..."
209
+ onSuccess={() => navigate('/login')}
210
+ />
211
+ </div>
171
212
  );
172
213
  }
173
214
  ```
@@ -184,17 +225,38 @@ function VerifyEmailPage() {
184
225
  const email = searchParams.get('email') || '';
185
226
 
186
227
  return (
187
- <VerifyEmailForm
188
- token={token}
189
- email={email}
190
- onSuccess={() => {
191
- alert('Email verified!');
192
- }}
193
- />
228
+ <div className="flex min-h-screen items-center justify-center bg-slate-50 px-4 py-12">
229
+ <VerifyEmailForm
230
+ token={token}
231
+ email={email}
232
+ title="Verify your email"
233
+ subtitle="Enter the code sent to your email address"
234
+ className="w-full max-w-md rounded-2xl border border-slate-200 bg-white p-8 shadow-lg"
235
+ formClassName="space-y-5"
236
+ fieldClassName="space-y-2"
237
+ labelClassName="block text-sm font-medium text-slate-700"
238
+ inputClassName="w-full rounded-lg border border-slate-300 px-4 py-2 text-sm focus:border-blue-500 focus:ring-4 focus:ring-blue-100"
239
+ buttonClassName="w-full rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-semibold text-white hover:bg-blue-700"
240
+ submitButtonText="Verify Email"
241
+ loadingText="Verifying..."
242
+ onSuccess={() => {
243
+ alert('Email verified! You can now log in.');
244
+ }}
245
+ />
246
+ </div>
194
247
  );
195
248
  }
196
249
  ```
197
250
 
251
+ ### Simple Usage Without Custom Styling
252
+
253
+ ```tsx
254
+ // Forms work with default Tailwind-friendly styling
255
+ <LoginForm
256
+ onSuccess={() => navigate('/dashboard')}
257
+ />
258
+ ```
259
+
198
260
  ### ProtectedRoute Component
199
261
 
200
262
  ```tsx