Skip to content

Commit 79aafa6

Browse files
committed
feat: day 4
1 parent 85f8d64 commit 79aafa6

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

004-hidden search widget/index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
</head>
1414
<body>
1515
<div class="search">
16-
<input type="text" class="input" placeholder="Search..." />
17-
<button class="btn"><i class="fas fa-search"></i></button>
16+
<!-- Change Placeholder Text -->
17+
<input type="text" class="input" placeholder="Type and hit enter..." />
18+
<!-- Change the Search Icon -->
19+
<button class="btn"><i class="fas fa-search-plus"></i></button>
1820
</div>
1921
<script src="script.js"></script>
2022
</body>

004-hidden search widget/script.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
const search = document.querySelector(".search");
22
const btn = document.querySelector(".btn");
33
const input = document.querySelector(".input");
4+
// Animate Button Icon Change
5+
const icon = document.querySelector(".fas");
46

57
btn.addEventListener("click", () => {
68
search.classList.toggle("active");
9+
icon.classList.toggle("fa-search-plus", !search.classList.contains("active"));
10+
icon.classList.toggle("fa-times", search.classList.contains("active"));
711
input.focus();
812
});

004-hidden search widget/style.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,17 @@ body {
4848
outline: none;
4949
}
5050

51+
/* Change Background Color on Hover */
52+
53+
.input:focus {
54+
background-color: #f0f0f0;
55+
}
56+
5157
.search.active .input {
52-
width: 200px;
58+
/* Modify Expansion Width */
59+
width: 300px;
5360
}
5461

5562
.search.active .btn {
56-
transform: translateX(198px);
63+
transform: translateX(248px);
5764
}

0 commit comments

Comments
 (0)