Skip to content

Commit fc6c008

Browse files
committed
add better styling to form inputs and buttons
1 parent 838f713 commit fc6c008

4 files changed

Lines changed: 37 additions & 10 deletions

File tree

public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
<form action="POST" id="login-form" spellcheck="false" autocomplete="off" autocapitalize="off" style="display: none;">
2424
<input type="text" name="login" id="login" placeholder="Enter your login" maxlength="32" />
2525
<input type="password" name="password" id="password" placeholder="Enter your password" maxlength="128" />
26-
<button type="submit" id="login-button">Login</button>
26+
<button type="submit" id="login-button" disabled>Login</button>
2727
</form>
2828

2929
<!-- Lock screen form (used when one or more sessions are active) -->
3030
<form action="POST" id="lock-form" spellcheck="false" autocomplete="off" autocapitalize="off" style="display: none;">
3131
<h3 id="active-user-session-display-name">John Doe</h3>
3232
<h4 id="active-user-session-login-name">jdoe</h4>
3333
<input type="password" name="active-user-session-password" id="active-user-session-password" placeholder="Enter your password" maxlength="128" />
34-
<button type="submit" id="unlock-button">Unlock</button>
34+
<button type="submit" id="unlock-button" disabled>Unlock</button>
3535
</form>
3636
</main>
3737

public/styles.css

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,20 @@ form input {
163163
text-align: left;
164164
text-shadow: var(--text-shadow);
165165
user-select: text !important;
166+
cursor: text;
166167
}
167168

168169
form input:focus {
169170
outline: none;
170171
border-color: var(--color-primary);
171172
}
172173

174+
form input:disabled {
175+
cursor: not-allowed;
176+
color: var(--color-text-tertiary);
177+
cursor: default;
178+
}
179+
173180
form input::placeholder {
174181
color: var(--color-text-tertiary);
175182
}
@@ -188,14 +195,21 @@ form button {
188195
border-radius: var(--border-radius);
189196
background: var(--color-primary);
190197
padding: var(--padding) calc(var(--padding) * 2);
198+
color: var(--color-text-primary);
199+
cursor: pointer;
191200
}
192201

193-
form button:hover,
194-
form button:focus {
202+
form button:not(:disabled):hover,
203+
form button:not(:disabled):focus {
195204
cursor: pointer;
196205
outline: none;
197206
}
198207

208+
form button:disabled {
209+
cursor: default;
210+
color: rgba(16, 16, 16, 0.3);
211+
}
212+
199213
form button::after,
200214
form button::after {
201215
content: '';
@@ -207,20 +221,20 @@ form button::after {
207221
position: absolute;
208222
top: -1px;
209223
left: -1px;
224+
pointer-events: none;
210225
}
211226

212-
form button:hover::after,
213-
form button:focus::after {
214-
pointer-events: none;
227+
form button:not(:disabled):hover::after,
228+
form button:not(:disabled):focus::after {
215229
background-color: var(--bg-color-lighten);
216230
}
217231

218-
form button:active {
232+
form button:not(:disabled):active {
219233
border-style: inset;
220234
}
221235

222-
form button:active::after {
223-
pointer-events: none;
236+
form button:active::after,
237+
form button:disabled::after {
224238
background-color: var(--bg-color-darken);
225239
}
226240

scripts/ui/lockscreen.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ export class LockScreenUI extends UIScreen {
5151
this._auth.login(this._activeSession.username, form.passwordInput.value);
5252
});
5353

54+
// Only enable the login button when both the login and password fields are filled in
55+
form.passwordInput.addEventListener('input', () => {
56+
form.unlockButton.disabled = form.passwordInput.value === "";
57+
});
58+
5459
// Display the lock screen form
5560
form.lockForm.style.display = "block";
5661
form.passwordInput.focus();

scripts/ui/loginscreen.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ export class LoginScreenUI extends UIScreen {
4343
this._auth.login(form.loginInput.value, form.passwordInput.value);
4444
});
4545

46+
// Only enable the login button when both the login and password fields are filled in
47+
form.loginInput.addEventListener('input', () => {
48+
form.loginButton.disabled = form.loginInput.value.trim() === "" || form.passwordInput.value === "";
49+
});
50+
form.passwordInput.addEventListener('input', () => {
51+
form.loginButton.disabled = form.loginInput.value.trim() === "" || form.passwordInput.value === "";
52+
});
53+
4654
// Display the login form
4755
form.loginForm.style.display = "block";
4856
form.loginInput.focus();

0 commit comments

Comments
 (0)