Skip to content

Commit 54ea8cb

Browse files
authored
Refactor search input styles and add icon (#54)
Updated styles for the search container and input elements, including padding, border, and background color changes. Added an icon to the search input for improved UI.
1 parent e84e41d commit 54ea8cb

File tree

1 file changed

+49
-23
lines changed

1 file changed

+49
-23
lines changed

homepage-search.js

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,10 @@ ready(() => {
3737
style.textContent = `
3838
.tool-search-container {
3939
margin: 1.5rem 0 2rem;
40-
padding: 1rem 1.25rem;
41-
border-radius: 0.85rem;
42-
border: 1px solid #e1e1e1;
43-
background: linear-gradient(180deg, #ffffff 0%, #f7f8ff 100%);
44-
box-shadow: 0 8px 24px rgba(23, 43, 99, 0.08);
45-
}
46-
.tool-search-container:focus-within {
47-
border-color: #5b6ef5;
48-
box-shadow: 0 12px 32px rgba(47, 64, 179, 0.15);
40+
padding: 1.15rem 1.5rem 1rem;
41+
border-radius: 0.45rem;
42+
border: 1.5px solid #d9dce6;
43+
background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
4944
}
5045
.tool-search-label {
5146
position: absolute;
@@ -59,33 +54,53 @@ ready(() => {
5954
}
6055
.tool-search-input-wrapper {
6156
position: relative;
57+
margin-bottom: 0.95rem;
58+
}
59+
.tool-search-input-icon {
60+
position: absolute;
61+
top: 50%;
62+
left: 1.1rem;
63+
transform: translateY(-50%);
64+
width: 1rem;
65+
height: 1rem;
66+
color: #4c5a85;
67+
pointer-events: none;
68+
}
69+
.tool-search-input-icon svg {
70+
display: block;
71+
width: 100%;
72+
height: 100%;
6273
}
6374
#tool-search-input {
6475
width: 100%;
6576
box-sizing: border-box;
66-
border-radius: 0.75rem;
67-
border: 1px solid #cfd2ff;
68-
background-color: rgba(255, 255, 255, 0.9);
69-
padding: 0.75rem 1rem;
77+
border-radius: 0.7rem;
78+
border: 1.5px solid #94a3d4;
79+
background-color: rgba(255, 255, 255, 0.95);
80+
padding: 0.75rem 1rem 0.75rem 2.75rem;
7081
font-size: 1rem;
7182
line-height: 1.5;
7283
transition: border-color 0.2s ease, box-shadow 0.2s ease;
7384
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
7485
}
86+
#tool-search-input::placeholder {
87+
color: #4f5c83;
88+
}
7589
#tool-search-input:focus {
7690
outline: none;
77-
border-color: #4454f7;
78-
box-shadow: 0 0 0 3px rgba(68, 84, 247, 0.2);
91+
border-color: #3b4fd4;
92+
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
7993
background-color: #fff;
8094
}
8195
#tool-search-input:disabled {
8296
color: #6b6f80;
8397
background-color: rgba(250, 250, 255, 0.8);
8498
}
8599
.tool-search-hint {
86-
margin: 0.5rem 0 0;
100+
margin: 0 0 0;
87101
font-size: 0.875rem;
88-
color: #4a4f67;
102+
color: #6f7796;
103+
max-width: 32rem;
89104
}
90105
.tool-search-results {
91106
list-style: none;
@@ -96,14 +111,13 @@ ready(() => {
96111
gap: 0.5rem;
97112
}
98113
.tool-search-option {
99-
border-radius: 0.75rem;
100-
border: 1px solid #d8dcff;
114+
border-radius: 0.7rem;
115+
border: 1.5px solid #d8dcff;
101116
background: #ffffff;
102117
transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
103118
}
104119
.tool-search-option.active {
105120
border-color: #4454f7;
106-
box-shadow: 0 6px 18px rgba(68, 84, 247, 0.18);
107121
transform: translateY(-1px);
108122
}
109123
.tool-search-option-link {
@@ -133,8 +147,8 @@ ready(() => {
133147
}
134148
.tool-search-empty {
135149
padding: 0.9rem 1rem;
136-
border-radius: 0.75rem;
137-
border: 1px dashed #c4c8ff;
150+
border-radius: 0.7rem;
151+
border: 1.5px dashed #c4c8ff;
138152
background: rgba(228, 232, 255, 0.5);
139153
font-size: 0.95rem;
140154
color: #3e4261;
@@ -177,6 +191,16 @@ ready(() => {
177191
const inputWrapper = document.createElement('div');
178192
inputWrapper.className = 'tool-search-input-wrapper';
179193

194+
const icon = document.createElement('span');
195+
icon.className = 'tool-search-input-icon';
196+
icon.setAttribute('aria-hidden', 'true');
197+
icon.innerHTML = `
198+
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
199+
<circle cx="9" cy="9" r="5.5" stroke="currentColor" stroke-width="1.5" fill="none" />
200+
<line x1="13.35" y1="13.35" x2="17" y2="17" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
201+
</svg>
202+
`;
203+
180204
const input = document.createElement('input');
181205
input.type = 'search';
182206
input.id = 'tool-search-input';
@@ -189,6 +213,9 @@ ready(() => {
189213
input.setAttribute('role', 'combobox');
190214
input.disabled = true;
191215

216+
inputWrapper.appendChild(icon);
217+
inputWrapper.appendChild(input);
218+
192219
const hint = document.createElement('p');
193220
hint.className = 'tool-search-hint';
194221
hint.textContent = 'Start typing to search all tools. Press “/” to focus the search.';
@@ -205,7 +232,6 @@ ready(() => {
205232
status.setAttribute('role', 'status');
206233
status.setAttribute('aria-live', 'polite');
207234

208-
inputWrapper.appendChild(input);
209235
container.appendChild(label);
210236
container.appendChild(inputWrapper);
211237
container.appendChild(hint);

0 commit comments

Comments
 (0)