Skip to content

Commit

Permalink
Added eye password reveal
Browse files Browse the repository at this point in the history
  • Loading branch information
JezerM committed Sep 12, 2021
1 parent 1a1f1c5 commit 02a2f81
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 21 deletions.
21 changes: 21 additions & 0 deletions themes/dracula/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ input:focus-visible {
border: 0;
outline: auto var(--fg0);
}
input::-ms-reveal,
input::-ms-clear {
display: none;
}
:focus {
outline: auto var(--fg0) !important;
}
Expand All @@ -202,6 +206,23 @@ input:focus-visible {
box-sizing: border-box;
margin: 0;
}
#input {
position: relative;
}
#input #pass-eye {
position: absolute;
right: 15px;
top: 0;
bottom: 0;
margin-top: auto;
margin-bottom: auto;
height: fit-content;
background-color: var(--bg2);
}
#input #pass-eye:hover,
#input #pass-eye:focus {
background-color: var(--bg3);
}

#input-username {
box-sizing: border-box;
Expand Down
21 changes: 13 additions & 8 deletions themes/dracula/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,19 @@ <h2 id="date-label">20-05-2021</h2>
</div>

<div id="pass-wrapper">
<input
id="input-password"
name="password"
type="password"
autocomplete="off"
autofocus="true"
placeholder="Enter your password"
/>
<div id="input">
<input
id="input-password"
name="password"
type="password"
autocomplete="off"
autofocus="true"
placeholder="Enter your password"
/>
<button id="pass-eye" type="button" class="button">
<i class="mdi mdi-eye"></i>
</button>
</div>
<button id="submit-button" class="button" type="submit">
<span class="mdi mdi-chevron-right mdi-24px"></span>
</button>
Expand Down
35 changes: 22 additions & 13 deletions themes/dracula/js/authenticate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
class Authenticate {
constructor() {
this._form = document.querySelector("#login-form");
this._inputUser = document.querySelector("#input-username");
this._inputPass = document.querySelector("#input-password");
this._input_eye = document.querySelector("#pass-eye");
this._username = "";
this._password = "";
this._init();
Expand All @@ -17,14 +20,21 @@ class Authenticate {
this._respond();
});
}
_setPasswordEye() {
this._input_eye.addEventListener("click", () => {
if (this._inputPass.type === "password") {
this._inputPass.type = "text";
} else {
this._inputPass.type = "password";
}
});
}

async _respond() {
let inputUser = document.querySelector("#input-username");
let inputPass = document.querySelector("#input-password");
inputUser.blur();
inputUser.disabled = true;
inputPass.blur();
inputPass.disabled = true;
this._inputUser.blur();
this._inputUser.disabled = true;
this._inputPass.blur();
this._inputPass.disabled = true;

lightdm.cancel_authentication();
lightdm.authenticate(String(this._username));
Expand Down Expand Up @@ -89,13 +99,11 @@ class Authenticate {
topbar.classList.remove("hide");
bottombar.classList.remove("hide");

let inputUser = document.querySelector("#input-username");
let inputPass = document.querySelector("#input-password");
inputUser.blur();
inputUser.disabled = false;
inputPass.blur();
inputPass.disabled = false;
inputPass.value = "";
this._inputUser.blur();
this._inputUser.disabled = false;
this._inputPass.blur();
this._inputPass.disabled = false;
this._inputPass.value = "";

body.classList.remove("failed");
}
Expand All @@ -113,5 +121,6 @@ class Authenticate {
_init() {
this._setForm();
this._setAuthentication_done();
this._setPasswordEye();
}
}
21 changes: 21 additions & 0 deletions themes/gruvbox/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,27 @@ input:focus-visible {
border: 0;
outline: auto var(--fg);
}
#input {
position: relative;
}
#input #pass-eye {
position: absolute;
right: 15px;
top: 0;
bottom: 0;
margin-top: auto;
margin-bottom: auto;
height: fit-content;
background-color: var(--bg1);
}
#input #pass-eye:hover,
#input #pass-eye:focus {
background-color: var(--bg2);
}
input::-ms-reveal,
input::-ms-clear {
display: none;
}

:focus {
outline: auto var(--fg) !important;
Expand Down
3 changes: 3 additions & 0 deletions themes/gruvbox/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
autofocus="true"
placeholder="Enter your password"
/>
<button id="pass-eye" type="button" class="button">
<i class="mdi mdi-eye"></i>
</button>
</div>
<div>
<button id="submit-button" type="submit" class="button">
Expand Down
11 changes: 11 additions & 0 deletions themes/gruvbox/js/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Authenticate {
constructor() {
this._input = document.querySelector("#input-password");
this._form = document.querySelector("#pass-form > form");
this._input_eye = document.querySelector("#pass-eye");
this._password = "";
this._init();
}
Expand All @@ -25,6 +26,15 @@ class Authenticate {
}
};
}
_setPasswordEye() {
this._input_eye.addEventListener("click", () => {
if (this._input.type === "password") {
this._input.type = "text";
} else {
this._input.type = "password";
}
});
}

_respond() {
var input = document.querySelector("#input-password");
Expand Down Expand Up @@ -74,6 +84,7 @@ class Authenticate {
_init() {
this._setForm();
this._setAuthentication_done();
this._setPasswordEye();
console.log("Start authentication");
this.startAuthentication();
}
Expand Down

0 comments on commit 02a2f81

Please sign in to comment.