diff --git a/docs/syntax/tables.md b/docs/syntax/tables.md index 11bda53bbd..ae0aa069ef 100644 --- a/docs/syntax/tables.md +++ b/docs/syntax/tables.md @@ -149,7 +149,7 @@ The `{table}` directive's `:matrix:` option highlights the whole row *and* colum ## Filterable table -The `{table}` directive's `:filterable:` option adds a search box above the table, plus a dropdown filter for each column that has a small number of repeated values — for example a type or status column. Search matches text in every column. Search and filters combine — each one you set narrows the results further. A live "Showing N of M" count is announced to assistive technologies. +The `{table}` directive's `:filterable:` option adds a search box above the table, plus a dropdown filter for each column that has a small number of repeated values — for example a type or status column. The dropdowns start collapsed behind a **Filters** button next to the search box, which shows how many filters are on. Search matches text in every column. Search and filters combine — each one you set narrows the results further. A live "Showing N of M" count is announced to assistive technologies. While a search or filter is set, a **Clear** button next to the count resets them all. When nothing matches, a message under the header row says so. The table is rendered server-side and stays fully usable without JavaScript, because the controls are added only as a progressive enhancement. The filter inputs don't print. A filter stays applied when you print, so a printed filtered table keeps its "Showing N of M" count to show that rows are missing. diff --git a/src/Elastic.Documentation.Site/Assets/markdown/table.css b/src/Elastic.Documentation.Site/Assets/markdown/table.css index 43a56ab72a..038a94f8b0 100644 --- a/src/Elastic.Documentation.Site/Assets/markdown/table.css +++ b/src/Elastic.Documentation.Site/Assets/markdown/table.css @@ -256,7 +256,9 @@ that reads like the complete table. An unfiltered table prints with no controls at all, since there is nothing to disclose. */ .filterable-table-search, - .filterable-table-facet { + .filterable-table-toggle, + .filterable-table-facets, + .filterable-table-clear { display: none !important; } @@ -275,34 +277,122 @@ display: block; } + /* Three rows: the search box on its own, the dropdowns in a grid, then + the count and the "Clear filters" button. The search box and the + dropdowns never compete for the same row, so neither one squeezes or + wraps the other. */ .filterable-table-controls { display: flex; - flex-wrap: wrap; - align-items: center; + flex-direction: column; gap: 0.75rem; margin: 0.75rem 0; } + /* The search box takes the row, with the Filters button beside it. */ + .filterable-table-search-row { + display: flex; + gap: 0.5rem; + } + .filterable-table-search { - min-width: 16rem; - padding: 0.375rem 0.625rem; + flex: 1 1 auto; + min-width: 0; + padding: 0.5rem 0.75rem; border: 1px solid var(--color-grey-30); border-radius: 6px; font-size: 0.875rem; } - .filterable-table-facet { + /* Equal columns that wrap as the page narrows, so the dropdowns line up + whatever their labels and values are. */ + .filterable-table-facets { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); + gap: 0.75rem; + + /* display:grid would otherwise override the hidden attribute. */ + &:empty, + &[hidden] { + display: none; + } + } + + .filterable-table-toggle { display: inline-flex; + flex: none; align-items: center; gap: 0.375rem; + padding: 0.375rem 0.75rem; + border: 1px solid var(--color-grey-30); + border-radius: 6px; + background: var(--color-white); + font-size: 0.875rem; + color: var(--color-ink-dark); + white-space: nowrap; + cursor: pointer; + + &:hover, + &[aria-expanded='true'] { + background: var(--color-grey-10); + } + + &[hidden] { + display: none; + } + } + + .filterable-table-toggle-icon, + .filterable-table-toggle-chevron { + width: 1rem; + height: 1rem; + } + + .filterable-table-toggle-chevron { + transition: transform 0.15s ease; + + [aria-expanded='true'] > & { + transform: rotate(180deg); + } + } + + /* How many filters are on, so the count stays visible with the panel shut. */ + .filterable-table-toggle-count { + min-width: 1.25rem; + padding: 0 0.375rem; + border-radius: 999px; + background: var(--color-blue-elastic); + font-size: 0.75rem; + font-weight: 600; + line-height: 1.25rem; + text-align: center; + color: var(--color-white); + + &:empty { + display: none; + } + } + + .filterable-table-facet { + display: flex; + flex-direction: column; + gap: 0.25rem; + min-width: 0; font-size: 0.875rem; } + .filterable-table-facet-label { + font-size: 0.8125rem; + font-weight: 600; + color: var(--color-ink-light); + } + /* The browser's own arrow sits against the right border. Draw one inset from the edge instead, in the text color, and leave room for it. */ .filterable-table-facet select { + width: 100%; + min-width: 0; appearance: none; - padding: 0.25rem 2rem 0.25rem 0.5rem; + padding: 0.375rem 2rem 0.375rem 0.5rem; border: 1px solid var(--color-grey-30); border-radius: 6px; background-color: var(--color-white); @@ -325,6 +415,21 @@ background-size: 0.375rem 0.375rem; background-repeat: no-repeat; font-size: 0.875rem; + text-overflow: ellipsis; + } + + /* A dropdown that's narrowing the table, so readers can see at a glance + which filters are on. */ + .filterable-table-facet[data-active] select { + border-color: var(--color-blue-elastic); + box-shadow: 0 0 0 1px var(--color-blue-elastic); + } + + .filterable-table-summary { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 0.75rem; } /* Forced-colors mode (Windows High Contrast) drops gradient backgrounds, @@ -337,8 +442,45 @@ } .filterable-table-status { - margin-inline-start: auto; font-size: 0.8125rem; color: var(--color-grey-100); } + + /* When nothing matches, the message sits under the header row like an + empty table body: the table's bottom margin goes, and the message + carries on its side and bottom borders. */ + filterable-table[data-empty] .table-wrapper { + margin-bottom: 0; + } + + .filterable-table-empty { + margin: 0 0 1rem; + padding: 1.5rem 1rem; + border: 1px solid var(--color-grey-20); + border-top: 0; + text-align: center; + font-size: 0.875rem; + color: var(--color-ink-light); + + &[hidden] { + display: none; + } + } + + .filterable-table-clear { + padding: 0; + border: 0; + background: none; + font-size: 0.8125rem; + color: var(--color-blue-elastic); + cursor: pointer; + + &:hover { + text-decoration: underline; + } + + &[hidden] { + display: none; + } + } } diff --git a/src/Elastic.Documentation.Site/Assets/web-components/FilterableTable.test.ts b/src/Elastic.Documentation.Site/Assets/web-components/FilterableTable.test.ts index 13b0f5e8d0..6ed0aa1754 100644 --- a/src/Elastic.Documentation.Site/Assets/web-components/FilterableTable.test.ts +++ b/src/Elastic.Documentation.Site/Assets/web-components/FilterableTable.test.ts @@ -534,9 +534,9 @@ describe('filterable-table author-chosen dropdowns', () => { ` const facetLabels = () => - Array.from(document.querySelectorAll('.filterable-table-facet')).map( - (f) => f.textContent?.split(':')[0] - ) + Array.from( + document.querySelectorAll('.filterable-table-facet-label') + ).map((label) => label.textContent) it('offers a dropdown for every qualifying column by default', () => { document.body.innerHTML = SCORES_HTML('') @@ -636,3 +636,241 @@ describe('filterable-table author-chosen dropdowns', () => { expect(facetLabels()).toEqual(['Provider']) }) }) + +describe('filterable-table control layout', () => { + const clearButton = () => + document.querySelector('.filterable-table-clear')! + const search = () => + document.querySelector('.filterable-table-search')! + const select = () => + document.querySelector( + '.filterable-table-facet select' + )! + + it('puts search, dropdowns, and the count in separate rows', () => { + mount() + const rows = Array.from( + document.querySelector('.filterable-table-controls')!.children + ).map((el) => el.className) + expect(rows).toEqual([ + 'filterable-table-search-row', + 'filterable-table-facets', + 'filterable-table-summary', + ]) + expect( + document.querySelector('.filterable-table-facet-label')?.textContent + ).toBe('Support status') + }) + + it('shows Clear filters only while something is filtered', () => { + mount() + expect(clearButton().hidden).toBe(true) + + search().value = 'apache' + search().dispatchEvent(new Event('input')) + expect(clearButton().hidden).toBe(false) + + search().value = '' + search().dispatchEvent(new Event('input')) + expect(clearButton().hidden).toBe(true) + }) + + it('marks a dropdown that is narrowing the table', () => { + mount() + const facet = document.querySelector('.filterable-table-facet')! + expect(facet.hasAttribute('data-active')).toBe(false) + + select().value = 'Core' + select().dispatchEvent(new Event('change')) + expect(facet.hasAttribute('data-active')).toBe(true) + }) + + it('resets search and dropdowns from Clear filters', () => { + mount() + search().value = 'host' + search().dispatchEvent(new Event('input')) + select().value = 'Core' + select().dispatchEvent(new Event('change')) + expect(visibleRows()).toHaveLength(1) + + clearButton().click() + expect(search().value).toBe('') + expect(select().value).toBe('') + expect(visibleRows()).toHaveLength(4) + expect(clearButton().hidden).toBe(true) + expect(document.activeElement).toBe(search()) + }) +}) + +describe('filterable-table empty results', () => { + const message = () => + document.querySelector('.filterable-table-empty')! + const search = (value: string) => { + const input = document.querySelector( + '.filterable-table-search' + )! + input.value = value + input.dispatchEvent(new Event('input')) + } + const choose = (value: string) => { + const select = document.querySelector( + '.filterable-table-facet select' + )! + select.value = value + select.dispatchEvent(new Event('change')) + } + + it('labels the reset button Clear', () => { + mount() + expect( + document.querySelector('.filterable-table-clear')?.textContent + ).toBe('Clear') + }) + + it('hides the message while rows match', () => { + mount() + expect(message().hidden).toBe(true) + search('apache') + expect(message().hidden).toBe(true) + }) + + it('explains an empty table after a search', () => { + mount() + search('nothing-matches') + expect(message().hidden).toBe(false) + expect(message().textContent).toBe('No rows match your search.') + }) + + it('explains an empty table after filters', () => { + // Each value matches some rows, but no row is both an Exporter and + // Extended, so only the two filters together empty the table. + document.body.innerHTML = ` + + + + + + + + +
NameTypeStatus
aReceiverCore
bReceiverExtended
cExporterCore
+
` + customElements.upgrade(document.body) + const [type, status] = Array.from( + document.querySelectorAll( + '.filterable-table-facet select' + ) + ) + type.value = 'Exporter' + type.dispatchEvent(new Event('change')) + status.value = 'Extended' + status.dispatchEvent(new Event('change')) + expect(message().hidden).toBe(false) + expect(message().textContent).toBe('No rows match your filters.') + }) + + it('names both search and filters when both are set', () => { + mount() + choose('Extended') + search('filelog') + expect(message().hidden).toBe(false) + expect(message().textContent).toBe( + 'No rows match your search and filters.' + ) + expect( + document + .querySelector('filterable-table')! + .hasAttribute('data-empty') + ).toBe(true) + }) + + it('hides the message again after Clear', () => { + mount() + search('nothing-matches') + document + .querySelector('.filterable-table-clear')! + .click() + expect(message().hidden).toBe(true) + expect( + document + .querySelector('filterable-table')! + .hasAttribute('data-empty') + ).toBe(false) + }) + + it('keeps one message when an enhanced host is cloned', () => { + mount() + const host = document.querySelector('filterable-table')! + const clone = host.cloneNode(true) as HTMLElement + clone.querySelector('.filterable-table-controls')?.remove() + delete clone.dataset.enhanced + document.body.appendChild(clone) + expect(clone.querySelectorAll('.filterable-table-empty')).toHaveLength( + 1 + ) + }) +}) + +describe('filterable-table collapsible filters', () => { + const toggle = () => + document.querySelector('.filterable-table-toggle')! + const panel = () => + document.querySelector('.filterable-table-facets')! + const count = () => + document.querySelector('.filterable-table-toggle-count')!.textContent + + it('starts with the dropdowns collapsed behind a Filters button', () => { + mount() + expect(toggle().hidden).toBe(false) + expect(toggle().textContent).toContain('Filters') + expect(toggle().getAttribute('aria-expanded')).toBe('false') + expect(toggle().getAttribute('aria-controls')).toBe(panel().id) + expect(panel().hidden).toBe(true) + }) + + it('opens and closes the dropdowns from the button', () => { + mount() + toggle().click() + expect(panel().hidden).toBe(false) + expect(toggle().getAttribute('aria-expanded')).toBe('true') + toggle().click() + expect(panel().hidden).toBe(true) + expect(toggle().getAttribute('aria-expanded')).toBe('false') + }) + + it('counts the filters that are on, with the panel open or shut', () => { + mount() + expect(count()).toBe('') + expect(toggle().getAttribute('aria-label')).toBe('Filters') + + toggle().click() + const select = document.querySelector( + '.filterable-table-facet select' + )! + select.value = 'Core' + select.dispatchEvent(new Event('change')) + toggle().click() + + expect(panel().hidden).toBe(true) + expect(count()).toBe('1') + expect(toggle().getAttribute('aria-label')).toBe('Filters, 1 on') + }) + + it('gives each table its own panel id', () => { + document.body.innerHTML = TABLE_HTML + TABLE_HTML + customElements.upgrade(document.body) + const ids = Array.from( + document.querySelectorAll('.filterable-table-facets') + ).map((el) => el.id) + expect(new Set(ids).size).toBe(2) + }) + + it('hides the button when there are no dropdowns', () => { + document.body.innerHTML = TABLE_HTML.replace( + '', + '' + ) + customElements.upgrade(document.body) + expect(toggle().hidden).toBe(true) + }) +}) diff --git a/src/Elastic.Documentation.Site/Assets/web-components/FilterableTable.ts b/src/Elastic.Documentation.Site/Assets/web-components/FilterableTable.ts index 97d20882ce..457950ffe2 100644 --- a/src/Elastic.Documentation.Site/Assets/web-components/FilterableTable.ts +++ b/src/Elastic.Documentation.Site/Assets/web-components/FilterableTable.ts @@ -23,6 +23,14 @@ const SETTLE_MS = 150 // htmx swaps) can never trigger a rebuild while someone is using the filters. const WATCH_CEILING_MS = 5000 +// Gives each dropdown panel a unique id for its button's aria-controls. +let facetListIds = 0 + +// The Filters button: a funnel icon, the label, a count of the filters that +// are on (empty when none), and a chevron that flips when the panel opens. +// Static markup, with no reader or author text in it. +const TOGGLE_CONTENT = `Filters` + type Facet = { colIndex: number; select: HTMLSelectElement } type FacetSpec = { colIndex: number; label: string; values: string[] } @@ -35,6 +43,10 @@ class FilterableTableElement extends HTMLElement { private facets: Facet[] = [] private status: HTMLElement | null = null private controls: HTMLElement | null = null + private facetList: HTMLElement | null = null + private clearButton: HTMLButtonElement | null = null + private emptyMessage: HTMLElement | null = null + private toggleButton: HTMLButtonElement | null = null private facetSignature = '' private observer: MutationObserver | null = null private settleTimer = 0 @@ -204,6 +216,13 @@ class FilterableTableElement extends HTMLElement { return specs } + /** + * Lays the controls out in rows: the search box with a "Filters" button, + * the dropdowns in a grid with their labels above them (collapsed until + * the button opens them), and the count with a "Clear" button that shows + * only while something is filtered. A message below the table says so + * when nothing matches. + */ private buildControls(): void { const controls = document.createElement('div') controls.className = 'filterable-table-controls' @@ -214,30 +233,94 @@ class FilterableTableElement extends HTMLElement { search.className = 'filterable-table-search' search.setAttribute('aria-label', 'Filter table') search.addEventListener('input', () => this.applyFilters()) - controls.appendChild(search) this.searchInput = search + // The dropdowns start collapsed behind a "Filters" button beside the + // search box. The button carries a count of the filters that are on, + // so readers can tell the table is narrowed even with the panel shut. + const facetList = document.createElement('div') + facetList.className = 'filterable-table-facets' + facetList.id = `filterable-table-facets-${++facetListIds}` + facetList.hidden = true + this.facetList = facetList + + const toggle = document.createElement('button') + toggle.type = 'button' + toggle.className = 'filterable-table-toggle' + toggle.setAttribute('aria-expanded', 'false') + toggle.setAttribute('aria-controls', facetList.id) + toggle.innerHTML = TOGGLE_CONTENT + toggle.addEventListener('click', () => + this.showFilters(facetList.hidden) + ) + this.toggleButton = toggle + + const searchRow = document.createElement('div') + searchRow.className = 'filterable-table-search-row' + searchRow.append(search, toggle) + controls.append(searchRow, facetList) + + const summary = document.createElement('div') + summary.className = 'filterable-table-summary' + const status = document.createElement('span') status.className = 'filterable-table-status' status.setAttribute('role', 'status') status.setAttribute('aria-live', 'polite') - controls.appendChild(status) + summary.appendChild(status) this.status = status + const clear = document.createElement('button') + clear.type = 'button' + clear.className = 'filterable-table-clear' + clear.textContent = 'Clear' + clear.hidden = true + clear.addEventListener('click', () => this.clearFilters()) + summary.appendChild(clear) + this.clearButton = clear + + controls.appendChild(summary) this.controls = controls this.insertBefore(controls, this.firstChild) + + // Shown under the header row when nothing matches, so an empty table + // doesn't look broken. It isn't a live region: the count above it + // already announces "Showing 0 of N". A fullscreen copy is cloned + // from an enhanced host, so drop any message the clone carried over. + this.querySelector(':scope > .filterable-table-empty')?.remove() + // A div, not a p: the page's paragraph styles would add a top margin. + const empty = document.createElement('div') + empty.className = 'filterable-table-empty' + empty.hidden = true + this.appendChild(empty) + this.emptyMessage = empty + this.renderFacets() } + /** Opens or closes the dropdown panel. */ + private showFilters(open: boolean): void { + if (!this.facetList || !this.toggleButton) return + this.facetList.hidden = !open + this.toggleButton.setAttribute('aria-expanded', String(open)) + } + + /** Empties the search box, sets every dropdown back to All, and returns focus to search. */ + private clearFilters(): void { + if (this.searchInput) this.searchInput.value = '' + for (const facet of this.facets) facet.select.value = '' + this.applyFilters() + this.searchInput?.focus() + } + /** * Builds the dropdowns, or rebuilds them when late-rendering content has * changed what the columns contain. A no-op when nothing changed, so * incidental DOM churn costs nothing. */ private renderFacets(): void { - const controls = this.controls - const status = this.status - if (!controls || !status) return + const facetList = this.facetList + if (!facetList) return const specs = this.facetSpecs() const signature = JSON.stringify(specs) @@ -254,7 +337,10 @@ class FilterableTableElement extends HTMLElement { for (const spec of specs) { const wrapper = document.createElement('label') wrapper.className = 'filterable-table-facet' - wrapper.append(`${spec.label}: `) + const name = document.createElement('span') + name.className = 'filterable-table-facet-label' + name.textContent = spec.label + wrapper.appendChild(name) const select = document.createElement('select') select.setAttribute('aria-label', `Filter by ${spec.label}`) @@ -268,10 +354,14 @@ class FilterableTableElement extends HTMLElement { select.addEventListener('change', () => this.applyFilters()) wrapper.appendChild(select) - // Keep the count last in the control row. - controls.insertBefore(wrapper, status) + facetList.appendChild(wrapper) this.facets.push({ colIndex: spec.colIndex, select }) } + + // No dropdowns, no button: a search-only table shows just the search box. + if (this.toggleButton) + this.toggleButton.hidden = this.facets.length === 0 + if (this.facets.length === 0) this.showFilters(false) } private watchLateContent(tbody: HTMLTableSectionElement): void { @@ -341,6 +431,46 @@ class FilterableTableElement extends HTMLElement { // count, so it can't be mistaken for the complete table. this.dataset.filtered = String(visible < this.rows.length) + // Mark the dropdowns that narrow the table, and offer a way to undo + // everything only while something is set. + for (const facet of this.facets) + facet.select + .closest('label') + ?.toggleAttribute('data-active', facet.select.value !== '') + if (this.clearButton) + this.clearButton.hidden = query === '' && activeFacets.length === 0 + + // Count the filters that are on in the Filters button, visibly and in + // its accessible name. + if (this.toggleButton) { + const count = this.toggleButton.querySelector( + '.filterable-table-toggle-count' + ) + if (count) + count.textContent = + activeFacets.length > 0 ? String(activeFacets.length) : '' + this.toggleButton.setAttribute( + 'aria-label', + activeFacets.length > 0 + ? `Filters, ${activeFacets.length} on` + : 'Filters' + ) + } + + // Say why the table is empty, naming what's narrowing it. + const none = visible === 0 + this.toggleAttribute('data-empty', none) + if (this.emptyMessage) { + this.emptyMessage.hidden = !none + if (none) + this.emptyMessage.textContent = + query !== '' && activeFacets.length > 0 + ? 'No rows match your search and filters.' + : query !== '' + ? 'No rows match your search.' + : 'No rows match your filters.' + } + const text = `Showing ${visible} of ${this.rows.length}` // Only touch the live region when the count really changed, so typing // doesn't queue one announcement per keystroke. diff --git a/src/Elastic.Documentation.Site/Components/Markdown/Table/table.css b/src/Elastic.Documentation.Site/Components/Markdown/Table/table.css index 81ba3f360f..8306b29012 100644 --- a/src/Elastic.Documentation.Site/Components/Markdown/Table/table.css +++ b/src/Elastic.Documentation.Site/Components/Markdown/Table/table.css @@ -229,15 +229,14 @@ dialog.table-modal thead th { background: var(--color-surface-sunken); } -/* The filter controls come from the filterable-table element. */ +/* The filter controls come from the filterable-table element: the search box with a Filters button, the dropdowns (collapsed until the button opens them), then the count and a Clear button. */ filterable-table { display: block; } .filterable-table-controls { display: flex; - flex-wrap: wrap; - align-items: center; + flex-direction: column; gap: var(--space-3); margin: var(--space-3) 0; } @@ -252,12 +251,106 @@ filterable-table { font-size: var(--text-sm); } +/* The search box takes the row, with the Filters button beside it. */ +.filterable-table-search-row { + display: flex; + gap: var(--space-2); +} + .filterable-table-search { - min-width: 16rem; + flex: 1 1 auto; + min-width: 0; + padding: var(--space-2) var(--space-3); +} + +.filterable-table-toggle { + display: inline-flex; + flex: none; + align-items: center; + gap: var(--space-2); + padding: var(--space-1) var(--space-3); + border: var(--border-width) solid var(--color-border-control); + border-radius: var(--radius-md); + background: var(--color-surface); + color: var(--color-text); + font-size: var(--text-sm); + white-space: nowrap; + cursor: pointer; +} + +.filterable-table-toggle:hover, +.filterable-table-toggle[aria-expanded='true'] { + background: var(--color-surface-sunken); +} + +.filterable-table-toggle[hidden] { + display: none; +} + +/* The design-system reset makes SVGs block-level with no size, so size the icons here. */ +.filterable-table-toggle-icon, +.filterable-table-toggle-chevron { + width: 1rem; + height: 1rem; +} + +.filterable-table-toggle-chevron { + transition: transform 0.15s ease; +} + +.filterable-table-toggle[aria-expanded='true'] + .filterable-table-toggle-chevron { + transform: rotate(180deg); +} + +/* How many filters are on, so the count stays visible with the panel shut. */ +.filterable-table-toggle-count { + min-width: 1.25rem; + padding: 0 var(--space-1); + border-radius: var(--radius-pill); + background: var(--color-accent); + color: var(--color-on-accent); + font-size: var(--text-xs); + font-weight: var(--weight-semibold); + line-height: 1.25rem; + text-align: center; +} + +.filterable-table-toggle-count:empty { + display: none; +} + +/* Equal columns that wrap as the page narrows, so the dropdowns line up whatever their labels and values are. */ +.filterable-table-facets { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); + gap: var(--space-3); +} + +/* display:grid would otherwise override the hidden attribute. */ +.filterable-table-facets:empty, +.filterable-table-facets[hidden] { + display: none; +} + +.filterable-table-facet { + display: flex; + flex-direction: column; + gap: var(--space-1); + min-width: 0; + font-size: var(--text-sm); +} + +.filterable-table-facet-label { + color: var(--color-text-muted); + font-size: var(--text-xs); + font-weight: var(--weight-semibold); } /* The browser's own arrow sits against the right border. Draw one inset from the edge instead, in the text colour, and leave room for it. */ .filterable-table-facet select { + width: 100%; + min-width: 0; appearance: none; padding-inline-end: calc(var(--space-2) + 1.25rem); background-image: @@ -278,6 +371,7 @@ filterable-table { calc(100% - 0.625rem) 50%; background-size: 0.375rem 0.375rem; background-repeat: no-repeat; + text-overflow: ellipsis; } /* Forced-colors mode (Windows High Contrast) drops gradient backgrounds, so the drawn arrow would vanish. Bring back the browser's own. */ @@ -288,23 +382,66 @@ filterable-table { } } -.filterable-table-facet { - display: inline-flex; +/* A dropdown that's narrowing the table, so readers can see at a glance which filters are on. */ +.filterable-table-facet[data-active] select { + border-color: var(--color-accent); + box-shadow: 0 0 0 var(--border-width) var(--color-accent); +} + +.filterable-table-summary { + display: flex; + flex-wrap: wrap; align-items: center; - gap: var(--space-2); - font-size: var(--text-sm); + gap: var(--space-3); } .filterable-table-status { - margin-inline-start: auto; color: var(--color-text-muted); font-size: var(--text-sm); } +.filterable-table-clear { + padding: 0; + border: 0; + background: none; + color: var(--color-accent); + font-size: var(--text-sm); + cursor: pointer; +} + +.filterable-table-clear:hover { + text-decoration: underline; +} + +.filterable-table-clear[hidden] { + display: none; +} + +/* When nothing matches, the message sits under the header row like an empty table body: the table's bottom margin goes, and the message carries on its side and bottom borders. */ +filterable-table[data-empty] .table-wrapper { + margin-bottom: 0; +} + +.filterable-table-empty { + margin: 0 0 var(--space-4); + padding: var(--space-5) var(--space-4); + border: var(--border-width) solid var(--color-border); + border-top: 0; + color: var(--color-text-muted); + font-size: var(--text-sm); + text-align: center; +} + +.filterable-table-empty[hidden] { + display: none; +} + @media print { .table-expand-btn, .filterable-table-search, - .filterable-table-facet { + .filterable-table-toggle, + .filterable-table-facets, + .filterable-table-clear { display: none; }