diff --git a/app/static/builder/command-builder.css b/app/static/builder/command-builder.css index 20402b70..6424d72c 100644 --- a/app/static/builder/command-builder.css +++ b/app/static/builder/command-builder.css @@ -278,6 +278,7 @@ #nullius-builder .std-boat-sizes .nb-tile-note { font-size: 13px; line-height: 1.4; } /* the Benchmark and Agent steps' grids: the card toolkit's (catalogue.css), fitted to the form */ #nullius-builder .nb-step { border-radius: 0; margin: 0; } /* catalogue.css has a .nb-step of its own */ +#nullius-builder .st-search-clear:focus-visible { outline-offset: 1px; } /* style.css's ring, inside the search box's own */ #nullius-builder :is(#nb-bench-grid, #nb-agent-grid) { margin-bottom: 20px; } #nullius-builder :is(#nb-bench-grid, #nb-agent-grid) .bench-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; grid-auto-rows: 1fr; } #nullius-builder :is(#nb-bench-grid, #nb-agent-grid) .bench-card { padding: 16px; gap: 10px; } diff --git a/app/static/style.css b/app/static/style.css index de6b267c..d3f123cf 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -397,6 +397,12 @@ button.seg:hover { filter: brightness(1.25); } .st-search input { min-width: 0; width: 100%; padding: 0; border: 0; background: transparent; color: var(--text); font: 13px var(--sans); } .st-search input:focus-visible { outline: none; } .st-search:focus-within { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); } +/* the toolkit's one clear control; the browser's own is hidden */ +.st-search [data-search]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; } +.st-search-clear { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin: -2px -4px -2px 0; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--text-faint); cursor: pointer; } +.st-search-clear .ic { width: 14px; height: 14px; } +.st-search-clear:hover { color: var(--text); background: var(--surface); } +.st-search-clear:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; } .menu-wrap { position: relative; } .btn.sm { font-size: .8rem; padding: .42rem .75rem; } .menu { diff --git a/app/static/tables.js b/app/static/tables.js index 53ac9231..fa09f614 100644 --- a/app/static/tables.js +++ b/app/static/tables.js @@ -153,17 +153,22 @@ window.NulliusTable = { /* A controls row's search box and filters (the controls macro), under `tools`; each optional. Search keeps the rows (or cards) whose data-search holds every word of the query, in any order and case; - Escape clears it. A column narrows when it does not show every value; + its clear button, shown while it holds text, or Escape empties it as + typing would and leaves the focus in it. A column narrows when it does not show every value; the Filter button or a dropdown holding such a column is marked .narrowed and counts: the Filter button the columns it narrows, a dropdown the values chosen (after None, 0), or the one chosen by name. Clear filters clears every column. `changed` runs after any of them. Returns passes(row). */ narrow(tools, changed) { const [fbtn, fmenu] = [tools.querySelector('[data-tools-btn="filter"]'), tools.querySelector('[data-tools="filter"]')]; - const q = tools.querySelector('[data-search]'); + const q = tools.querySelector('[data-search]'), x = tools.querySelector('[data-search-clear]'); + const shown = () => { if (x) x.hidden = !q.value; }; + const clear = () => { q.value = ''; q.dispatchEvent(new Event('input', {bubbles: true})); q.focus(); }; if (q) { - q.addEventListener('input', changed); - q.addEventListener('keydown', e => { if (e.key === 'Escape' && q.value) { e.preventDefault(); q.value = ''; changed(); } }); + q.addEventListener('input', () => { shown(); changed(); }); + q.addEventListener('keydown', e => { if (e.key === 'Escape' && q.value) { e.preventDefault(); clear(); } }); + x?.addEventListener('click', clear); + shown(); // a value the browser restored } const found = row => !q || this.matches(row.dataset.search, q.value); const menus = [...(fmenu ? [[fbtn, fmenu, () => 1]] : []), @@ -176,7 +181,7 @@ window.NulliusTable = { count.textContent = sets.length === 1 ? n(sets[0]) : sets.length ? sets.reduce((sum, set) => sum + n(set), 0) : ''; count.hidden = !sets.length; }); - const narrowed = () => { mark(); changed(); }; + const narrowed = () => { mark(); if (q) shown(); changed(); }; // a page that empties the box itself, then filters const f = this.filters(tools, narrowed); mark(); menus.forEach(([btn, menu]) => this.menu(btn, menu)); diff --git a/app/templates/_tables.html b/app/templates/_tables.html index db81311f..1cfe06b7 100644 --- a/app/templates/_tables.html +++ b/app/templates/_tables.html @@ -79,7 +79,7 @@ {% macro controls(id, cols, search='', columns=false, choices={}, only={}, views=none, actions=none, sort=true, layout=none, default='table') %} {%- set by = {'button': [], 'dropdown': [], 'pills': []} %}{% for c in cols if c.key in choices %}{% for f in ([c.filter] if c.filter is string else c.filter or ['button']) %}{% set _ = by[f].append(c) %}{% endfor %}{% endfor %}