www_projectmycelium_io/poc_project_mycelium/login2222.html

284 lines
8.5 KiB
HTML
Raw Normal View History

2024-11-08 15:31:50 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Project Mycelium</title>
2024-11-08 15:31:50 +00:00
<link rel="stylesheet" href="components/nav.html">
</head>
<body>
<div class="login-container">
<div class="login-box">
<div class="login-header">
<svg class="logo" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/>
</svg>
<h1>Welcome Back</h1>
<p>Sign in to your Project Mycelium account</p>
2024-11-08 15:31:50 +00:00
</div>
<form id="loginForm" onsubmit="return validateForm(event)">
<div class="form-group">
<label for="email">Email</label>
<input
type="email"
id="email"
name="email"
required
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$"
placeholder="Enter your email"
autocomplete="email"
>
<span class="error-message" id="emailError"></span>
</div>
<div class="form-group">
<label for="password">Password</label>
<input
type="password"
id="password"
name="password"
required
minlength="8"
placeholder="Enter your password"
autocomplete="current-password"
>
<span class="error-message" id="passwordError"></span>
</div>
<div class="form-footer">
<label class="remember-me">
<input type="checkbox" name="remember"> Remember me
</label>
<a href="#" class="forgot-password">Forgot Password?</a>
</div>
<button type="submit" class="login-button">Sign In</button>
</form>
<div class="signup-link">
Don't have an account? <a href="#">Sign up</a>
</div>
</div>
</div>
<style>
:root {
--primary-color: #1a73e8;
--error-color: #dc3545;
--text-color: #333;
--border-color: #ddd;
--background-color: #f5f5f5;
--box-shadow: 0 2px 10px #0000001A;
}
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: var(--background-color);
color: var(--text-color);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.login-container {
width: 100%;
max-width: 400px;
padding: 10px;
}
.login-box {
background: white;
border-radius: 8px;
box-shadow: var(--box-shadow);
padding: 2rem;
}
.login-header {
text-align: center;
margin-bottom: 1.5rem;
}
.logo {
width: 48px;
height: 48px;
margin-bottom: 1rem;
color: var(--primary-color);
}
.login-header h1 {
margin: 0;
font-size: 1.75rem;
color: var(--text-color);
}
.login-header p {
margin: 0.5rem 0 0;
color: #666;
font-size: 0.95rem;
}
.form-group {
margin-bottom: 0.5rem; /* Reduced from 1rem */
}
label {
display: block;
margin-bottom: 0.5rem;
color: var(--text-color);
font-size: 0.9rem;
font-weight: 500;
}
input[type="email"],
input[type="password"] {
width: 100%;
padding: 0.75rem;
border: 1px solid var(--border-color);
border-radius: 4px;
font-size: 1rem;
transition: border-color 0.3s, box-shadow 0.3s;
box-sizing: border-box;
}
input[type="email"]:focus,
input[type="password"]:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 2px #1A73E833;
}
.error-message {
display: block;
color: var(--error-color);
font-size: 0.85rem;
margin-top: 0.25rem;
min-height: 1.25em;
}
.form-footer {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.5rem; /* Reduced from 1rem */
}
.remember-me {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.9rem;
color: #666;
}
.forgot-password {
font-size: 0.9rem;
color: var(--primary-color);
text-decoration: none;
}
.forgot-password:hover {
text-decoration: underline;
}
.login-button {
width: 100%;
padding: 0.75rem;
background: var(--primary-color);
color: white;
border: none;
border-radius: 4px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
transition: background-color 0.3s, transform 0.3s;
}
.login-button:hover {
background: #1557b0;
transform: translateY(-1px);
}
.login-button:active {
transform: translateY(0);
}
.signup-link {
text-align: center;
margin-top: 1rem;
font-size: 0.9rem;
color: #666;
}
.signup-link a {
color: var(--primary-color);
text-decoration: none;
font-weight: 500;
}
.signup-link a:hover {
text-decoration: underline;
}
@media (max-width: 480px) {
.login-container {
padding: 10px;
}
.login-box {
padding: 1.5rem;
}
}
</style>
<script>
function validateForm(event) {
event.preventDefault();
const email = document.getElementById('email');
const emailError = document.getElementById('emailError');
const password = document.getElementById('password');
const passwordError = document.getElementById('passwordError');
// Reset error messages
emailError.textContent = '';
passwordError.textContent = '';
let isValid = true;
// Email validation
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
if (!emailRegex.test(email.value)) {
emailError.textContent = 'Please enter a valid email address';
isValid = false;
}
// Password validation
if (password.value.length < 8) {
passwordError.textContent = 'Password must be at least 8 characters long';
isValid = false;
}
if (isValid) {
// Here you would typically send the form data to your server
console.log('Form is valid, ready to submit');
// For demo purposes, we'll just log the email
console.log('Email:', email.value);
}
return isValid;
}
// Real-time email validation
document.getElementById('email').addEventListener('input', function(e) {
const emailError = document.getElementById('emailError');
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
if (this.value && !emailRegex.test(this.value)) {
emailError.textContent = 'Please enter a valid email address';
} else {
emailError.textContent = '';
}
});
</script>
</body>
</html>