From b83e535010139ad47efbad6c8e37dc0895c60b9b Mon Sep 17 00:00:00 2001 From: martin <74269598+martabal@users.noreply.github.com> Date: Mon, 24 Jul 2023 04:09:06 +0200 Subject: [PATCH] feat(web): show available shortcuts (#3342) * feat(web): show available shortcuts * pr feeback * feat: new shortcut for deselect * fix: remove new shortcut * responsive --- .../components/photos-page/asset-grid.svelte | 9 +++ .../shared-components/show-shortcuts.svelte | 79 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 web/src/lib/components/shared-components/show-shortcuts.svelte diff --git a/web/src/lib/components/photos-page/asset-grid.svelte b/web/src/lib/components/photos-page/asset-grid.svelte index db8f232b57..ae4673e0bd 100644 --- a/web/src/lib/components/photos-page/asset-grid.svelte +++ b/web/src/lib/components/photos-page/asset-grid.svelte @@ -30,6 +30,7 @@ import { goto } from '$app/navigation'; import { browser } from '$app/environment'; import { isSearchEnabled } from '$lib/stores/search.store'; + import ShowShortcuts from '../shared-components/show-shortcuts.svelte'; export let user: UserResponseDto | undefined = undefined; export let isAlbumSelectionMode = false; @@ -39,6 +40,7 @@ let viewportWidth = 0; let assetGridElement: HTMLElement; let bucketInfo: AssetCountByTimeBucketResponseDto; + let showShortcuts = false; const onKeyboardPress = (event: KeyboardEvent) => handleKeyboardPress(event); @@ -93,6 +95,9 @@ if (!$isViewingAssetStoreState) { switch (event.key) { + case '?': + if (event.shiftKey) showShortcuts = !showShortcuts; + return; case '/': goto(AppRoute.EXPLORE); return; @@ -290,6 +295,10 @@ +{#if showShortcuts} + (showShortcuts = !showShortcuts)} /> +{/if} + {#if bucketInfo && viewportHeight && $assetGridState.timelineHeight > viewportHeight} + import Close from 'svelte-material-icons/Close.svelte'; + import CircleIconButton from '../elements/buttons/circle-icon-button.svelte'; + import { createEventDispatcher } from 'svelte'; + + const shortcuts = { + general: [ + { key: ['←', '→'], action: 'Previous or next photo' }, + { key: ['Esc'], action: 'Back, close, or deselect' }, + { key: ['/'], action: 'Search your photos' }, + ], + actions: [ + { key: ['f'], action: 'Favorite or unfavorite photo' }, + { key: ['i'], action: 'Show or hide info' }, + { key: ['⇧', 'a'], action: 'Archive or unarchive photo' }, + { key: ['⇧', 'd'], action: 'Download' }, + { key: ['Space'], action: 'Play or pause video' }, + { key: ['Del'], action: 'Delete Asset' }, + ], + }; + const dispatch = createEventDispatcher(); + + +
+
+
+
+

Keyboard Shortcuts

+
+ dispatch('close')} /> +
+
+ +
+
+

General

+
+ {#each shortcuts.general as shortcut} +
+
+ {#each shortcut.key as key} +

+ {key} +

+ {/each} +
+

{shortcut.action}

+
+ {/each} +
+
+ +
+

Actions

+
+ {#each shortcuts.actions as shortcut} +
+
+ {#each shortcut.key as key} +

+ {key} +

+ {/each} +
+

{shortcut.action}

+
+ {/each} +
+
+
+
+
+