diff --git a/icons.config.js b/icons.config.js index ded6d2a4..8456c7ec 100644 --- a/icons.config.js +++ b/icons.config.js @@ -79,6 +79,7 @@ const config = { "palette", "translate", "smart_toy", + "visibility_off", "play_arrow", "extension", "upload_file", @@ -165,6 +166,7 @@ const config = { routine: "e20c", experiment: "e686", dictionary: "f539", + visibility_off: "e8f5", }, }; diff --git a/src/lib/ProgressButton.svelte b/src/lib/ProgressButton.svelte new file mode 100644 index 00000000..7d09e275 --- /dev/null +++ b/src/lib/ProgressButton.svelte @@ -0,0 +1,121 @@ + + + + + diff --git a/src/lib/components/Action.svelte b/src/lib/components/Action.svelte index b4f6b1d6..281d4564 100644 --- a/src/lib/components/Action.svelte +++ b/src/lib/components/Action.svelte @@ -3,11 +3,14 @@ import type { KeyInfo } from "$lib/serial/keymap-codes"; import { osLayout } from "$lib/os-layout"; import { tooltip } from "$lib/hover-popover"; + import { isVerbose } from "./verbose-action"; + import { actionTooltip } from "$lib/title"; let { action, display, - }: { action: number | KeyInfo; display: "inline-keys" | "keys" } = $props(); + }: { action: number | KeyInfo; display: "inline-keys" | "keys" | "verbose" } = + $props(); let info = $derived( typeof action === "number" @@ -15,52 +18,56 @@ : action, ); let dynamicMapping = $derived(info.keyCode && $osLayout.get(info.keyCode)); - - let popover: HTMLElement | undefined = $state(undefined); + let hasPopover = $derived(!info.id || info.title || info.description); -{#snippet popoverSnippet()} -
{@html title}
+{:else} + {@render title?.()} {/if} {#if shortcut} diff --git a/src/lib/components/layout/ActionSelector.svelte b/src/lib/components/layout/ActionSelector.svelte index 9a950a5e..6c134299 100644 --- a/src/lib/components/layout/ActionSelector.svelte +++ b/src/lib/components/layout/ActionSelector.svelte @@ -11,6 +11,9 @@ import LL from "$i18n/i18n-svelte"; import { action } from "$lib/title"; import { get } from "svelte/store"; + import type { KeymapCategory } from "$lib/meta/types/actions"; + import Action from "../Action.svelte"; + import { isVerbose } from "../verbose-action"; let { currentAction = undefined, @@ -26,6 +29,7 @@ onMount(() => { searchBox.focus(); + search(); }); const index = new FlexSearch.Index({ tokenize: "full" }); @@ -46,7 +50,29 @@ } async function search() { - results = (await index!.searchAsync(searchBox.value)) as number[]; + const groups = new Map( + $KEYMAP_CATEGORIES.map( + (category) => [category, []] as [KeymapCategory, KeyInfo[]], + ), + ); + const result = + searchBox.value === "" + ? Array.from($KEYMAP_CODES.keys()) + : await index!.searchAsync(searchBox.value); + for (const id of result) { + const action = $KEYMAP_CODES.get(id as number); + if (action?.category) { + groups.get(action.category)?.push(action); + } + } + + function sortValue(action: KeyInfo): number { + return isVerbose(action) ? 0 : action.id?.length === 1 ? 2 : 1; + } + for (const actions of groups.values()) { + actions.sort((a, b) => sortValue(b) - sortValue(a)); + } + results = groups; exact = get(KEYMAP_IDS).get(searchBox.value)?.code; code = Number(searchBox.value); } @@ -81,13 +107,12 @@ event.preventDefault(); } - let results: number[] = $state([]); + let results: Map