import { Show } from "solid-js"; import type { Refs } from "../lib/refs"; /** * Narrowing the sidebar down. * * A `search` input rather than a plain text one: it carries the right * semantics, and browsers give it a clear affordance for free. Escape is * handled explicitly because whether it clears the field is left to the * browser otherwise, and WebKit and Chromium do not agree. */ export default function RefFilter(props: { refs: Refs }) { function onKeyDown(event: KeyboardEvent) { if (event.key !== "Escape") return; event.preventDefault(); props.refs.setQuery(""); } return (
props.refs.setQuery(event.currentTarget.value)} onKeyDown={onKeyDown} class="w-full rounded-small border border-outline bg-surface px-2 py-1 text-body-sm text-on-surface focus-visible:outline-2 focus-visible:outline-offset-[-1px] focus-visible:outline-primary" /> {/* An is a polite live region, so the result of typing is announced without stealing focus from the field. */} {props.refs.counts().matched} of {props.refs.counts().total} match
); }