Skip to content

Commit 7e9c05a

Browse files
committed
feat: add clear button to catalog search field
1 parent f756987 commit 7e9c05a

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/pages/CatalogPage.module.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
.search {
1818
width: 100%;
19-
padding: 9px 12px 9px 38px;
19+
padding: 9px 34px 9px 38px;
2020
background: var(--bg-card);
2121
border: 1px solid var(--border-strong);
2222
border-radius: 8px;
@@ -30,6 +30,22 @@
3030
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
3131
.search::placeholder { color: var(--text-secondary); }
3232

33+
.clearBtn {
34+
position: absolute;
35+
right: 10px;
36+
top: 50%;
37+
transform: translateY(-50%);
38+
background: none;
39+
border: none;
40+
padding: 0 2px;
41+
font-size: 16px;
42+
line-height: 1;
43+
color: var(--text-secondary);
44+
cursor: pointer;
45+
transition: color 0.1s;
46+
}
47+
.clearBtn:hover { color: var(--text-primary); }
48+
3349
/* ── Table scroll wrapper ─────────────────────────────── */
3450
.tableScroll { overflow-x: auto; }
3551
.tableScroll table { table-layout: fixed; width: 100%; }

src/pages/CatalogPage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export function CatalogPage() {
6868
onChange={e => setQuery(e.target.value)}
6969
autoComplete="off"
7070
/>
71+
{query && (
72+
<button className={styles.clearBtn} onClick={() => setQuery('')} aria-label="Clear search">×</button>
73+
)}
7174
</div>
7275
<p className="count-label">
7376
Showing <b>{filtered.length.toLocaleString()}</b> of <b>{packages.length.toLocaleString()}</b> packages

0 commit comments

Comments
 (0)