A results page answers a search: a field for the words, conditions that narrow what was found, a count, a sort, and the results in pages. It stands on the page frame, a header, the main region and a footer, and the document scrolls as a whole. The conditions stand beside the results where there is room and wait in a drawer where there is not.
Results
<div class="page bg-surface-base fg-text-body text-sm" data-example="results"> <a class="skip" href="#rs-main">Skip to content</a> <header class="navbar" style="--navbar-padding-x: max(1.5rem, calc(50% - 33.5rem))"> <a class="navbar-brand" href="#"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" /> <path d="M8 4.3333A3.6667 3.6667 0 0 1 8 11.6667Z" fill="currentColor" stroke="none" /> </svg>Atlas</a> <nav class="navbar-nav" aria-label="Main"> <a class="navbar-link" href="#">Product</a> <a class="navbar-link" href="#">Pricing</a> <a class="navbar-link" href="#">Docs</a> <a class="navbar-link" href="#" aria-current="page">Resources</a> </nav> <div class="navbar-end"> <a class="btn btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <button type="button" class="btn btn-quiet btn-square btn-sm navbar-toggle" popovertarget="rs-menu" aria-label="Open the menu"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M3 5.5L13 5.5" /> <path d="M3 10.5L13 10.5" /> </svg> </button> <div class="menu menu-end" id="rs-menu" popover> <a class="menu-item" href="#">Product</a> <a class="menu-item" href="#">Pricing</a> <a class="menu-item" href="#">Docs</a> <a class="menu-item" href="#" aria-current="page">Resources</a> <a class="menu-item" href="#">Sign in</a> </div> </div> </header> <main class="grow(1) w-full max-w(1120) mx-auto px-lg py-xl container-inline" id="rs-main" tabindex="-1"> <header class="flex flex-col gap-3xs"> <h1 class="heading heading-xl">Resources</h1> <p class="m(0) fg-text-muted">Guides, templates, videos and case studies for teams that deploy with Atlas.</p> </header> <form class="flex flex-wrap gap-xs max-w(560) mt-lg" id="rs-form" method="get" role="search" aria-label="Resources"> <label class="input-group grow(1) basis(200) min-w(0)"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="7" cy="7" r="4.5" /> <path d="M10.182 10.182L14 14" /> </svg> <input class="input-group-field" type="search" name="q" placeholder="Search resources" aria-label="Search resources" autocomplete="off"> </label> <button class="btn">Search</button> </form> <div class="flex flex-col gap-lg mt-xl flex-row@container(--4xl) gap-xl@container(--4xl)"> <div class="w(240)@container(--4xl) pt(6)@container(--4xl) shrink(0)" data-results="sidebar"> <fieldset class="fieldset" data-results="conditions"> <legend class="fieldset-legend">Type</legend> <label class="check flex"> <input type="checkbox" class="checkbox" name="type" value="guide" form="rs-form"> <span class="grow(1)">Guides</span> <span class="fg-text-muted" data-count="guide">4</span> </label> <label class="check flex"> <input type="checkbox" class="checkbox" name="type" value="template" form="rs-form"> <span class="grow(1)">Templates</span> <span class="fg-text-muted" data-count="template">3</span> </label> <label class="check flex"> <input type="checkbox" class="checkbox" name="type" value="video" form="rs-form"> <span class="grow(1)">Videos</span> <span class="fg-text-muted" data-count="video">3</span> </label> <label class="check flex"> <input type="checkbox" class="checkbox" name="type" value="case-study" form="rs-form"> <span class="grow(1)">Case studies</span> <span class="fg-text-muted" data-count="case-study">2</span> </label> </fieldset> </div> <section class="grow(1) basis(0) min-w(0) flex flex-col gap-md" aria-labelledby="rs-results-title"> <h2 class="sr-only" id="rs-results-title">Results</h2> <div class="flex flex-wrap items-center gap-xs"> <div class="hidden@container(--4xl)" data-results="open" hidden> <button type="button" class="btn btn-sm" commandfor="rs-filters" command="show-modal"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M4.5365 3L11.4635 3A1 1 0 0 1 12.2548 4.6114L9.4587 8.2299A1 1 0 0 0 9.25 8.8413L9.25 11.323A1 1 0 0 1 8.6214 12.2514L7.875 12.55A0.8203 0.8203 0 0 1 6.75 11.7883L6.75 8.8413A1 1 0 0 0 6.5413 8.2299L3.7452 4.6114A1 1 0 0 1 4.5365 3Z" /> </svg>Filters <span data-results="applied" hidden> <span class="badge badge-sm badge-ink badge-pill" aria-hidden="true">0</span> <span class="sr-only">, 0 applied</span> </span> </button> </div> <p class="m(0) grow(1) fg-text-muted" id="rs-count" role="status">12 resources</p> <div data-results="clear" hidden> <button type="button" class="btn btn-quiet btn-sm">Clear all</button> </div> <div class="flex flex-wrap items-center justify-between gap-xs grow(1) grow(0)@container(--md)"> <label class="flex flex-wrap items-center gap-xs fg-text-muted">Sort <select class="select select-sm" name="sort" form="rs-form"> <option class="select-option" value="updated">Recently updated</option> <option class="select-option" value="name">Name</option> </select> </label> <div class="segmented segmented-sm" role="radiogroup" aria-label="Show results as"> <label class="segmented-item"> <input type="radio" class="segmented-input" name="view" value="cards" form="rs-form" checked>Cards</label> <label class="segmented-item"> <input type="radio" class="segmented-input" name="view" value="list" form="rs-form">List</label> </div> </div> </div> <div id="rs-results"> <ul class="auto-grid" style="--auto-grid-min: 15rem"> <li class="card"> <header class="card-header"> <h3 class="card-title"> <a class="card-link" href="#">Deploy your first project</a> </h3> <p class="card-description">Connect a repository, push to main and open the address Atlas gives it.</p> </header> <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted"> <span class="badge">Guide</span> <time datetime="2026-11-12">Nov 12, 2026</time> </div> </li> <li class="card"> <header class="card-header"> <h3 class="card-title"> <a class="card-link" href="#">A tour of the new dashboard</a> </h3> <p class="card-description">Four minutes through projects, domains and usage, now on one page.</p> </header> <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted"> <span class="badge">Video</span> <time datetime="2026-11-10">Nov 10, 2026</time> </div> </li> <li class="card"> <header class="card-header"> <h3 class="card-title"> <a class="card-link" href="#">How Borealis cut cold builds to under a minute</a> </h3> <p class="card-description">Restoring caches before the install step, measured across forty projects.</p> </header> <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted"> <span class="badge">Case study</span> <time datetime="2026-11-06">Nov 6, 2026</time> </div> </li> <li class="card"> <header class="card-header"> <h3 class="card-title"> <a class="card-link" href="#">Astro blog starter</a> </h3> <p class="card-description">Posts in Markdown, a feed and a preview deployment for every draft.</p> </header> <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted"> <span class="badge">Template</span> <time datetime="2026-11-03">Nov 3, 2026</time> </div> </li> <li class="card"> <header class="card-header"> <h3 class="card-title"> <a class="card-link" href="#">Roll back without a meeting</a> </h3> <p class="card-description">A deployment never changes, so going back is choosing an earlier one.</p> </header> <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted"> <span class="badge">Guide</span> <time datetime="2026-10-29">Oct 29, 2026</time> </div> </li> <li class="card"> <header class="card-header"> <h3 class="card-title"> <a class="card-link" href="#">Reading a build log</a> </h3> <p class="card-description">Where a failed build says what went wrong, and what the timings mean.</p> </header> <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted"> <span class="badge">Video</span> <time datetime="2026-10-24">Oct 24, 2026</time> </div> </li> </ul> </div> <div data-results="foot"> <div class="flex flex-wrap items-center justify-between gap-sm"> <p class="m(0) fg-text-muted" id="rs-range">1–6 of 12</p> <nav aria-label="Pagination"> <ol class="pagination" id="rs-pages"> <li> <a class="btn btn-quiet btn-square btn-sm" aria-label="Previous page" aria-disabled="true"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M6 3.5L10.3586 7.8586A0.2 0.2 0 0 1 10.3586 8.1414L6 12.5" transform="rotate(180 8 8)" /> </svg> </a> </li> <li> <a class="btn btn-quiet btn-square btn-sm" href="?page=1" aria-label="Page 1" aria-current="page">1</a> </li> <li> <a class="btn btn-quiet btn-square btn-sm" href="?page=2" aria-label="Page 2">2</a> </li> <li> <a class="btn btn-quiet btn-square btn-sm" href="?page=2" aria-label="Next page"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M6 3.5L10.3586 7.8586A0.2 0.2 0 0 1 10.3586 8.1414L6 12.5" /> </svg> </a> </li> </ol> </nav> </div> </div> <p class="sr-only" id="rs-status" role="status"></p> </section> </div> <dialog class="dialog dialog-drawer" id="rs-filters" closedby="any" aria-labelledby="rs-filters-title" style="--dialog-width: 20rem"> <header class="dialog-header"> <h2 class="dialog-title" id="rs-filters-title">Filters</h2> </header> <div class="dialog-body" data-results="drawer"></div> <footer class="dialog-footer"> <button type="button" class="btn" data-results="drawer-clear">Clear</button> <button type="button" class="btn btn-primary" commandfor="rs-filters" command="close" data-results="drawer-done" aria-live="polite">Show 12 results</button> </footer> <button type="button" class="btn btn-quiet btn-square btn-sm dialog-close" commandfor="rs-filters" command="close" aria-label="Close the filters"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M4 4L12 12" /> <path d="M4 12L12 4" /> </svg> </button> </dialog> </main> <footer class="bt(1) bt-solid b-line-hair"> <div class="flex flex-wrap items-center justify-between gap-sm w-full max-w(1120) mx-auto px-lg py-lg text-xs fg-text-muted"> <span>© 2026 Atlas Labs</span> <nav class="flex flex-wrap gap-lg" aria-label="Footer"> <a class="link link-quiet" href="#">Privacy</a> <a class="link link-quiet" href="#">Terms</a> <a class="link link-quiet" href="#">Status</a> </nav> </div> </footer> <template id="rs-cards"> <ul class="auto-grid" style="--auto-grid-min: 15rem"> <li class="card"> <header class="card-header"> <h3 class="card-title"> <a class="card-link" href="#"></a> </h3> <p class="card-description"></p> </header> <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted"> <span class="badge"></span> <time></time> </div> </li> </ul> </template> <template id="rs-list"> <ul class="list list-interactive mx(-10)"> <li> <a class="list-row" href="#"> <div class="list-body"> <h3 class="list-title"></h3> <p class="list-description"></p> </div> <span class="list-end flex items-center gap-sm fg-text-muted"> <time class="hidden inline@container(--md)"></time> <span class="badge"></span> </span> </a> </li> </ul> </template> <template id="rs-empty"> <div class="empty"> <span class="icon-frame empty-media" aria-hidden="true"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"> <circle cx="8.75" cy="8.75" r="5.75" /> <path d="M12.8159 12.8159L17.5 17.5" /> </svg> </span> <h3 class="empty-title">No resources match</h3> <p class="empty-description">Try another word or fewer types, or clear the conditions to see all 12 resources.</p> <div class="empty-actions"> <button type="button" class="btn btn-sm" data-results="reset">Clear conditions</button> </div> </div> </template> <template id="rs-page"> <ol class="pagination"> <li> <a class="btn btn-quiet btn-square btn-sm" aria-label="Page"></a> </li> </ol> </template></div>import { formatDate, paginate, search, sort } from '../filter-bar/query.js'import { resources, types } from './data.js'const size = 6const labels = new Map(types)const orders = { updated: ['updated', 'descending'], name: ['title', 'ascending'] }/** * The results page on local data. The form is the state: every draw reads the search, the types, the sort and * the view from its named fields, as a server reads them from the URL the same form submits. The script adds * what a round trip would otherwise do (it answers as the reader types and keeps the page number) and moves * the one set of conditions between the sidebar and the drawer. Returns the function that stops it. */export function mount(root) { const $ = (selector) => root.querySelector(selector) const part = (name) => root.querySelector(`[data-results="${name}"]`) const controller = new AbortController() const { signal } = controller const form = $('#rs-form') const drawer = $('#rs-filters') const conditions = part('conditions') const [previous, next] = [$('#rs-pages').firstElementChild, $('#rs-pages').lastElementChild] let page = 1 /** What the form would send: `q`, every checked `type`, `sort` and `view`. */ const query = () => new URLSearchParams(new FormData(form)) /** The address of a page of the same query, for a pagination link. */ const address = (number) => { const given = query() if (!given.get('q')) given.delete('q') given.set('page', number) return `?${given}` } const say = (words) => { $('#rs-status').textContent = words } function results(rows, view) { if (!rows.length) return $('#rs-empty').content.firstElementChild.cloneNode(true) const list = $(`#rs-${view}`).content.firstElementChild.cloneNode(true) const item = list.firstElementChild list.replaceChildren(...rows.map((record) => { const copy = item.cloneNode(true) copy.querySelector('.card-link, .list-title').textContent = record.title copy.querySelector('.card-description, .list-description').textContent = record.summary copy.querySelector('.badge').textContent = labels.get(record.type) copy.querySelector('time').dateTime = record.updated copy.querySelector('time').textContent = formatDate(record.updated) return copy })) return list } function pages(result) { const aim = (link, number, possible) => { if (possible) link.setAttribute('href', address(number)) else link.removeAttribute('href') if (possible) link.removeAttribute('aria-disabled') else link.setAttribute('aria-disabled', 'true') } aim(previous.querySelector('a'), result.page - 1, result.page > 1) aim(next.querySelector('a'), result.page + 1, result.page < result.pages) const numbers = Array.from({ length: result.pages }, (_, index) => { const item = $('#rs-page').content.querySelector('li').cloneNode(true) const link = item.querySelector('a') link.setAttribute('href', address(index + 1)) link.setAttribute('aria-label', `Page ${index + 1}`) link.textContent = String(index + 1) if (index + 1 === result.page) link.setAttribute('aria-current', 'page') return item }) $('#rs-pages').replaceChildren(previous, ...numbers, next) } /** Write the results, the counts and the pages from the form. */ function draw() { const given = query() const chosen = given.getAll('type') const found = search(resources, given.get('q') ?? '', ['title', 'summary']) const rows = sort(found.filter((record) => !chosen.length || chosen.includes(record.type)), ...orders[given.get('sort')]) const result = paginate(rows, page, size) page = result.page const narrowed = chosen.length > 0 || Boolean(given.get('q')?.trim()) $('#rs-count').textContent = !rows.length ? 'No resources match' : rows.length < resources.length ? `${rows.length} of ${resources.length} resources` : `${resources.length} resources` part('clear').hidden = !narrowed // Beside each type, how many of what the search found are of it. for (const count of conditions.querySelectorAll('[data-count]')) count.textContent = String(found.filter((record) => record.type === count.dataset.count).length) part('applied').hidden = chosen.length === 0 part('applied').firstElementChild.textContent = String(chosen.length) part('applied').lastElementChild.textContent = `, ${chosen.length} applied` part('drawer-done').textContent = `Show ${rows.length} ${rows.length === 1 ? 'result' : 'results'}` $('#rs-results').replaceChildren(results(result.rows, given.get('view'))) part('foot').hidden = result.pages === 1 $('#rs-range').textContent = `${result.from}–${result.to} of ${result.total}` pages(result) return result } /** Empty the search and the types, or the types alone, and start from the first page. */ function clear({ text = true } = {}) { if (text) form.elements.q.value = '' for (const box of form.elements.type) box.checked = false page = 1 draw() } // One set of conditions stands where the width puts it: in the sidebar while the Filters button is not // displayed, which the stylesheet decides at 56rem of main region, and in the drawer otherwise. The same // checkboxes move, so nothing is copied and no choice can be lost; each names its form, so it is submitted // from either place. function place() { const wide = getComputedStyle(part('open')).display === 'none' const home = wide ? part('sidebar') : part('drawer') if (conditions.parentElement === home) return const active = root.ownerDocument.activeElement const held = conditions.contains(active) ? active : null // Focus on the drawer's own buttons would go back to the Filters button, which is no longer displayed. const stranded = wide && drawer.open && drawer.contains(active) && !held if (home.moveBefore) home.moveBefore(conditions, null) else home.append(conditions) part('sidebar').hidden = !wide if (wide && drawer.open) drawer.close() ;(held ?? (stranded ? conditions.querySelector('input') : null))?.focus() } part('open').hidden = false place() const observer = new ResizeObserver(place) observer.observe($('#rs-main')) // A field of the form changed, wherever it stands. Only the view keeps the page. root.addEventListener('input', (event) => { if (event.target.form !== form) return if (event.target.name !== 'view') page = 1 say('') draw() }, { signal }) form.addEventListener('submit', (event) => { event.preventDefault() page = 1 draw() }, { signal }) part('clear').addEventListener('click', () => { clear(); form.elements.q.focus() }, { signal }) part('drawer-clear').addEventListener('click', () => clear({ text: false }), { signal }) $('#rs-results').addEventListener('click', (event) => { // A resource's own page is not part of the example. if (event.target.closest('a')) event.preventDefault() if (event.target.closest('[data-results="reset"]')) { clear(); form.elements.q.focus() } }, { signal }) $('#rs-pages').addEventListener('click', (event) => { const link = event.target.closest('a') if (!link) return event.preventDefault() if (!link.hasAttribute('href')) return page = Number(new URLSearchParams(link.search).get('page')) const result = draw() // The link pressed may have lost its address: focus stays on the current page's, without pulling the view back // down to it, and the new page is shown from its first result. $('#rs-pages [aria-current="page"]').focus({ preventScroll: true }) $('#rs-results-title').parentElement.scrollIntoView({ block: 'start' }) say(`Page ${result.page} of ${result.pages}, resources ${result.from} to ${result.to}`) }, { signal }) draw() return () => { controller.abort() observer.disconnect() if (drawer.open) drawer.close() part('sidebar').append(conditions) part('sidebar').hidden = false part('open').hidden = true }}/** * Twelve resources of Atlas, a deployment platform: what the results page searches, narrows and sorts. A real * page asks its server for one page of these and for the count; the rows here stand in for that answer. * `updated` is `YYYY-MM-DD`, so dates sort as text. */export const types = [['guide', 'Guide'], ['template', 'Template'], ['video', 'Video'], ['case-study', 'Case study']]export const resources = [ { id: 'first-project', type: 'guide', title: 'Deploy your first project', summary: 'Connect a repository, push to main and open the address Atlas gives it.', updated: '2026-11-12' }, { id: 'dashboard-tour', type: 'video', title: 'A tour of the new dashboard', summary: 'Four minutes through projects, domains and usage, now on one page.', updated: '2026-11-10' }, { id: 'borealis-builds', type: 'case-study', title: 'How Borealis cut cold builds to under a minute', summary: 'Restoring caches before the install step, measured across forty projects.', updated: '2026-11-06' }, { id: 'astro-blog', type: 'template', title: 'Astro blog starter', summary: 'Posts in Markdown, a feed and a preview deployment for every draft.', updated: '2026-11-03' }, { id: 'rolling-back', type: 'guide', title: 'Roll back without a meeting', summary: 'A deployment never changes, so going back is choosing an earlier one.', updated: '2026-10-29' }, { id: 'build-log', type: 'video', title: 'Reading a build log', summary: 'Where a failed build says what went wrong, and what the timings mean.', updated: '2026-10-24' }, { id: 'incident-runbook', type: 'template', title: 'Incident runbook', summary: 'Who decides, who writes the update and when to roll back, on one page.', updated: '2026-10-20' }, { id: 'custom-domain', type: 'guide', title: 'Move a custom domain to Atlas without downtime, certificates included', summary: 'Lower the record’s lifetime, issue the certificate first, then switch.', updated: '2026-10-15' }, { id: 'cinder-previews', type: 'case-study', title: 'Cinder reviews forty previews a day with a team of six', summary: 'Comments pinned to the page replaced the screenshots in their reviews.', updated: '2026-10-09' }, { id: 'edge-caching', type: 'video', title: 'Edge caching in ten minutes', summary: 'What is cached in each region, for how long, and how a deployment clears it.', updated: '2026-10-02' }, { id: 'launch-checklist', type: 'template', title: 'Launch checklist', summary: 'Domains, redirects, analytics and a rollback plan, to tick off before a launch.', updated: '2026-09-25' }, { id: 'branch-previews', type: 'guide', title: 'Preview every branch', summary: 'Give each branch its own address and protect it with a password.', updated: '2026-09-18' },]/** * The demo's query logic, shared by the filter bar and the table view: conditions on a field, an operator and a * value, all of which a row must meet (one level of AND), plus search, sort and pages. It reads plain rows and * plain fields and touches no element. An application asks its own data source the same questions; this is * not a query engine to publish. * * A field is `{ key, label, type, options? }`: `type` is `text`, `enum`, `number` or `date`, and an enum lists * its `options` as `[value, label]`. A date is `YYYY-MM-DD`, so dates compare as text. *//** The operators each type of field offers, in the order a reader meets them: `[name, words]`. */export const operators = { text: [['contains', 'contains'], ['is', 'is'], ['is-not', 'is not'], ['starts', 'starts with']], enum: [['is', 'is'], ['is-not', 'is not']], number: [['is', 'is'], ['more', 'is more than'], ['less', 'is less than']], date: [['on', 'is on'], ['before', 'is before'], ['after', 'is after']],}/** @param {{ type: keyof typeof operators }} field */export const operatorsOf = (field) => operators[field.type]/** A new condition on a field: its first operator, and a value still to give, even a choice. */export function condition(field) { return { field: field.key, operator: operatorsOf(field)[0][0], value: '' }}/** * What is wrong with a condition, in words, or null when it can be applied. The input's own validity comes first, * so a number field that holds letters is caught as the browser sees it. * @param {{ field: string, operator: string, value: string }} given * @param {{ type: string, label: string, options?: string[][] }} field * @param {ValidityState} [validity] */export function problem(given, field, validity) { if (!field) return 'Choose a field.' if (!operatorsOf(field).some(([name]) => name === given.operator)) return `Choose how ${field.label.toLowerCase()} compares.` const value = String(given.value ?? '').trim() if (validity?.badInput) return field.type === 'date' ? `Enter a whole date for ${field.label.toLowerCase()}.` : `Enter a number for ${field.label.toLowerCase()}.` if (!value) return field.type === 'enum' ? `Choose a ${field.label.toLowerCase()}, or remove the condition.` : `Enter a value for ${field.label.toLowerCase()}, or remove the condition.` if (field.type === 'number' && !Number.isFinite(Number(value))) return `Enter a number for ${field.label.toLowerCase()}.` if (field.type === 'date' && !/^\d{4}-\d{2}-\d{2}$/.test(value)) return `Enter a whole date for ${field.label.toLowerCase()}.` if (field.type === 'enum' && !field.options.some(([option]) => option === value)) return `Choose a ${field.label.toLowerCase()}.` return null}/** Whether a row meets one condition. */function meets(row, given, field) { const have = row[field.key] const want = given.value switch (field.type) { case 'text': { const text = String(have).toLowerCase() const term = String(want).trim().toLowerCase() if (given.operator === 'contains') return text.includes(term) if (given.operator === 'starts') return text.startsWith(term) return given.operator === 'is' ? text === term : text !== term } case 'enum': return given.operator === 'is' ? have === want : have !== want case 'number': { const number = Number(want) if (given.operator === 'more') return have > number if (given.operator === 'less') return have < number return have === number } case 'date': if (given.operator === 'before') return have < want if (given.operator === 'after') return have > want return have === want } return true}/** The rows that meet every condition. */export function filter(rows, conditions, fields) { const keyed = new Map(fields.map((field) => [field.key, field])) return rows.filter((row) => conditions.every((given) => meets(row, given, keyed.get(given.field))))}/** The rows whose given text holds what was typed, without regard to case. */export function search(rows, text, keys) { const term = text.trim().toLowerCase() if (!term) return rows return rows.filter((row) => keys.some((key) => String(row[key]).toLowerCase().includes(term)))}/** The rows in the order of one field, ascending or descending; ties keep the order they had. */export function sort(rows, key, direction = 'ascending') { const sign = direction === 'descending' ? -1 : 1 const compare = (a, b) => typeof a === 'number' ? a - b : String(a).localeCompare(String(b), 'en', { numeric: true }) return [...rows].sort((a, b) => compare(a[key], b[key]) * sign)}/** One page of rows, and where it stands among them. A page past the end is the last one. */export function paginate(rows, page, size) { const pages = Math.max(1, Math.ceil(rows.length / size)) const current = Math.min(Math.max(1, page), pages) const start = (current - 1) * size return { rows: rows.slice(start, start + size), page: current, pages, from: rows.length ? start + 1 : 0, to: Math.min(start + size, rows.length), total: rows.length }}const dates = new Intl.DateTimeFormat('en-US', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' })/** A date as a reader reads it: `Nov 13, 2026`. */export const formatDate = (value) => dates.format(new Date(`${value}T00:00:00Z`))/** A condition in words, for its chip: `Status is Ready`. */export function describe(given, field) { const words = operatorsOf(field).find(([name]) => name === given.operator)?.[1] ?? given.operator const value = field.type === 'enum' ? field.options.find(([option]) => option === given.value)?.[1] ?? given.value : field.type === 'date' ? formatDate(given.value) : field.type === 'text' ? `“${String(given.value).trim()}”` : given.value return `${field.label} ${words} ${value}${field.unit ? ` ${field.unit}` : ''}`}The twelve resources are rows in the example's own file, and its script answers from them. A real page asks its server; wiring it to a server says where.
#How it is built
pageon the frame, one measure inside it. The main region isgrow(1) max-w(1120) mx-auto px-lg, and what the footer holds has the same measure. The navbar runs the full width, and its--navbar-padding-xismax(1.5rem, calc(50% - 33.5rem)): the content's own start, so the brand, the title, the search field and the footer's first word stand on one line at every width.- The search is a form of its own.
<form method="get" role="search">holds the field, namedq, and a submit button. The field is aninput-groupthat grows to the form'smax-w(560); where the field would be narrower than 200px the button goes below it. - The other fields name the form. The type checkboxes, the sort and the Cards / List switch stand outside the
<form>and carryform="rs-form". They are submitted with it wherever they stand, which is what lets the checkboxes move into a drawer. - Two columns from 56rem. The main region is a size container,
container-inline. The body isflex flex-col, and from 56rem of main regionflex-row@container(--4xl): aw(240)column for the conditions, 15rem, and a fluid one for the results,grow(1) basis(0) min-w(0). - A count, a sort and a view on one line. The count is a paragraph with
role="status"that takes the room left, so the sort and the switch stand at the end. The line wraps: on a phone the sort and the switch take a second row, one at each end. - The results are a list either way. As cards, a
<ul class="auto-grid">of cards with--auto-grid-min: 15rem: three across at Desktop, two at Tablet, one at Phone, counted by the grid. As a list, a<ul class="list list-interactive">whose rows are links;mx(-10)sets the rows' words on the column's edge. Six to a page, with the range and a pagination of links under them. - Nothing found is an empty state. It says so, says what to try, and its button clears the search and the types.
#Where the conditions go
There is one set of checkboxes. It is written in the sidebar, and it is moved, not copied.
- From 56rem of main region the conditions are the 15rem column beside the results, and the Filters button is
hidden@container(--4xl). - Below 56rem the column is empty and hidden, the Filters button shows, and it opens a drawer,
dialog dialog-drawerat--dialog-width: 20rem, withcommand="show-modal"andcommandfor. The script puts the<fieldset>in the drawer's body. A badge on the button counts the types that are ticked. - The stylesheet owns the threshold. The script holds no number: when the main region changes size it asks whether the Filters button is displayed and puts the fieldset where that says, in the sidebar or the drawer. Change
--4xlin the markup and the script follows. - Nothing can be lost between widths, because nothing is duplicated: the checkbox ticked in the drawer is the checkbox in the sidebar. There is no second id and no state to copy. If the page grows wide while the drawer is open, the drawer closes and focus stays on the checkbox it was on.
- In the drawer a choice applies at once. The results change behind it, the confirming button says how many there are, "Show 4 results", and closes it. Clear unticks the types and leaves the search alone.
Without the script the fieldset stays where it is written, above the results below 56rem and beside them from there, and the Filters button, which would open an empty drawer, stays hidden.
#Wiring it to a server
The markup is what a server would send for the first page: six results, the count, and pagination links. Everything a reader can set is a named field of one GET form, so the URL is the state.
- The query. Submitting sends
?q=build&type=guide&type=video&sort=name&view=list.typerepeats, once for each ticked box;sortisupdatedorname;viewiscardsorlist. The form has noaction, so it submits to the page's own address. - The pages. Each pagination link is the same query with
pageadded,?sort=name&view=list&page=2. The link of the current page hasaria-current="page"; "Previous" on the first page and "Next" on the last have nohrefandaria-disabled="true". - What the server renders. The fields with the values it read (
valueon the search,checkedon the boxes and the view,selectedon the sort), the results of that page, the count, and its own empty state when nothing matches. A changed condition is a new query withoutpage, which is the first page. - What the script adds. It answers as the reader types or ticks, without a round trip, keeps the page number, moves the conditions into the drawer, and reveals what only it can work: the Filters button and "Clear all". It reads the conditions from the form each time,
new FormData(form), and keeps no copy of them; the page number is the one thing it holds. A project that keeps the script points itsdraw()at a request for that query and writes the same query to the address withhistory.replaceState, so a reload or a shared link shows the same results.
The example imports search, sort and paginate from the filter bar's query.js, which stand in for that request. They are part of the demonstration, not of @master/ui: the library publishes no query engine.
#When to use it
- Use a results page when the things found are read one at a time and each has a page of its own: articles, guides, templates, listings, people.
- Use a table view when the rows are compared across columns, selected and acted on in bulk. It is a block inside an application's page, with its own search, sort and pages.
- Use a filter bar when a condition is a field, a comparison and a value, and several are combined. A sidebar of checkboxes suits a few fixed groups that are always worth showing.
- Use a dashboard when the page summarizes: figures and charts first, and a list only as the way in.
#Accessibility
- The landmarks are the header with its
Mainnavigation, the main region, the search form, namedResources, thePaginationnavigation, and the footer with its own. The first link is a skip link to the main region, which hastabindex="-1". - Source order is reading order at every width: title, search, conditions, count and sort, results, pages. The drawer is written last in the main region and is in nobody's way until it opens.
- The types are a
<fieldset>with a<legend>; each count is in its checkbox's label. The Cards / List switch is aradiogroupof native radios, and the sort a native<select>with a label. - The count has
role="status", so a change of conditions is announced without moving focus: "4 of 12 resources", or "No resources match". A second, visually hidden status says the page and the range after a pagination link is pressed, and focus stays on the current page's link. - The results are under a visually hidden
<h2>, "Results", and each title is an<h3>, so a reader can jump to the results and from one to the next. A card's title is its link,card-link, and the whole card is its target. - The drawer is a native modal
<dialog>named by its title. Focus goes to the first checkbox when it opens; Esc, a press outside (closedby="any"), the close button and "Show results" close it, and focus returns to the Filters button. The button's name says how many filters are applied. - "Clear all" and the empty state's button remove themselves when pressed, so focus goes to the search field.
#Related
- NavbarThe bar at the top of a page, which takes its material once content scrolls under it.
- Skip linkThe first link of a page, shown while it has focus, that jumps past the navigation.
- HeadingA title in the ink of the page, with the line over it and the paragraph under it.
- InputText fields cut into the surface, with labels, hints, errors and groups.
- ButtonA raised control that lifts on hover and sinks when pressed.
- CheckboxA small native well that fills with ink when checked.
- SelectA native select whose option list is drawn in the same material.
- Segmented controlA few options in one well; a sheet glides to the current one.
- BadgeA small chip for a status, a category or a count.
- Auto gridAs many equal columns as fit, counted by the grid itself.
- CardA raised sheet whose parts follow the room the card is given.
- ListRows of things with media, words and something at the end.
- PaginationThe pages of a long list, as a row of links.
- EmptyWhat a view shows when it has nothing to show yet.
- Icon frameA small well that holds an icon at its size beside a heading.
- DialogA native modal on an overlay sheet, opened and closed without script.
- MenuA list of actions in a popover, placed against its button.
- LinkText that goes somewhere, in the ink of its sentence.
- HeaderA site header: the brand, the links, the actions and a drawer for narrow screens.
- Filter barConditions to narrow a list, staged, applied and shown as chips.
- Table viewA table with its search, filters, selection and pages.
- Article listArticles, resources or case studies: a picture, a summary, who wrote it and the way in.
- Empty stateWhat a view shows before it has anything, and how to begin.
- FooterWhere a site ends: columns of quiet links and the small print.