Skip to content

Commit 87936d1

Browse files
committed
feat: add NpmPackageSearchButton
1 parent 33a49a8 commit 87936d1

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<script lang="ts">
2+
import { onMount } from "svelte";
3+
import LucideSearch from "~icons/lucide/search";
4+
5+
let shortcut = $state("Ctrl+Shift+F");
6+
7+
onMount(() => {
8+
if (navigator.userAgent.includes("Mac")) {
9+
shortcut = "⇧⌘F";
10+
}
11+
});
12+
13+
function openNpmSearchDialog() {
14+
const dialog = document.querySelector<HTMLDialogElement>("#npm-search-dialog");
15+
if (!dialog || dialog.open) return;
16+
dialog.showModal();
17+
}
18+
</script>
19+
20+
<div class="contents md:hidden">
21+
<button
22+
type="button"
23+
class="btn-sm-icon-outline"
24+
title="Search npm packages"
25+
onclick={openNpmSearchDialog}
26+
>
27+
<LucideSearch class="size-4" />
28+
</button>
29+
</div>
30+
31+
<div class="hidden md:contents">
32+
<button
33+
type="button"
34+
class="btn-sm-outline"
35+
title="Search npm packages"
36+
onclick={openNpmSearchDialog}
37+
>
38+
<LucideSearch class="size-4" />
39+
<span>Search npm packages</span>
40+
<kbd class="kbd">{shortcut}</kbd>
41+
</button>
42+
</div>

0 commit comments

Comments
 (0)