app/components/search-trigger.tsx
40 lines and 1 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.
Functions
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| SearchTrigger | 17 to 43 | 1 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
Imports
It imports app/components/enhance.tsx, app/components/theme-toggle.tsx. Imported by app/components/site-header.tsx.
Source
import { Link } from "react-router";
import { ENHANCE_URLS } from "~/components/enhance";
import { HeaderTip } from "~/components/theme-toggle";
import paletteDialogCss from "~/styles/palette-dialog.css?url";
import askCss from "~/styles/ask.css?url";
/**
* The shortcut hint ships `hidden` and `theme.ts` unhides it once the listener is attached, so a
* reader without script is never promised a shortcut. `data-palette` sits on the trigger, not the
* document, so a page without this component has no palette rather than a broken one. The URL is
* the palette bundle's, fetched on the gesture, never a <script> on the page.
*/
// One constant for the id, because a mismatched `aria-describedby` stops being announced silently.
const HINT_ID = "search-shortcut-hint";
export function SearchTrigger() {
return (
<>
<Link
to="/search"
className="cap-site-header-icon search-trigger"
data-search-trigger=""
data-palette={ENHANCE_URLS.palette}
data-palette-css={`${paletteDialogCss},${askCss}`}
aria-label="Search"
aria-describedby={HINT_ID}
>
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<circle cx="11" cy="11" r="7" />
<path d="M20 20l-3.5-3.5" />
</svg>
{/* No keys here: theme.ts adds the platform's once it is listening for them. */}
<HeaderTip text="Search" />
</Link>
{/* Outside the anchor, or it would join the link's own content. */}
{/* A placeholder: the chord is platform-dependent, so `theme.ts` writes the real text before it unhides this. */}
<span id={HINT_ID} className="sr-only" data-search-hint="" hidden>
Search
</span>
</>
);
}