Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/SantaClaas/gigit. git client
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import { 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 ( <div class="mb-3"> <label for="ref-filter" class="sr-only"> Filter references </label> <input id="ref-filter" type="search" placeholder="Filter…" spellcheck={false} autocapitalize="off" autocorrect="off" value={props.refs.query()} onInput={(event) => 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 <output> is a polite live region, so the result of typing is announced without stealing focus from the field. */} <output class="block px-1 pt-1 text-label-sm text-on-surface-variant"> <Show when={props.refs.isFiltering()}> {props.refs.counts().matched} of {props.refs.counts().total} match </Show> </output> </div> );}