From 000a1e8a33ac3f1dea00ca21aac0f1771a0325f0 Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Thu, 20 Feb 2025 16:09:08 +0100 Subject: frontend: Rework and improve accelerators This commit switches around a couple of existing accelerators to make them easier to activate with just the left hand on the keyboard and more easily allow the addition of accelerators for all filter fields. --- docs/usage/shortcuts.rst | 58 ++++++++++++++++++++-- frontend/src/lib/Shortcuts.ts | 2 +- frontend/src/lib/filter/ComicFilterForm.svelte | 43 +++++++++------- frontend/src/lib/filter/TagFilterForm.svelte | 7 ++- frontend/src/lib/filter/components/Filter.svelte | 6 ++- frontend/src/lib/toolbar/FilterOrganized.svelte | 2 +- frontend/src/lib/toolbar/Search.svelte | 2 +- .../src/lib/toolbar/ToggleAdvancedFilters.svelte | 3 ++ 8 files changed, 94 insertions(+), 29 deletions(-) diff --git a/docs/usage/shortcuts.rst b/docs/usage/shortcuts.rst index 3f532e2..d261c00 100644 --- a/docs/usage/shortcuts.rst +++ b/docs/usage/shortcuts.rst @@ -92,16 +92,68 @@ Filtering * - Shortcut - Action - * - ``F`` + * - ``q`` - Focus search. * - ``f`` - Toggle favourites. * - ``b`` - Toggle bookmarked. - * - ``o`` - - Toggle organized. * - ``r`` - Toggle orphaned. + * - ``z`` + - Toggle organized. + +.. _shortcut-advanced-filtering: + +Advanced Filtering +------------------ + +.. list-table:: + :align: left + :header-rows: 1 + + * - Shortcut + - Action + * - ``F`` + - Toggle advanced filters. + * - ``X`` + - Reset filters. + +Focusing filter fields +^^^^^^^^^^^^^^^^^^^^^^ + +When the advanced filters are visible, each field may be focused by activating +the following shortcuts prefixed by either ``i`` for an include field or ``e`` +for an exclude field. For example, to include an artist, hit ``ia``. + +.. list-table:: + :align: left + :header-rows: 1 + + * - Shortcut + - Filters on... + * - ``n`` + - Namespaces + * - ``t`` + - Tags + * - ``a`` + - Artists + * - ``i`` + - Circles + * - ``h`` + - Characters + * - ``w`` + - Worlds + * - ``g`` + - Categories + * - ``r`` + - Ratings + * - ``s`` + - Censorships + * - ``l`` + - Languages + * - ``u`` + - URLs .. _shortcut-misc: diff --git a/frontend/src/lib/Shortcuts.ts b/frontend/src/lib/Shortcuts.ts index 1ff7679..82f19ac 100644 --- a/frontend/src/lib/Shortcuts.ts +++ b/frontend/src/lib/Shortcuts.ts @@ -31,7 +31,7 @@ type UppercaseLetter = Uppercase; type Letter = LowercaseLetter | UppercaseLetter; type Special = '?' | 'Enter' | 'Escape' | 'Delete'; -const modeSwitches = ['n', 'g', 'i'] as const; +const modeSwitches = ['n', 'g', 'i', 'e'] as const; type ModeSwitch = (typeof modeSwitches)[number]; function isModeSwitch(s: string): s is ModeSwitch { diff --git a/frontend/src/lib/filter/ComicFilterForm.svelte b/frontend/src/lib/filter/ComicFilterForm.svelte index 331d571..4c6e2d2 100644 --- a/frontend/src/lib/filter/ComicFilterForm.svelte +++ b/frontend/src/lib/filter/ComicFilterForm.svelte @@ -2,6 +2,7 @@ import { artistList, characterList, circleList, comicTagList, worldList } from '$gql/Queries'; import { categories, censorships, languages, ratings } from '$lib/Enums'; import { ComicFilterContext } from '$lib/Filter.svelte'; + import { accelerator } from '$lib/Shortcuts'; import { getContextClient } from '@urql/svelte'; import Filter from './components/Filter.svelte'; import FilterForm from './components/FilterForm.svelte'; @@ -21,38 +22,42 @@ let characters = $derived($charactersQuery.data?.characters.edges); let circles = $derived($circlesQuery.data?.circles.edges); let worlds = $derived($worldsQuery.data?.worlds.edges); + + let inc = $derived(filter.include); + let exc = $derived(filter.exclude); {#snippet include(type)} - - - - - - - - - + + + + + + + + +
{/snippet} {#snippet exclude(type)} - - - - - - - - - + + + + + + + + + {/snippet}
diff --git a/frontend/src/lib/filter/TagFilterForm.svelte b/frontend/src/lib/filter/TagFilterForm.svelte index 1ca1a2d..c514163 100644 --- a/frontend/src/lib/filter/TagFilterForm.svelte +++ b/frontend/src/lib/filter/TagFilterForm.svelte @@ -11,13 +11,16 @@ let namespaceQuery = $derived(namespaceList(client)); let namespaces = $derived($namespaceQuery.data?.namespaces.edges); + + let inc = $derived(filter.include); + let exc = $derived(filter.exclude); {#snippet include(type)} - + {/snippet} {#snippet exclude(type)} - + {/snippet} diff --git a/frontend/src/lib/filter/components/Filter.svelte b/frontend/src/lib/filter/components/Filter.svelte index 832ac19..4ebbd7f 100644 --- a/frontend/src/lib/filter/components/Filter.svelte +++ b/frontend/src/lib/filter/components/Filter.svelte @@ -1,5 +1,6 @@