From bb359cde476d7201eabf5b619110f3056d4eca6f Mon Sep 17 00:00:00 2001 From: Camden Cheek Date: Fri, 14 Jun 2024 00:12:48 -0600 Subject: [PATCH] Svelte: implement keyboard shortcut design (#63253) --- .../src/lib/KeyboardShortcut.svelte | 41 +++++++++++++------ .../web-sveltekit/src/lib/TabsHeader.svelte | 11 +---- .../src/lib/codemirror/SearchPanelView.svelte | 2 +- .../lib/search/dynamicFilters/Sidebar.svelte | 37 ++++------------- .../src/lib/search/input/ActionInfo.svelte | 34 ++++----------- .../src/lib/search/input/Suggestions.svelte | 8 +++- .../(validrev)/(code)/+layout.svelte | 2 +- .../(code)/RepositoryRevPickerItem.svelte | 2 +- client/web-sveltekit/src/routes/styles.scss | 18 -------- 9 files changed, 54 insertions(+), 101 deletions(-) diff --git a/client/web-sveltekit/src/lib/KeyboardShortcut.svelte b/client/web-sveltekit/src/lib/KeyboardShortcut.svelte index 5d73fa9933e..dc121bb1c13 100644 --- a/client/web-sveltekit/src/lib/KeyboardShortcut.svelte +++ b/client/web-sveltekit/src/lib/KeyboardShortcut.svelte @@ -5,14 +5,14 @@ A component to display the keyboard shortcuts for the application. import { isMacPlatform } from '$lib/common' import { formatShortcutParts, type Keys } from '$lib/Hotkey' - export let shorcut: Keys + export let shortcut: Keys export let inline: boolean = false const separator = isMacPlatform() ? '' : '+' $: parts = (() => { const result: string[] = [] - let parts = formatShortcutParts(shorcut) + let parts = formatShortcutParts(shortcut) for (let i = 0; i < parts.length; i++) { if (i > 0) { result.push(separator) @@ -31,16 +31,33 @@ A component to display the keyboard shortcuts for the application. diff --git a/client/web-sveltekit/src/lib/TabsHeader.svelte b/client/web-sveltekit/src/lib/TabsHeader.svelte index c6a7fa0f03a..974d0d3e800 100644 --- a/client/web-sveltekit/src/lib/TabsHeader.svelte +++ b/client/web-sveltekit/src/lib/TabsHeader.svelte @@ -54,7 +54,7 @@ {tab.title} {#if tab.shortcut} - + {/if} {/each} @@ -82,7 +82,7 @@ flex-flow: row nowrap; justify-content: center; white-space: nowrap; - gap: 0.25rem; + gap: 0.5rem; position: relative; &::after { @@ -106,13 +106,6 @@ color: var(--text-title); background-color: var(--secondary-2); - :global(kbd) { - color: white; - box-shadow: none; - border-color: var(--primary); - background-color: var(--primary); - } - &::after { border-color: var(--primary); } diff --git a/client/web-sveltekit/src/lib/codemirror/SearchPanelView.svelte b/client/web-sveltekit/src/lib/codemirror/SearchPanelView.svelte index 83023b4f195..c38f6b65c9f 100644 --- a/client/web-sveltekit/src/lib/codemirror/SearchPanelView.svelte +++ b/client/web-sveltekit/src/lib/codemirror/SearchPanelView.svelte @@ -94,7 +94,7 @@ --> @@ -34,6 +18,7 @@ import { page } from '$app/stores' import { getGraphQLClient } from '$lib/graphql' import Icon from '$lib/Icon.svelte' + import KeyboardShortcut from '$lib/KeyboardShortcut.svelte' import LanguageIcon from '$lib/LanguageIcon.svelte' import Popover from '$lib/Popover.svelte' import RepoPopover, { fetchRepoPopoverData } from '$lib/repo/RepoPopover/RepoPopover.svelte' @@ -77,7 +62,6 @@ } }) - $: resetModifier = inferOperatingSystem(navigator.userAgent) === 'MacOS' ? '⌥' : 'Alt' $: resetURL = resetFilters($page.url).toString() $: enableReset = selectedFilters.length > 0 @@ -104,9 +88,10 @@

Filter results

{#if enableReset} - - Reset all {resetModifier} ⌫ - +
+ Reset all  + +
{/if}
@@ -226,17 +211,9 @@ h3 { margin: 0; } - a { + .reset { + font-size: var(--font-size-tiny); margin-left: auto; - line-height: 1; - kbd { - // TODO: use this style globally - font-family: var(--font-family-base); - color: var(--text-muted); - background: var(--color-bg-1); - box-shadow: inset 0 -2px 0 var(--border-color-2); - border: 1px solid var(--border-color-2); - } } } diff --git a/client/web-sveltekit/src/lib/search/input/ActionInfo.svelte b/client/web-sveltekit/src/lib/search/input/ActionInfo.svelte index 18dd04ece4b..7ae9e2521dd 100644 --- a/client/web-sveltekit/src/lib/search/input/ActionInfo.svelte +++ b/client/web-sveltekit/src/lib/search/input/ActionInfo.svelte @@ -1,37 +1,17 @@ -Press {displayName} to +Press to {#if action.type === 'completion'} - add to your query + add to your query. {:else if action.type === 'goto'} - go to the suggestion + go to the suggestion. {:else if action.type === 'command'} - execute the command + execute the command. {/if} - - diff --git a/client/web-sveltekit/src/lib/search/input/Suggestions.svelte b/client/web-sveltekit/src/lib/search/input/Suggestions.svelte index 7d9015adc48..356397e7122 100644 --- a/client/web-sveltekit/src/lib/search/input/Suggestions.svelte +++ b/client/web-sveltekit/src/lib/search/input/Suggestions.svelte @@ -85,9 +85,13 @@ {#if selectedOption}