-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
347 lines (297 loc) · 16.1 KB
/
index.html
File metadata and controls
347 lines (297 loc) · 16.1 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
<!-- <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="auth-system authentication homepage for modern apps.">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="./frontend/css/style.css">
<title>auth-system</title>
<style>
</style>
</head>
<body>
<main class="page-shell">
<div class="auth-layout">
<section class="brand-panel">
<div>
<div class="brand-badge">Developer Portfolio</div>
<p class="brand-name">auth-system</p>
<h1>Secure authentication for modern apps.</h1>
<p class="brand-copy">
A focused dark-mode auth experience with clean validation, loading states, and a polished SaaS feel.
</p>
<div class="signal-grid" aria-label="Product highlights">
<article class="signal-card">
<span class="signal-label">Security</span>
<strong>Session ready</strong>
<p>Designed for real login flows, protected routes, and API-backed auth.</p>
</article>
<article class="signal-card">
<span class="signal-label">UX</span>
<strong>Inline validation</strong>
<p>Every field has clear error and success feedback with smooth transitions.</p>
</article>
<article class="signal-card">
<span class="signal-label">Design</span>
<strong>Dark SaaS aesthetic</strong>
<p>Glass surfaces, subtle glow, and compact layout without empty hero space.</p>
</article>
</div>
<div class="chip-row" aria-hidden="true">
<span class="chip">POST /api/login</span>
<span class="chip">remember_me=true</span>
<span class="chip">loading-state</span>
</div>
</div>
<div class="page-links">
<a class="page-link" href="./frontend/pages/login.html">Open old login page</a>
<a class="page-link" href="./frontend/pages/signup.html">Open old signup page</a>
</div>
</section>
<section class="auth-card" aria-labelledby="auth-title">
<div class="auth-header">
<div>
<p class="eyebrow">Authentication</p>
<h2 id="auth-title">Access your workspace</h2>
</div>
<div class="auth-tabs" role="tablist" aria-label="Authentication forms">
<button class="auth-tab is-active" type="button" role="tab" aria-selected="true"
data-target="login-panel">
Log in
</button>
<button class="auth-tab" type="button" role="tab" aria-selected="false"
data-target="signup-panel">
Sign up
</button>
</div>
</div>
<form class="auth-form is-active" id="login-panel" novalidate>
<div class="form-intro">
<h3>Welcome back</h3>
<p>Use your email and password to continue.</p>
</div>
<div class="form-field" data-field>
<label for="login-email">Email</label>
<input id="login-email" type="email" name="email" placeholder="you@company.com" autocomplete="email">
<span class="field-message" aria-live="polite"></span>
</div>
<div class="form-field" data-field>
<div class="form-topline">
<label for="login-password">Password</label>
<a href="#" class="text-link" id="forgot-link">Forgot password?</a>
</div>
<input id="login-password" type="password" name="password" placeholder="Enter your password"
autocomplete="current-password">
<span class="field-message" aria-live="polite"></span>
</div>
<div class="form-row form-row-between">
<label class="checkbox-row" for="remember-me">
<input id="remember-me" type="checkbox" name="remember">
<span>Remember me</span>
</label>
<span class="micro-copy">Secure session storage</span>
</div>
<p class="form-status" aria-live="polite"></p>
<button class="submit-button" type="submit">
<span class="submit-label">Log in</span><span class="submit-loader" aria-hidden="true"></span>
</button>
<p class="form-switch-copy">
New to auth-system?
<button class="text-button" type="button" data-switch-to="signup-panel">Create an account</button>
</p>
</form>
<form class="auth-form" id="signup-panel" novalidate hidden>
<div class="form-intro">
<h3>Create your account</h3>
<p>Set up a secure workspace in under a minute.</p>
</div>
<div class="form-field" data-field>
<label for="signup-name">Full name</label>
<input id="signup-name" type="text" name="name" placeholder="Jane Developer" autocomplete="name">
<span class="field-message" aria-live="polite"></span>
</div>
<div class="form-field" data-field>
<label for="signup-email">Email</label>
<input id="signup-email" type="email" name="email" placeholder="you@company.com" autocomplete="email">
<span class="field-message" aria-live="polite"></span>
</div>
<div class="form-field" data-field>
<label for="signup-password">Password</label>
<input id="signup-password" type="password" name="password" placeholder="At least 8 characters"
autocomplete="new-password">
<span class="field-message" aria-live="polite"></span>
</div>
<div class="form-field" data-field>
<label for="signup-confirm-password">Confirm password</label>
<input id="signup-confirm-password" type="password" name="confirmPassword"
placeholder="Repeat your password" autocomplete="new-password">
<span class="field-message" aria-live="polite"></span>
</div>
<div class="form-row">
<label class="checkbox-row" for="terms-check">
<input id="terms-check" type="checkbox" name="terms">
<span>I agree to the terms and privacy policy</span>
</label>
</div>
<p class="form-status" aria-live="polite"></p>
<button class="submit-button" type="submit">
<span class="submit-label">Create account</span><span class="submit-loader" aria-hidden="true"></span>
</button>
<p class="form-switch-copy">
Already have an account?
<button class="text-button" type="button" data-switch-to="login-panel">Back to login</button>
</p>
</form>
</section>
</div>
</main>
<script>
const tabButtons = document.querySelectorAll(".auth-tab");
const forms = document.querySelectorAll(".auth-form");
const switchButtons = document.querySelectorAll("[data-switch-to]");
const forgotPasswordLink = document.getElementById("forgot-link");
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
const fieldRules = {
"login-email": (value) => {
if (!value.trim()) return { state: "invalid", message: "Email is required." };
if (!emailPattern.test(value.trim())) return { state: "invalid", message: "Enter a valid email address." };
return { state: "valid", message: "Email looks good." };
},
"login-password": (value) => {
if (!value.trim()) return { state: "invalid", message: "Password is required." };
if (value.trim().length < 8) return { state: "invalid", message: "Password must be at least 8 characters." };
return { state: "valid", message: "Password format is valid." };
},
"signup-name": (value) => {
if (!value.trim()) return { state: "invalid", message: "Full name is required." };
if (value.trim().length < 3) return { state: "invalid", message: "Use at least 3 characters." };
return { state: "valid", message: "Name looks good." };
},
"signup-email": (value) => {
if (!value.trim()) return { state: "invalid", message: "Email is required." };
if (!emailPattern.test(value.trim())) return { state: "invalid", message: "Enter a valid email address." };
return { state: "valid", message: "Email looks good." };
},
"signup-password": (value) => {
if (!value.trim()) return { state: "invalid", message: "Password is required." };
if (value.trim().length < 8) return { state: "invalid", message: "Use at least 8 characters." };
return { state: "valid", message: "Strong enough for a demo account." };
},
"signup-confirm-password": (value, input) => {
const passwordInput = input.form.querySelector("#signup-password");
if (!value.trim()) return { state: "invalid", message: "Please confirm your password." };
if (value !== passwordInput.value) return { state: "invalid", message: "Passwords do not match." };
return { state: "valid", message: "Passwords match." };
}
};
const setActivePanel = (targetId) => {
tabButtons.forEach((button) => {
const isActive = button.dataset.target === targetId;
button.classList.toggle("is-active", isActive);
button.setAttribute("aria-selected", String(isActive));
});
forms.forEach((form) => {
const isActive = form.id === targetId;
form.classList.toggle("is-active", isActive);
form.hidden = !isActive;
});
};
const setFieldState = (input, result) => {
const field = input.closest("[data-field]");
const message = field.querySelector(".field-message");
field.classList.remove("is-valid", "is-invalid");
field.classList.add(result.state === "valid" ? "is-valid" : "is-invalid");
message.textContent = result.message;
};
const validateInput = (input) => {
const validator = fieldRules[input.id];
if (!validator) return true;
const result = validator(input.value, input);
setFieldState(input, result);
return result.state === "valid";
};
const clearStatus = (form) => {
const status = form.querySelector(".form-status");
status.className = "form-status";
status.textContent = "";
};
const setLoadingState = (form, isLoading) => {
const button = form.querySelector(".submit-button");
button.classList.toggle("is-loading", isLoading);
button.disabled = isLoading;
};
const validateTerms = (form) => {
const termsInput = form.querySelector("#terms-check");
const status = form.querySelector(".form-status");
if (!termsInput) return true;
if (!termsInput.checked) {
status.className = "form-status is-error";
status.textContent = "Accept the terms to create your account.";
return false;
}
return true;
};
const handleSubmit = async (event) => {
event.preventDefault();
const form = event.currentTarget;
const status = form.querySelector(".form-status");
const inputs = Array.from(form.querySelectorAll("input:not([type='checkbox'])"));
const valid = inputs.map(validateInput).every(Boolean) && validateTerms(form);
if (!valid) {
if (!status.textContent) {
status.className = "form-status is-error";
status.textContent = "Fix the highlighted fields before continuing.";
}
return;
}
clearStatus(form);
setLoadingState(form, true);
await new Promise((resolve) => window.setTimeout(resolve, 1200));
setLoadingState(form, false);
status.className = "form-status is-success";
status.textContent = form.id === "login-panel"
? "Login successful. Connect this form to your auth API next."
: "Account created. You can now switch back and log in.";
if (form.id === "signup-panel") {
window.setTimeout(() => setActivePanel("login-panel"), 900);
}
};
tabButtons.forEach((button) => {
button.addEventListener("click", () => setActivePanel(button.dataset.target));
});
switchButtons.forEach((button) => {
button.addEventListener("click", () => setActivePanel(button.dataset.switchTo));
});
Object.keys(fieldRules).forEach((id) => {
const input = document.getElementById(id);
if (!input) return;
input.addEventListener("blur", () => validateInput(input));
input.addEventListener("input", () => {
const field = input.closest("[data-field]");
if (field.classList.contains("is-invalid")) validateInput(input);
if (input.id === "signup-password") {
const confirmInput = document.getElementById("signup-confirm-password");
if (confirmInput.value) validateInput(confirmInput);
}
});
});
forgotPasswordLink.addEventListener("click", (event) => {
event.preventDefault();
const loginStatus = document.querySelector("#login-panel .form-status");
loginStatus.className = "form-status";
loginStatus.textContent = "Hook this link into your password reset flow or recovery API.";
});
document.getElementById("terms-check").addEventListener("change", () => {
const signupForm = document.getElementById("signup-panel");
const status = signupForm.querySelector(".form-status");
if (status.classList.contains("is-error")) clearStatus(signupForm);
});
forms.forEach((form) => {
form.addEventListener("submit", handleSubmit);
});
</script>
</body>
</html> -->