Repository navigation
Expand file tree
/
Copy pathocodejs-auth.html
More file actions
170 lines (163 loc) · 9.84 KB
/
Copy pathocodejs-auth.html
File metadata and controls
170 lines (163 loc) · 9.84 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>OCodeJS — Auth</title>
<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=JetBrains+Mono:wght@400;500;700&display=swap" rel="stylesheet">
<style>
:root{
--bg:#000; --fg:#f5f5f5; --muted:#8a8a8a; --line:#262626; --field:#0a0a0a; --hover:#141414;
--btn:#f5f5f5; --btn-fg:#000;
--mono:'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
color-scheme:dark;
box-sizing:border-box;
padding-top:env(safe-area-inset-top,0px);
padding-bottom:env(safe-area-inset-bottom,0px);
}
html{scroll-padding-top:env(safe-area-inset-top,0px)}
*,*::before,*::after{box-sizing:border-box;border-radius:0!important}
html,body{margin:0;min-height:100%;background:var(--bg);color:var(--fg);font-family:var(--mono);font-size:14px}
body{display:flex;justify-content:center}
.wrap{width:100%;max-width:420px;padding:24px 20px 40px}
.back{display:inline-flex;gap:8px;align-items:center;color:var(--muted);text-decoration:none;font-size:13px}
.back:hover{color:var(--fg)}
.logo{display:flex;flex-direction:column;align-items:center;margin:40px 0 28px;gap:14px}
.mark{width:56px;height:56px;border:1px solid var(--line);display:grid;place-items:center;background:var(--bg)}
.brand{font-weight:700;letter-spacing:.02em;font-size:15px}
h1{font-size:22px;font-weight:700;text-align:center;margin:0 0 10px;letter-spacing:-.01em}
.sub{text-align:center;color:var(--muted);margin:0 0 28px;font-size:13px}
.sub a{color:var(--fg);font-weight:700;text-decoration:none;border-bottom:1px solid var(--fg)}
.oauth{display:flex;align-items:center;justify-content:center;gap:12px;width:100%;height:46px;margin-bottom:12px;
background:var(--bg);color:var(--fg);border:1px solid var(--line);font:inherit;font-weight:500;cursor:pointer}
.oauth:hover{background:var(--hover);border-color:#3a3a3a}
.or{display:flex;align-items:center;gap:14px;color:var(--muted);margin:22px 0}
.or::before,.or::after{content:"";flex:1;height:1px;background:var(--line)}
label{display:block;color:var(--muted);margin:0 0 8px;font-size:12px;text-transform:uppercase;letter-spacing:.08em}
.field{margin-bottom:18px;position:relative}
input[type=email],input[type=password],input[type=text]{width:100%;height:46px;padding:0 14px;background:var(--field);
color:var(--fg);border:1px solid var(--line);font:inherit;outline:none}
input::placeholder{color:#555}
input:focus{border-color:var(--fg)}
.eye{position:absolute;right:1px;bottom:1px;width:44px;height:44px;background:none;border:0;color:var(--muted);cursor:pointer;display:grid;place-items:center}
.eye:hover{color:var(--fg)}
.check{display:flex;gap:12px;align-items:flex-start;color:var(--muted);margin:2px 0 22px;font-size:13px;line-height:1.5;cursor:pointer}
.check input{appearance:none;flex:none;width:18px;height:18px;margin:1px 0 0;border:1px solid #3a3a3a;background:var(--field);cursor:pointer;display:grid;place-items:center}
.check input:checked{background:var(--fg);border-color:var(--fg)}
.check input:checked::after{content:"";width:8px;height:4px;border-left:2px solid #000;border-bottom:2px solid #000;transform:rotate(-45deg) translate(1px,-1px)}
.submit{width:100%;height:46px;background:var(--btn);color:var(--btn-fg);border:1px solid var(--btn);font:inherit;font-weight:700;cursor:pointer}
.submit:disabled{background:var(--field);color:#555;border-color:var(--line);cursor:not-allowed}
.submit:not(:disabled):hover{background:#fff}
.legal{text-align:center;color:var(--muted);font-size:12px;line-height:1.7;margin-top:28px}
.legal a{color:var(--muted);text-decoration:underline}
.legal a:hover{color:var(--fg)}
.msg{margin-top:16px;text-align:center;color:var(--muted);font-size:12px;min-height:16px}
[hidden]{display:none!important}
</style>
</head>
<body>
<main class="wrap">
<a class="back" href="#"><span>‹</span> Home</a>
<div class="logo">
<div class="mark" aria-hidden="true">
<svg width="34" height="34" viewBox="0 0 34 34" fill="none" stroke="#f5f5f5" stroke-width="2.5" stroke-linecap="square">
<rect x="6" y="6" width="22" height="22"/>
<path d="M13 13h8M13 17h8M13 21h4"/>
</svg>
</div>
<div class="brand">OCodeJS</div>
</div>
<!-- LOGIN -->
<section id="login">
<h1>Log in to OCodeJS</h1>
<p class="sub">Don’t have an account? <a href="#signup">Sign up</a>.</p>
<button class="oauth" type="button" data-p="Google">
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M21.35 11.1H12v2.98h5.35c-.5 2.4-2.5 3.5-5.35 3.5a5.6 5.6 0 1 1 0-11.2c1.4 0 2.6.5 3.55 1.35l2.1-2.1A8.6 8.6 0 0 0 12 3.4a8.6 8.6 0 1 0 0 17.2c4.95 0 8.6-3.5 8.6-8.4 0-.4-.05-.75-.1-1.1z"/></svg>
Log in with Google
</button>
<button class="oauth" type="button" data-p="GitHub">
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M12 .5a11.5 11.5 0 0 0-3.64 22.41c.58.1.79-.25.79-.56v-2c-3.2.7-3.88-1.38-3.88-1.38-.52-1.33-1.28-1.69-1.28-1.69-1.04-.71.08-.7.08-.7 1.16.08 1.77 1.19 1.77 1.19 1.03 1.76 2.7 1.25 3.36.96.1-.75.4-1.25.73-1.54-2.55-.29-5.24-1.28-5.24-5.69 0-1.26.45-2.29 1.19-3.1-.12-.29-.52-1.46.11-3.05 0 0 .97-.31 3.18 1.18a11 11 0 0 1 5.78 0c2.2-1.49 3.17-1.18 3.17-1.18.63 1.59.23 2.76.11 3.05.74.81 1.19 1.84 1.19 3.1 0 4.42-2.69 5.4-5.26 5.68.41.36.78 1.06.78 2.14v3.17c0 .31.21.67.8.56A11.5 11.5 0 0 0 12 .5z"/></svg>
Log in with GitHub
</button>
<div class="or">or</div>
<form id="f-login" novalidate>
<div class="field">
<label for="l-email">Email</label>
<input id="l-email" type="email" placeholder="alan.turing@example.com" autocomplete="email">
</div>
<button class="submit" type="submit" disabled>Log In</button>
</form>
<p class="legal">By signing in, you agree to our <a href="#">Terms</a> and <a href="#">Privacy Policy</a>.</p>
</section>
<!-- SIGNUP -->
<section id="signup" hidden>
<h1>Create an OCodeJS account</h1>
<p class="sub">Already have an account? <a href="#login">Log in</a>.</p>
<button class="oauth" type="button" data-p="Google">
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M21.35 11.1H12v2.98h5.35c-.5 2.4-2.5 3.5-5.35 3.5a5.6 5.6 0 1 1 0-11.2c1.4 0 2.6.5 3.55 1.35l2.1-2.1A8.6 8.6 0 0 0 12 3.4a8.6 8.6 0 1 0 0 17.2c4.95 0 8.6-3.5 8.6-8.4 0-.4-.05-.75-.1-1.1z"/></svg>
Sign up with Google
</button>
<button class="oauth" type="button" data-p="GitHub">
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M12 .5a11.5 11.5 0 0 0-3.64 22.41c.58.1.79-.25.79-.56v-2c-3.2.7-3.88-1.38-3.88-1.38-.52-1.33-1.28-1.69-1.28-1.69-1.04-.71.08-.7.08-.7 1.16.08 1.77 1.19 1.77 1.19 1.03 1.76 2.7 1.25 3.36.96.1-.75.4-1.25.73-1.54-2.55-.29-5.24-1.28-5.24-5.69 0-1.26.45-2.29 1.19-3.1-.12-.29-.52-1.46.11-3.05 0 0 .97-.31 3.18 1.18a11 11 0 0 1 5.78 0c2.2-1.49 3.17-1.18 3.17-1.18.63 1.59.23 2.76.11 3.05.74.81 1.19 1.84 1.19 3.1 0 4.42-2.69 5.4-5.26 5.68.41.36.78 1.06.78 2.14v3.17c0 .31.21.67.8.56A11.5 11.5 0 0 0 12 .5z"/></svg>
Sign up with GitHub
</button>
<div class="or">or</div>
<form id="f-signup" novalidate>
<div class="field">
<label for="s-email">Email</label>
<input id="s-email" type="email" placeholder="alan.turing@example.com" autocomplete="email">
</div>
<div class="field">
<label for="s-pass">Password</label>
<input id="s-pass" type="password" placeholder="Min. 8 characters" autocomplete="new-password">
<button class="eye" type="button" aria-label="Show password" id="eye">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M1.5 12S5.5 5 12 5s10.5 7 10.5 7-4 7-10.5 7S1.5 12 1.5 12z"/><circle cx="12" cy="12" r="3"/></svg>
</button>
</div>
<label class="check"><input type="checkbox"><span>Send me occasional updates, guides, and promotions.</span></label>
<button class="submit" type="submit" disabled>Create account</button>
</form>
<p class="legal">By signing up, you agree to our <a href="#">Terms</a>, <a href="#">Acceptable Use</a>, and <a href="#">Privacy Policy</a>.</p>
</section>
<div class="msg" id="msg" role="status"></div>
</main>
<script>
(function(){
var views=['login','signup'];
function route(){
var h=(location.hash||'#login').slice(1);
if(views.indexOf(h)<0) h='login';
views.forEach(function(v){document.getElementById(v).hidden=(v!==h)});
document.title=(h==='login'?'Log in':'Sign up')+' — OCodeJS';
document.getElementById('msg').textContent='';
}
window.addEventListener('hashchange',route); route();
var emailRe=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;
function bind(formId,check){
var f=document.getElementById(formId), btn=f.querySelector('.submit');
function upd(){btn.disabled=!check(f)}
f.addEventListener('input',upd); upd();
f.addEventListener('submit',function(e){
e.preventDefault(); if(btn.disabled) return;
document.getElementById('msg').textContent='> demo only — connect your auth backend here.';
});
}
bind('f-login',function(f){return emailRe.test(f.querySelector('input[type=email]').value.trim())});
bind('f-signup',function(f){
return emailRe.test(f.querySelector('input[type=email]').value.trim()) && f.querySelector('#s-pass').value.length>=8;
});
document.getElementById('eye').addEventListener('click',function(){
var i=document.getElementById('s-pass');
i.type=i.type==='password'?'text':'password';
});
Array.prototype.forEach.call(document.querySelectorAll('.oauth'),function(b){
b.addEventListener('click',function(){
document.getElementById('msg').textContent='> '+b.getAttribute('data-p')+' OAuth — demo only.';
});
});
})();
</script>
</body>
</html>