From 88c238f249749604da5a5bce738e5c38ca32cee0 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 28 Aug 2026 05:58:43 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Add=20clear=20search?= =?UTF-8?q?=20button=20micro-UX=20to=20Examples=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: MilakyS <155958485+MilakyS@users.noreply.github.com> --- assets/css/examples.css | 37 ++++++++++++++++++++++++++++++++++++- assets/js/examples.js | 12 ++++++++++++ examples.html | 5 ++++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/assets/css/examples.css b/assets/css/examples.css index 902f983..e39dc61 100644 --- a/assets/css/examples.css +++ b/assets/css/examples.css @@ -86,10 +86,17 @@ main { } } +.search-input-wrapper { + position: relative; + display: flex; + align-items: center; + width: 100%; +} + .examples-search { width: 100%; min-height: 42px; - padding: 9px 12px; + padding: 9px 34px 9px 12px; border: 1px solid rgba(216, 180, 254, 0.14); border-radius: 8px; color: #fbf7ff; @@ -105,6 +112,34 @@ main { border-color: rgba(216, 180, 254, 0.34); } +.search-clear-btn { + position: absolute; + right: 8px; + display: inline-flex; + align-items: center; + justify-content: center; + width: 24px; + height: 24px; + padding: 0; + border: 0; + border-radius: 999px; + background: rgba(216, 180, 254, 0.12); + color: #b7a3cf; + font-size: 16px; + line-height: 1; + cursor: pointer; + transition: color 140ms ease, background 140ms ease; +} + +.search-clear-btn:hover { + color: #fbf7ff; + background: rgba(168, 85, 247, 0.28); +} + +.search-clear-btn[hidden] { + display: none !important; +} + .toolbar-left { display: flex; flex-wrap: wrap; diff --git a/assets/js/examples.js b/assets/js/examples.js index 9c5c863..995c9e9 100644 --- a/assets/js/examples.js +++ b/assets/js/examples.js @@ -14,6 +14,7 @@ var chips = document.querySelectorAll('.filter-chip'); var cards = document.querySelectorAll('.example-card, .featured-card'); var search = document.querySelector('[data-example-search]'); + var clearBtn = document.querySelector('[data-example-search-clear]'); var count = document.querySelector('[data-example-count]'); if (!chips.length || !cards.length) return; @@ -73,9 +74,20 @@ if (search) { search.addEventListener('input', function() { query = search.value.trim().toLowerCase(); + if (clearBtn) clearBtn.hidden = !query; applyFilters(); }); } + + if (clearBtn && search) { + clearBtn.addEventListener('click', function() { + search.value = ''; + query = ''; + clearBtn.hidden = true; + applyFilters(); + search.focus(); + }); + } })(); ;(function animateExamplesTerminal() { diff --git a/examples.html b/examples.html index 154e05c..8cc7aee 100644 --- a/examples.html +++ b/examples.html @@ -68,7 +68,10 @@