Skip to content

Commit d49308e

Browse files
📝 Updated input behavior
1 parent 5d22430 commit d49308e

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

password-input/index.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@
44
<meta charset="UTF-8" />
55
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<link
8-
rel="stylesheet"
9-
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"
10-
/>
117
<link rel="stylesheet" href="style.css" />
128
<title>Input Password</title>
139
</head>
1410
<body>
1511
<div class="input-container">
1612
<div class="input-group">
1713
<input type="password" placeholder="Enter your password" />
18-
<i class="fa-solid fa-eye-slash"></i>
14+
<span class="toggle">☠️</span>
15+
<span class="ripple"></span>
1916
</div>
2017
<div class="pass-strength">
2118
<div class="strength-percent"><span></span></div>

password-input/main.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const passInput = document.querySelector(".input-group input");
2-
const toggleIcon = document.querySelector(".input-group i");
2+
const toggleIcon = document.querySelector(".input-group .toggle");
3+
const ripple = document.querySelector(".input-group .ripple");
34
const percentBar = document.querySelector(".strength-percent span");
45
const passLabel = document.querySelector(".strength-label");
56

@@ -35,11 +36,29 @@ function togglePassInput(e) {
3536
const type = passInput.getAttribute("type");
3637
if (type === "password") {
3738
passInput.setAttribute("type", "text");
38-
toggleIcon.classList.remove("fa-eye-slash");
39-
toggleIcon.classList.add("fa-eye");
39+
toggleIcon.innerHTML = "💀";
40+
ripple.style.cssText = `
41+
border-radius: 4px;
42+
width: 100%;
43+
height: 100%;
44+
right: 0;
45+
z-index: -1;
46+
`;
47+
passInput.style.color = "#000";
48+
passInput.style.background = "transparent";
49+
toggleIcon.style.fontSize = "27px";
4050
} else {
4151
passInput.setAttribute("type", "password");
42-
toggleIcon.classList.remove("fa-eye");
43-
toggleIcon.classList.add("fa-eye-slash");
52+
toggleIcon.innerHTML = "☠️";
53+
toggleIcon.style.fontSize = "25px";
54+
ripple.style.cssText = `
55+
border-radius: 50%;
56+
height: 35px;
57+
width: 35px;
58+
right: 10px;
59+
z-index: 1;
60+
`;
61+
passInput.style.color = "#fff";
62+
passInput.style.background = "#112d37";
4463
}
4564
}

password-input/style.css

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ body {
3030
border: 1px solid #215164;
3131
border-radius: 4px;
3232
color: #fff;
33-
transition: all 0.2s;
33+
transition: width 0.9s, height 0.9s, border-radius 0.9s;
3434
font-size: 16px;
3535
}
3636

@@ -42,10 +42,25 @@ body {
4242
border: 1px solid #55b7dd;
4343
box-shadow: 0px 0px 2px 2px #55b7dd34;
4444
}
45-
.input-group i {
45+
.input-group .toggle {
4646
position: absolute;
4747
right: 10px;
48+
font-size: 25px;
4849
cursor: pointer;
50+
user-select: none;
51+
z-index: 99;
52+
}
53+
54+
.input-group .ripple {
55+
background: #fff;
56+
display: block;
57+
position: absolute;
58+
height: 35px;
59+
width: 35px;
60+
border-radius: 50%;
61+
right: 10px;
62+
transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
63+
z-index: 1;
4964
}
5065

5166
.pass-strength {

0 commit comments

Comments
 (0)