검색 결과 페이지는 검색에 답하는 페이지입니다. 검색어를 입력하는 필드, 찾은 결과를 좁히는 조건, 결과 개수, 정렬, 페이지로 나눈 결과로 구성됩니다. 헤더, 메인 영역, 푸터로 이루어진 페이지 프레임 위에 구성하며 문서 전체가 함께 스크롤됩니다. 조건은 공간이 있으면 결과 옆에 놓이고, 공간이 없으면 드로어 안에서 대기합니다.
검색 결과
<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}` : ''}`}“build”를 검색한 뒤 검색어를 지워 보세요. 이름순으로 정렬하고 두 번째 페이지로 이동한 다음 List로 전환해도 정렬과 페이지는 그대로 유지됩니다. 태블릿이나 휴대폰을 선택해 Filters를 열고 유형 하나를 체크한 뒤 데스크톱을 선택하면 사이드바에서도 체크되어 있습니다. 없는 내용을 검색하면 빈 상태를 볼 수 있습니다.
리소스 열두 개는 예제 자체 파일에 있는 행이며, 예제의 스크립트가 이 데이터로 응답합니다. 실제 페이지는 서버에 요청합니다. 그 지점은 서버와 연결하기에서 설명합니다.
#구성 방법
- 프레임에
page, 그 안에 하나의 너비 제한. 메인 영역은grow(1) max-w(1120) mx-auto px-lg이고, 푸터 내부 콘텐츠도 같은 너비 제한을 사용합니다. 내비게이션 바는 전체 너비를 차지하며,--navbar-padding-x는max(1.5rem, calc(50% - 33.5rem))입니다. 이는 콘텐츠가 시작하는 위치와 같으므로 브랜드, 제목, 검색 필드, 푸터의 첫 단어가 모든 너비에서 같은 선에 놓입니다. - 검색은 독립된 폼입니다.
<form method="get" role="search">에 이름이q인 필드와 제출 버튼이 있습니다. 필드는 폼의max-w(560)까지 늘어나는input-group이며, 필드가 200px보다 좁아질 상황에서는 버튼이 필드 아래로 내려갑니다. - 나머지 필드는 폼을 가리킵니다. 유형 체크박스, 정렬, Cards / List 전환 컨트롤은
<form>밖에 있으며form="rs-form"을 가집니다. 어디에 놓이든 폼과 함께 제출되므로 체크박스를 드로어로 옮길 수 있습니다. - 56rem부터 두 열. 메인 영역은 크기 컨테이너인
container-inline입니다. 조건과 결과를 담는 부분은flex flex-col이고, 메인 영역의 너비가 56rem 이상이면flex-row@container(--4xl)이 됩니다. 조건을 담는 열은w(240), 즉 15rem이고, 결과를 담는 열은grow(1) basis(0) min-w(0)인 가변 너비입니다. - 개수, 정렬, 보기 전환을 한 줄에. 개수는
role="status"가 있는 문단으로 남은 공간을 차지하므로 정렬과 전환 컨트롤은 끝에 놓입니다. 이 줄은 줄바꿈됩니다. 휴대폰에서는 정렬과 전환 컨트롤이 둘째 줄로 내려가 양쪽 끝에 하나씩 놓입니다. - 결과는 어느 보기에서든 목록입니다. 카드 보기에서는
--auto-grid-min: 15rem을 지정한, 카드의<ul class="auto-grid">입니다. 한 줄에 데스크톱에서는 세 개, 태블릿에서는 두 개, 휴대폰에서는 한 개가 놓이며, 이 개수는 그리드가 계산합니다. 목록 보기에서는 행이 링크인<ul class="list list-interactive">이며,mx(-10)으로 행의 텍스트를 열의 가장자리에 맞춥니다. 한 페이지에 여섯 개씩 표시하고, 그 아래에 범위와 링크로 된 페이지네이션을 둡니다. - 찾은 것이 없으면 빈 상태를 표시합니다. 결과가 없음을 알리고 무엇을 시도할지 안내하며, 버튼은 검색어와 유형을 지웁니다.
#조건의 위치
체크박스 묶음은 하나뿐입니다. 사이드바에 작성되어 있으며, 복사하지 않고 옮깁니다.
- 메인 영역의 너비가 56rem 이상이면 조건은 결과 옆의 15rem 열이고, Filters 버튼은
hidden@container(--4xl)입니다. - 56rem 미만이면 이 열은 비어서 숨겨지고 Filters 버튼이 표시됩니다. 이 버튼은
command="show-modal"과commandfor로 드로어를 엽니다. 드로어는--dialog-width: 20rem을 지정한dialog dialog-drawer입니다. 스크립트가<fieldset>을 드로어의 본문에 넣습니다. 버튼의 배지는 체크된 유형의 개수를 표시합니다. - 기준 너비는 스타일시트가 정합니다. 스크립트에는 숫자가 없습니다. 메인 영역의 크기가 바뀌면 Filters 버튼이 표시되는지 확인하고, 그 결과에 따라 fieldset을 사이드바나 드로어에 둡니다. 마크업에서
--4xl을 바꾸면 스크립트도 따라갑니다. - 너비가 바뀌어도 잃는 것이 없습니다. 중복된 것이 없기 때문입니다. 드로어에서 체크한 체크박스가 곧 사이드바의 체크박스입니다. 두 번째 id도, 복사할 상태도 없습니다. 드로어가 열린 채 페이지가 넓어지면 드로어가 닫히고 포커스는 원래 있던 체크박스에 그대로 남습니다.
- 드로어에서는 선택이 바로 적용됩니다. 드로어 뒤에서 결과가 바뀌고, 확인 버튼은 "Show 4 results"처럼 결과 개수를 알려 주며 드로어를 닫습니다. Clear는 유형의 체크를 해제하고 검색어는 그대로 둡니다.
스크립트가 없으면 fieldset은 작성된 자리에 남아 56rem 미만에서는 결과 위에, 그 이상에서는 결과 옆에 놓이며, 빈 드로어를 열게 될 Filters 버튼은 hidden 상태로 남습니다.
#서버와 연결하기
마크업은 서버가 첫 페이지에 대해 보낼 내용 그대로입니다. 결과 여섯 개, 개수, 페이지네이션 링크입니다. 사용자가 설정할 수 있는 모든 것이 하나의 GET 폼에 속한, 이름이 있는 필드이므로 URL이 곧 상태입니다.
- 쿼리. 제출하면
?q=build&type=guide&type=video&sort=name&view=list가 전송됩니다.type은 체크된 상자마다 한 번씩 반복되고,sort는updated또는name,view는cards또는list입니다. 폼에action이 없으므로 페이지 자신의 주소로 제출됩니다. - 페이지. 각 페이지네이션 링크는 같은 쿼리에
page를 더한 것으로,?sort=name&view=list&page=2와 같습니다. 현재 페이지의 링크에는aria-current="page"가 있고, 첫 페이지의 "Previous"와 마지막 페이지의 "Next"에는href가 없고aria-disabled="true"가 있습니다. - 서버가 렌더링하는 것. 읽은 값을 반영한 필드(검색 필드의
value, 체크박스와 보기의checked, 정렬의selected), 해당 페이지의 결과, 개수, 그리고 일치하는 것이 없을 때의 빈 상태입니다. 조건이 바뀌면page가 없는 새 쿼리가 되며, 이는 첫 페이지입니다. - 스크립트가 더하는 것. 사용자가 입력하거나 체크하는 대로 서버 왕복 없이 응답하고, 페이지 번호를 유지하고, 조건을 드로어로 옮기며, 스크립트가 있어야만 작동하는 Filters 버튼과 "Clear all"을 표시합니다. 조건은 매번
new FormData(form)으로 폼에서 읽으며 사본을 두지 않습니다. 스크립트가 보관하는 것은 페이지 번호뿐입니다. 이 스크립트를 유지하는 프로젝트에서는draw()가 해당 쿼리로 요청을 보내게 하고history.replaceState로 같은 쿼리를 주소에 기록하세요. 그러면 새로 고치거나 링크를 공유해도 같은 결과가 표시됩니다.
예제는 필터 바의 query.js에서 search, sort, paginate를 가져오며, 이 함수들이 그 요청을 대신합니다. 이들은 데모의 일부이며 @master/ui의 일부가 아닙니다. 라이브러리는 쿼리 엔진을 제공하지 않습니다.
#사용 기준
- 검색 결과 페이지는 찾은 항목을 하나씩 읽고 각 항목에 자체 페이지가 있을 때 사용하세요. 아티클, 가이드, 템플릿, 매물이나 공고 같은 등록 정보, 사람 등이 해당합니다.
- 테이블 뷰는 행을 열끼리 비교하고, 선택해서 일괄 처리할 때 사용하세요. 애플리케이션의 페이지 안에 넣는 블록이며 자체 검색, 정렬, 페이지를 갖습니다.
- 필터 바는 조건 하나가 필드, 비교, 값으로 이루어지고 여러 조건을 조합할 때 사용하세요. 체크박스 사이드바는 항상 보여 줄 만한 몇 개의 고정된 그룹에 적합합니다.
- 대시보드는 페이지가 요약을 보여 줄 때 사용하세요. 수치와 차트가 먼저이고, 목록은 더 들어가는 입구로만 둡니다.
#접근성
- 랜드마크는
Main내비게이션이 있는 헤더, 메인 영역, 이름이Resources인 검색 폼,Pagination내비게이션, 자체 내비게이션이 있는 푸터입니다. 첫 번째 링크는tabindex="-1"이 지정된 메인 영역으로 이동하는 건너뛰기 링크입니다. - 소스 순서는 모든 너비에서 읽는 순서와 같습니다. 제목, 검색, 조건, 개수와 정렬, 결과, 페이지 순입니다. 드로어는 메인 영역의 마지막에 작성되어 있어 열리기 전에는 아무것도 가로막지 않습니다.
- 유형은
<legend>가 있는<fieldset>이며, 각 개수는 해당 체크박스의 레이블 안에 있습니다. Cards / List 전환 컨트롤은 네이티브 라디오 버튼으로 된radiogroup이고, 정렬은 레이블이 있는 네이티브<select>입니다. - 개수에는
role="status"가 있으므로 조건이 바뀌면 포커스를 옮기지 않고 "4 of 12 resources" 또는 "No resources match"라고 안내합니다. 시각적으로 숨긴 두 번째 상태 영역은 페이지네이션 링크를 누른 뒤 페이지와 범위를 알리며, 포커스는 현재 페이지의 링크에 남습니다. - 결과는 시각적으로 숨긴
<h2>인 "Results" 아래에 있고 각 제목은<h3>이므로, 사용자는 결과로 바로 이동하거나 한 결과에서 다음 결과로 건너갈 수 있습니다. 카드의 제목이 곧 링크인card-link이며, 카드 전체가 그 링크의 클릭 영역입니다. - 드로어는 제목으로 이름을 지정한 네이티브 모달
<dialog>입니다. 열리면 포커스가 첫 번째 체크박스로 이동합니다. Esc 키, 바깥쪽 누르기(closedby="any"), 닫기 버튼, "Show results"로 닫을 수 있고, 닫히면 포커스가 Filters 버튼으로 돌아갑니다. 버튼의 이름은 적용된 필터의 개수를 알려 줍니다. - "Clear all"과 빈 상태의 버튼은 누르면 스스로 사라지므로 포커스는 검색 필드로 이동합니다.
#관련 항목
- 내비게이션 바스크롤하는 콘텐츠가 막대 아래를 지나갈 때 표면 효과가 나타나는 페이지 상단의 막대입니다.
- 건너뛰기 링크포커스를 받았을 때 표시되며 탐색 영역을 건너뛰는 페이지의 첫 번째 링크입니다.
- 제목페이지의 기본 글자색으로 표시하는 제목과 제목 위 안내 문구, 아래 소개 문단입니다.
- 입력 필드표면을 파낸 듯한 텍스트 입력 필드와 레이블, 힌트, 오류, 입력 그룹.
- 버튼표면 위로 살짝 돌출되어 있으며, 포인터를 올리면 떠오르고 누르면 가라앉는 버튼입니다.
- 체크박스선택하면 잉크 색으로 채워지는 작은 오목한 영역 형태의 네이티브 입력 요소입니다.
- 셀렉트인터페이스의 다른 부분과 같은 표면 스타일로 옵션 목록을 표시하는 네이티브 셀렉트입니다.
- 세그먼트 컨트롤하나의 오목한 영역에 몇 가지 옵션을 배치하고, 솟아오른 표면이 현재 옵션으로 부드럽게 이동합니다.
- 배지상태, 카테고리 또는 개수를 표시하는 작은 칩입니다. 색에 의미가 있을 때만 색을 사용합니다.
- 자동 그리드그리드가 주어진 공간에 들어갈 수 있는 같은 너비의 열 수를 직접 정합니다.
- 카드카드에 주어진 공간에 따라 내부 배치가 달라지는, 살짝 떠 있는 시트입니다.
- 목록이미지나 아이콘, 텍스트, 끝에 놓이는 요소로 구성된 행을 나열합니다.
- 페이지네이션긴 목록의 페이지를 한 줄의 링크로 보여 주며, 현재 페이지는 눌린 상태로 표시합니다.
- 빈 상태뷰에 아직 표시할 내용이 없을 때 나타나는 상태입니다.
- 아이콘 프레임제목 옆에 아이콘을 크기에 맞게 담는 작은 오목한 영역입니다.
- 대화 상자스크립트 없이 열고 닫는 오버레이 시트 형태의 네이티브 모달입니다.
- 메뉴버튼에 맞춰 배치되며 작업 목록을 담는 팝오버입니다.
- 링크문장 속에서 주변 텍스트와 같은 색으로 표시되며 다른 위치로 이동하는 텍스트입니다.