rojects/electron/login.html

210 lines
5.4 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Roject — Sign in</title>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: #0f0f0f;
color: #e8e8e8;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
user-select: none;
}
.card {
width: 340px;
padding: 2.5rem 2rem;
}
h1 {
font-size: 1.6rem;
font-weight: 600;
margin-bottom: 0.25rem;
letter-spacing: -0.02em;
}
.subtitle {
font-size: 0.85rem;
color: #666;
margin-bottom: 2rem;
}
label {
display: block;
font-size: 0.78rem;
color: #888;
margin-bottom: 0.4rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
input[type="email"],
input[type="password"] {
width: 100%;
padding: 0.65rem 0.85rem;
background: #1a1a1a;
border: 1px solid #2a2a2a;
border-radius: 6px;
color: #e8e8e8;
font-size: 0.95rem;
outline: none;
margin-bottom: 1.2rem;
transition: border-color 0.15s;
}
input[type="email"]:focus,
input[type="password"]:focus { border-color: #555; }
.remember-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1.2rem;
}
.remember-label {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.82rem;
color: #777;
cursor: pointer;
text-transform: none;
letter-spacing: 0;
margin-bottom: 0;
}
.remember-label input[type="checkbox"] {
width: 14px;
height: 14px;
margin: 0;
accent-color: #aaa;
cursor: pointer;
}
.btn-clear {
font-size: 0.78rem;
color: #555;
background: none;
border: none;
padding: 0;
cursor: pointer;
width: auto;
margin: 0;
font-weight: 400;
transition: color 0.15s;
}
.btn-clear:hover { color: #e05555; background: none; }
.btn-clear:disabled { display: none; }
button#btn {
width: 100%;
padding: 0.7rem;
background: #e8e8e8;
color: #0f0f0f;
border: none;
border-radius: 6px;
font-size: 0.95rem;
font-weight: 600;
cursor: pointer;
transition: background 0.15s;
margin-top: 0.4rem;
}
button#btn:hover { background: #fff; }
button#btn:disabled { background: #333; color: #666; cursor: default; }
.error {
font-size: 0.83rem;
color: #e05555;
margin-top: 0.9rem;
min-height: 1.2em;
text-align: center;
}
</style>
</head>
<body>
<div class="card">
<h1>Roject</h1>
<p class="subtitle">Sign in with your rokojori account</p>
<label for="email">Email</label>
<input id="email" type="email" placeholder="you@example.com" autocomplete="email">
<label for="password">Password</label>
<input id="password" type="password" placeholder="••••••••" autocomplete="current-password">
<div class="remember-row">
<label class="remember-label">
<input type="checkbox" id="remember" checked>
Remember me
</label>
<button class="btn-clear" id="btn-clear">Clear saved</button>
</div>
<button id="btn">Sign in</button>
<p class="error" id="error"></p>
</div>
<script>
const emailEl = document.getElementById( 'email' );
const passwordEl = document.getElementById( 'password' );
const rememberEl = document.getElementById( 'remember' );
const btn = document.getElementById( 'btn' );
const btnClear = document.getElementById( 'btn-clear' );
const errorEl = document.getElementById( 'error' );
async function login() {
const email = emailEl.value.trim();
const password = passwordEl.value;
if ( !email || !password ) { errorEl.textContent = 'Please enter email and password.'; return; }
btn.disabled = true;
btn.textContent = 'Signing in…';
errorEl.textContent = '';
const result = await window.electronAuth.login( email, password, rememberEl.checked );
if ( result.ok ) {
window.electronAuth.loginSuccess();
} else {
errorEl.textContent = result.error ?? 'Sign in failed.';
btn.disabled = false;
btn.textContent = 'Sign in';
}
}
btnClear.addEventListener( 'click', async () => {
await window.electronAuth.clearCredentials();
emailEl.value = '';
passwordEl.value = '';
rememberEl.checked = true;
btnClear.disabled = true;
emailEl.focus();
} );
btn.addEventListener( 'click', login );
document.addEventListener( 'keydown', ( e ) => { if ( e.key === 'Enter' ) login(); } );
Promise.all( [ window.electronAuth.lastEmail(), window.electronAuth.lastPassword() ] )
.then( ( [ email, password ] ) => {
const hasSaved = !!email;
if ( email ) emailEl.value = email;
if ( password ) passwordEl.value = password;
btnClear.disabled = !hasSaved;
if ( email && password ) btn.focus();
else if ( email ) passwordEl.focus();
else emailEl.focus();
} );
</script>
</body>
</html>