mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 18:20:30 +08:00
Add keyboard shortcuts
Add a shortcuts modal `?` and app-wide shortcuts: - Cmd+F: sidebar repo filter, pressed again: list search - Cmd+N: new issue, anywhere in a repo - Cmd+1…9: jump to the nth sidebar repo; holding Cmd shows the numbers on the repo avatars - Cmd+[ / Cmd+] (Alt+Left / Alt+Right elsewhere): back and forward - Cmd+R: reload, skipped while typing or in a modal with a text field Global shortcuts are ignored while typing in an input and, except for `?`, while a modal is open. Co-Authored-By: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
co-authored by
Rūdolfs Ošiņš
parent
1d2cdaf033
commit
1f38339c9f
Generated
-17
@@ -57,7 +57,6 @@
|
||||
"hast-util-to-dom": "^4.0.1",
|
||||
"js-yaml": "^5.2.1",
|
||||
"katex": "^0.17.0",
|
||||
"keyux": "^0.11.6",
|
||||
"lodash": "^4.18.1",
|
||||
"lru-cache": "^11.5.2",
|
||||
"marked": "^18.0.6",
|
||||
@@ -3418,22 +3417,6 @@
|
||||
"katex": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/keyux": {
|
||||
"version": "0.11.6",
|
||||
"resolved": "https://registry.npmjs.org/keyux/-/keyux-0.11.6.tgz",
|
||||
"integrity": "sha512-sibuRm9zix1VixIAk7KWr78eEpuA34F2wKaorP8vHnqLn7W8hZRBYlBDUUw37OCbnuXQhi61/bYhAiUnxXrhow==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^20.0.0 || ^22.0.0 || >=24.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/keyv": {
|
||||
"version": "4.5.4",
|
||||
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
|
||||
|
||||
@@ -74,7 +74,6 @@
|
||||
"hast-util-to-dom": "^4.0.1",
|
||||
"js-yaml": "^5.2.1",
|
||||
"katex": "^0.17.0",
|
||||
"keyux": "^0.11.6",
|
||||
"lodash": "^4.18.1",
|
||||
"lru-cache": "^11.5.2",
|
||||
"marked": "^18.0.6",
|
||||
|
||||
+90
-6
@@ -17,25 +17,36 @@
|
||||
import { nodeRunning } from "@app/lib/events";
|
||||
import { dynamicInterval } from "@app/lib/interval";
|
||||
import { invoke } from "@app/lib/invoke";
|
||||
import { hide, toggle } from "@app/lib/modal";
|
||||
import { hide, modalStore, show, toggle } from "@app/lib/modal";
|
||||
import * as router from "@app/lib/router";
|
||||
import { isLoadedRepoRoute } from "@app/lib/router/definitions";
|
||||
import { toggleSidebar } from "@app/lib/sidebar.svelte";
|
||||
import {
|
||||
isLoadedRepoRoute,
|
||||
sidebarDataOf,
|
||||
} from "@app/lib/router/definitions";
|
||||
import { sidebarCollapsed, toggleSidebar } from "@app/lib/sidebar.svelte";
|
||||
import {
|
||||
setUnlistenNodeEvents,
|
||||
unlistenNodeEvents,
|
||||
} from "@app/lib/startup.svelte";
|
||||
import { isMac, unreachable } from "@app/lib/utils";
|
||||
import { isMac, isTyping, unreachable } from "@app/lib/utils";
|
||||
import { dragWindow } from "@app/lib/window";
|
||||
|
||||
import AppSidebar from "@app/components/AppSidebar.svelte";
|
||||
import { codeFont } from "@app/components/CodeFontSwitch.svelte";
|
||||
import { openListSearch } from "@app/components/FuzzySearch.svelte";
|
||||
import {
|
||||
isRepoFilter,
|
||||
openRepoFilter,
|
||||
sidebarRepoOrder,
|
||||
} from "@app/components/SidebarRepoList.svelte";
|
||||
import {
|
||||
followSystemTheme,
|
||||
loadTheme,
|
||||
theme,
|
||||
} from "@app/components/ThemeSwitch.svelte";
|
||||
import CreateIssueModal from "@app/modals/CreateIssue.svelte";
|
||||
import GuideView from "@app/modals/Guide.svelte";
|
||||
import KeyboardShortcutsModal from "@app/modals/KeyboardShortcuts.svelte";
|
||||
import SettingsView from "@app/modals/Settings.svelte";
|
||||
import Auth from "@app/views/auth/Auth.svelte";
|
||||
import CreateIdentity from "@app/views/auth/CreateIdentity.svelte";
|
||||
@@ -61,6 +72,14 @@
|
||||
return isLoadedRepoRoute(route) ? route.params.repo : undefined;
|
||||
});
|
||||
|
||||
function modalHasTextEntry(): boolean {
|
||||
return (
|
||||
document.querySelector(
|
||||
"[data-modal-content] :is(textarea, [contenteditable='true'], input:not([type='checkbox'], [type='radio'], [type='range'], [type='button']))",
|
||||
) !== null
|
||||
);
|
||||
}
|
||||
|
||||
window
|
||||
.matchMedia("(prefers-color-scheme: dark)")
|
||||
.addEventListener("change", ({ matches }) => {
|
||||
@@ -149,21 +168,86 @@
|
||||
onkeydown={e => {
|
||||
const auxiliarKey = isMac() ? e.metaKey : e.ctrlKey;
|
||||
// Handles the position of the plus key on different keyboard layouts.
|
||||
const plusKey = e.key === "1" || e.key === "=";
|
||||
const plusKey = e.key === "+" || e.key === "=";
|
||||
const backKey = isMac()
|
||||
? e.metaKey && e.key === "["
|
||||
: e.altKey && e.key === "ArrowLeft";
|
||||
const forwardKey = isMac()
|
||||
? e.metaKey && e.key === "]"
|
||||
: e.altKey && e.key === "ArrowRight";
|
||||
const noModal = $modalStore === undefined;
|
||||
if (e.key === "Escape") {
|
||||
hide();
|
||||
} else if (auxiliarKey && (e.key === "+" || plusKey)) {
|
||||
return;
|
||||
}
|
||||
// The first press goes to the sidebar's repo filter, the second one from
|
||||
// there to the search of the list on screen.
|
||||
if (auxiliarKey && e.key.toLowerCase() === "f" && noModal) {
|
||||
if (isRepoFilter(e.target)) {
|
||||
if (openListSearch()) {
|
||||
e.preventDefault();
|
||||
}
|
||||
} else if (!isTyping(e.target)) {
|
||||
e.preventDefault();
|
||||
if (sidebarCollapsed.value) {
|
||||
openListSearch();
|
||||
} else {
|
||||
openRepoFilter();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isTyping(e.target)) {
|
||||
return;
|
||||
}
|
||||
if (auxiliarKey && plusKey) {
|
||||
increaseFontSize();
|
||||
} else if (auxiliarKey && e.key === "-") {
|
||||
decreaseFontSize();
|
||||
} else if (auxiliarKey && e.key.toLowerCase() === "0") {
|
||||
resetFontSize();
|
||||
} else if (auxiliarKey && e.key.toLowerCase() === "r") {
|
||||
e.preventDefault();
|
||||
// A reload would throw away whatever is being composed in a modal.
|
||||
if (!modalHasTextEntry()) {
|
||||
// Matches the sidebar's reload button rather than re-fetching per route.
|
||||
window.location.reload();
|
||||
}
|
||||
} else if (auxiliarKey && /^[1-9]$/.test(e.key) && noModal) {
|
||||
const repos = sidebarDataOf($activeRouteStore)?.repos;
|
||||
const repo = repos && sidebarRepoOrder(repos)[Number(e.key) - 1];
|
||||
if (repo) {
|
||||
e.preventDefault();
|
||||
void router.push({ resource: "repo.home", rid: repo.rid });
|
||||
}
|
||||
} else if (backKey && noModal) {
|
||||
e.preventDefault();
|
||||
window.history.back();
|
||||
} else if (forwardKey && noModal) {
|
||||
e.preventDefault();
|
||||
window.history.forward();
|
||||
} else if (auxiliarKey && e.key === ",") {
|
||||
e.preventDefault();
|
||||
toggle({ component: SettingsView, props: {} });
|
||||
} else if (auxiliarKey && e.key.toLowerCase() === "b") {
|
||||
e.preventDefault();
|
||||
toggleSidebar();
|
||||
} else if (e.key === "?" && !auxiliarKey && !e.altKey) {
|
||||
// Only toggle our own modal, so an open modal isn't replaced from
|
||||
// under the user.
|
||||
const open = $modalStore?.component;
|
||||
if (open === undefined || open === KeyboardShortcutsModal) {
|
||||
e.preventDefault();
|
||||
toggle({ component: KeyboardShortcutsModal, props: {} });
|
||||
}
|
||||
} else if (
|
||||
auxiliarKey &&
|
||||
e.key.toLowerCase() === "n" &&
|
||||
activeRepo &&
|
||||
noModal
|
||||
) {
|
||||
e.preventDefault();
|
||||
show({ component: CreateIssueModal, props: { repo: activeRepo } });
|
||||
}
|
||||
}} />
|
||||
<FullscreenModalPortal />
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { fade } from "svelte/transition";
|
||||
|
||||
import { hide, modalStore } from "@app/lib/modal";
|
||||
import { DRAG_REGION_HEIGHT } from "@app/lib/window";
|
||||
|
||||
@@ -46,6 +48,7 @@
|
||||
role="button"
|
||||
tabindex="0"
|
||||
class="overlay"
|
||||
transition:fade={{ duration: 120 }}
|
||||
onclick={$modalStore.disableScrimClose ? undefined : hide}
|
||||
style:cursor={$modalStore.disableHide ? "not-allowed" : "default"}>
|
||||
</div>
|
||||
@@ -57,7 +60,7 @@
|
||||
data-tauri-drag-region>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="content">
|
||||
<div class="content" data-modal-content>
|
||||
<svelte:component this={$modalStore.component} {...$modalStore.props} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
<script lang="ts" module>
|
||||
let openActive: (() => void) | undefined;
|
||||
|
||||
// Opens and focuses the search of the list on screen. Returns false when
|
||||
// there is none, or it has nothing to search.
|
||||
export function openListSearch(): boolean {
|
||||
if (openActive === undefined) {
|
||||
return false;
|
||||
}
|
||||
openActive();
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type { ComponentProps } from "svelte";
|
||||
|
||||
@@ -20,7 +34,7 @@
|
||||
let {
|
||||
hasItems = true,
|
||||
placeholder,
|
||||
icon = "filter",
|
||||
icon = "search",
|
||||
show = $bindable(),
|
||||
value = $bindable(),
|
||||
onFocus,
|
||||
@@ -28,12 +42,35 @@
|
||||
styleHeight = "2rem",
|
||||
}: Props = $props();
|
||||
/* eslint-enable prefer-const */
|
||||
|
||||
function open() {
|
||||
show = true;
|
||||
// Mounting autofocuses the input, but it may already be open and blurred.
|
||||
requestAnimationFrame(() => {
|
||||
document
|
||||
.querySelector<HTMLInputElement>('input[name="list-search"]')
|
||||
?.focus({ preventScroll: true });
|
||||
});
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (!hasItems) {
|
||||
return;
|
||||
}
|
||||
openActive = open;
|
||||
return () => {
|
||||
if (openActive === open) {
|
||||
openActive = undefined;
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if hasItems}
|
||||
{#if show}
|
||||
<TextInput
|
||||
autofocus
|
||||
name="list-search"
|
||||
{onFocus}
|
||||
{onSubmit}
|
||||
onBlur={() => {
|
||||
@@ -64,7 +101,7 @@
|
||||
{styleHeight}
|
||||
keyShortcuts="ctrl+f"
|
||||
onclick={() => (show = true)}>
|
||||
<Icon name="filter" />
|
||||
<Icon name={icon} />
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -253,7 +253,7 @@
|
||||
</div>
|
||||
<div class="filter-search" class:expanded={showSearch}>
|
||||
<FuzzySearch
|
||||
placeholder={`Fuzzy filter notifications ${modifierKey()} + f`}
|
||||
placeholder={`Search notifications ${modifierKey()} + f`}
|
||||
bind:show={showSearch}
|
||||
bind:value={searchInput} />
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts" module>
|
||||
import type { RepoSummary } from "@bindings/repo/RepoSummary";
|
||||
|
||||
import { array, boolean, string } from "zod";
|
||||
|
||||
import useLocalStorage from "@app/lib/useLocalStorage.svelte";
|
||||
@@ -20,6 +22,49 @@
|
||||
!window.localStorage,
|
||||
);
|
||||
|
||||
// The list as currently rendered, which the sidebar refreshes on its own,
|
||||
// so it can be newer than the route's sidebar data.
|
||||
let liveRepos: RepoSummary[] | undefined;
|
||||
|
||||
function pinnedFrom(repos: RepoSummary[]): RepoSummary[] {
|
||||
const byRid = new Map(repos.map(r => [r.rid, r]));
|
||||
return pinnedRepoIds.value
|
||||
.map(rid => byRid.get(rid))
|
||||
.filter((r): r is RepoSummary => r !== undefined);
|
||||
}
|
||||
|
||||
// The sidebar's top-to-bottom order: pinned repos first, in the order they
|
||||
// were pinned, then the rest. Exported so that the Cmd+1..9 shortcuts land
|
||||
// on the same rows the user is looking at. Deliberately ignores the filter
|
||||
// query, which is transient, so the numbering stays put while typing in it.
|
||||
// Falls back to the given repos while the sidebar isn't mounted.
|
||||
export function sidebarRepoOrder(fallback: RepoSummary[]): RepoSummary[] {
|
||||
return orderRepos(liveRepos ?? fallback);
|
||||
}
|
||||
|
||||
function orderRepos(repos: RepoSummary[]): RepoSummary[] {
|
||||
return pinnedFrom(repos).concat(
|
||||
repos.filter(r => !pinnedRepoIds.value.includes(r.rid)),
|
||||
);
|
||||
}
|
||||
|
||||
export function openRepoFilter() {
|
||||
filterOpen = true;
|
||||
reposExpanded.value = true;
|
||||
// Opening already focuses the input, but not when it was open and blurred.
|
||||
requestAnimationFrame(() => {
|
||||
document
|
||||
.querySelector<HTMLInputElement>("[data-repo-filter]")
|
||||
?.focus({ preventScroll: true });
|
||||
});
|
||||
}
|
||||
|
||||
export function isRepoFilter(target: EventTarget | null): boolean {
|
||||
return (
|
||||
target instanceof HTMLElement && target.hasAttribute("data-repo-filter")
|
||||
);
|
||||
}
|
||||
|
||||
export function revealRepoInSidebar(rid: string) {
|
||||
if (pinnedRepoIds.value.includes(rid)) return;
|
||||
|
||||
@@ -39,7 +84,6 @@
|
||||
<script lang="ts">
|
||||
import type { Config } from "@bindings/config/Config";
|
||||
import type { RepoInfo } from "@bindings/repo/RepoInfo";
|
||||
import type { RepoSummary } from "@bindings/repo/RepoSummary";
|
||||
import type { CrossfadeParams } from "svelte/transition";
|
||||
|
||||
import { onMount, untrack } from "svelte";
|
||||
@@ -66,6 +110,7 @@
|
||||
explorerHost,
|
||||
explorerUrl,
|
||||
formatRepositoryId,
|
||||
isMac,
|
||||
} from "@app/lib/utils";
|
||||
|
||||
import AddRepoButton from "@app/components/AddRepoButton.svelte";
|
||||
@@ -97,6 +142,24 @@
|
||||
let seededNotReplicated: string[] = $derived(initialSeededNotReplicated);
|
||||
let filterInputElement: HTMLInputElement | undefined = $state(undefined);
|
||||
|
||||
const shortcutNumbers = $derived(
|
||||
new Map(
|
||||
orderRepos(repos)
|
||||
.slice(0, 9)
|
||||
.map((r, i) => [r.rid, i + 1]),
|
||||
),
|
||||
);
|
||||
|
||||
let showShortcutNumbers = $state(false);
|
||||
|
||||
function isShortcutModifier(e: KeyboardEvent): boolean {
|
||||
return e.key === (isMac() ? "Meta" : "Control");
|
||||
}
|
||||
|
||||
function hideShortcutNumbers() {
|
||||
showShortcutNumbers = false;
|
||||
}
|
||||
|
||||
let contextMenu = $state<
|
||||
{ x: number; y: number; repo: RepoSummary; target: HTMLElement } | undefined
|
||||
>(undefined);
|
||||
@@ -116,6 +179,13 @@
|
||||
contextMenu = undefined;
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
liveRepos = repos;
|
||||
return () => {
|
||||
liveRepos = undefined;
|
||||
};
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (filterOpen && filterInputElement) {
|
||||
filterInputElement.focus({ preventScroll: true });
|
||||
@@ -158,12 +228,7 @@
|
||||
!window.localStorage,
|
||||
);
|
||||
|
||||
const pinnedRepos = $derived.by(() => {
|
||||
const byRid = new Map(repos.map(r => [r.rid, r]));
|
||||
return pinnedRepoIds.value
|
||||
.map(rid => byRid.get(rid))
|
||||
.filter((r): r is RepoSummary => r !== undefined);
|
||||
});
|
||||
const pinnedRepos = $derived.by(() => pinnedFrom(repos));
|
||||
|
||||
const unpinnedFilteredRepos = $derived(
|
||||
filteredRepos.filter(r => !pinnedRepoIds.value.includes(r.rid)),
|
||||
@@ -715,6 +780,27 @@
|
||||
:global(.view.mini) .nav-item.context-active .avatar-lock {
|
||||
background-color: var(--color-surface-subtle);
|
||||
}
|
||||
.avatar-shortcut {
|
||||
display: flex;
|
||||
position: absolute;
|
||||
right: -0.25rem;
|
||||
bottom: -0.25rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 0.75rem;
|
||||
height: 0.75rem;
|
||||
border-radius: var(--border-radius-sm);
|
||||
background-color: var(--color-surface-canvas);
|
||||
color: var(--color-text-secondary);
|
||||
font: var(--txt-body-s-semibold);
|
||||
font-size: 0.625rem;
|
||||
line-height: 1;
|
||||
}
|
||||
.nav-item:hover .avatar-shortcut,
|
||||
.nav-item.active .avatar-shortcut,
|
||||
.nav-item.context-active .avatar-shortcut {
|
||||
background-color: var(--color-surface-subtle);
|
||||
}
|
||||
/* Out of flow: hidden, they still reserved a button's width on every row.
|
||||
They sit over the end of the name instead, on the row's own fill. */
|
||||
.nav-item .row-actions {
|
||||
@@ -881,6 +967,19 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<svelte:window
|
||||
onkeydown={e => {
|
||||
if (isShortcutModifier(e)) {
|
||||
showShortcutNumbers = true;
|
||||
}
|
||||
}}
|
||||
onkeyup={e => {
|
||||
if (isShortcutModifier(e)) {
|
||||
hideShortcutNumbers();
|
||||
}
|
||||
}}
|
||||
onblur={hideShortcutNumbers} />
|
||||
|
||||
{#if seededNotReplicated.length > 0 && !sidebarCollapsed.value}
|
||||
<div
|
||||
class="section-header"
|
||||
@@ -971,6 +1070,7 @@
|
||||
role="none">
|
||||
<input
|
||||
bind:this={filterInputElement}
|
||||
data-repo-filter
|
||||
class="filter-input"
|
||||
placeholder="Filter repos…"
|
||||
bind:value={filterQuery}
|
||||
@@ -1046,6 +1146,7 @@
|
||||
|
||||
{#snippet repoRowInner(repo: RepoSummary, pinned: boolean = false)}
|
||||
{@const pinState = pinnedRepoIds.value.includes(repo.rid)}
|
||||
{@const shortcutNumber = shortcutNumbers.get(repo.rid)}
|
||||
<a
|
||||
class="nav-item"
|
||||
class:not-seeded={!repo.seeding}
|
||||
@@ -1062,7 +1163,9 @@
|
||||
href={router.routeToPath({ resource: "repo.home", rid: repo.rid })}>
|
||||
<span class="avatar">
|
||||
<RepoAvatar name={repo.name} rid={repo.rid} styleWidth="1rem" />
|
||||
{#if repo.private}
|
||||
{#if showShortcutNumbers && shortcutNumber !== undefined}
|
||||
<span class="avatar-shortcut">{shortcutNumber}</span>
|
||||
{:else if repo.private}
|
||||
<span class="avatar-lock">
|
||||
<Icon name="lock" />
|
||||
</span>
|
||||
|
||||
@@ -68,6 +68,12 @@ export function isLoadedRepoRoute(
|
||||
);
|
||||
}
|
||||
|
||||
// Every route but `booting` carries the sidebar data, which has no params at
|
||||
// all, so reach for it through here rather than narrowing at each call site.
|
||||
export function sidebarDataOf(route: LoadedRoute): SidebarData | undefined {
|
||||
return route.resource === "booting" ? undefined : route.params.sidebarData;
|
||||
}
|
||||
|
||||
export async function loadSidebarData(): Promise<SidebarData> {
|
||||
const [config, repos, notificationCount, seededNotReplicated] =
|
||||
await Promise.all([
|
||||
|
||||
@@ -252,6 +252,14 @@ export function modifierKey() {
|
||||
return isMac() ? "⌘" : "ctrl";
|
||||
}
|
||||
|
||||
export function isTyping(target: EventTarget | null): boolean {
|
||||
if (!(target instanceof HTMLElement)) {
|
||||
return false;
|
||||
}
|
||||
const tag = target.tagName.toLowerCase();
|
||||
return tag === "input" || tag === "textarea" || target.isContentEditable;
|
||||
}
|
||||
|
||||
export function parseNodeId(
|
||||
nid: string,
|
||||
): { prefix: string; pubkey: string } | undefined {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import "overlayscrollbars/overlayscrollbars.css";
|
||||
import { hotkeyKeyUX, hotkeyMacCompat, startKeyUX } from "keyux";
|
||||
import { mount } from "svelte";
|
||||
|
||||
import App from "./App.svelte";
|
||||
@@ -9,7 +8,4 @@ const app = mount(App, { target: document.body });
|
||||
|
||||
disableNativeContextMenu();
|
||||
|
||||
const mac = hotkeyMacCompat();
|
||||
startKeyUX(window, [hotkeyKeyUX([mac])]);
|
||||
|
||||
export default app;
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
<script lang="ts">
|
||||
import { cubicIn, cubicOut } from "svelte/easing";
|
||||
import { fly } from "svelte/transition";
|
||||
|
||||
import { isMac, modifierKey } from "@app/lib/utils";
|
||||
|
||||
type Shortcut = { keys: string[]; description: string };
|
||||
|
||||
const shortcuts: Shortcut[] = [
|
||||
{ keys: ["?"], description: "Keyboard shortcuts" },
|
||||
{ keys: [modifierKey(), "f"], description: "Search the current list" },
|
||||
{ keys: [modifierKey(), "n"], description: "New issue" },
|
||||
{ keys: [modifierKey(), "1…9"], description: "Go to the nth repo" },
|
||||
{
|
||||
keys: isMac() ? [modifierKey(), "["] : ["alt", "←"],
|
||||
description: "Go back",
|
||||
},
|
||||
{
|
||||
keys: isMac() ? [modifierKey(), "]"] : ["alt", "→"],
|
||||
description: "Go forward",
|
||||
},
|
||||
{ keys: [modifierKey(), "r"], description: "Reload" },
|
||||
{ keys: [modifierKey(), "b"], description: "Toggle sidebar" },
|
||||
{ keys: [modifierKey(), ","], description: "Settings" },
|
||||
{ keys: [modifierKey(), "+"], description: "Increase font size" },
|
||||
{ keys: [modifierKey(), "-"], description: "Decrease font size" },
|
||||
{ keys: [modifierKey(), "0"], description: "Reset font size" },
|
||||
{ keys: ["esc"], description: "Close modal" },
|
||||
];
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.modal {
|
||||
width: 30rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-radius: var(--border-radius-lg);
|
||||
background-color: var(--color-surface-canvas);
|
||||
overflow: hidden;
|
||||
}
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 1.5rem;
|
||||
height: 3.25rem;
|
||||
flex-shrink: 0;
|
||||
border-bottom: 1px solid var(--color-border-subtle);
|
||||
}
|
||||
.title {
|
||||
font: var(--txt-heading-s);
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
.rows {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
align-items: center;
|
||||
column-gap: 1rem;
|
||||
row-gap: 0.75rem;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
.keys {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.key {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 1.75rem;
|
||||
min-width: 1.75rem;
|
||||
padding: 0 0.5rem;
|
||||
border-radius: var(--border-radius-md);
|
||||
background-color: var(--color-surface-subtle);
|
||||
font: var(--txt-body-m-medium);
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
.plus {
|
||||
font: var(--txt-body-m-regular);
|
||||
color: var(--color-text-tertiary);
|
||||
}
|
||||
.description {
|
||||
font: var(--txt-body-m-regular);
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
</style>
|
||||
|
||||
<div
|
||||
class="modal"
|
||||
in:fly={{ y: 8, duration: 160, easing: cubicOut }}
|
||||
out:fly={{ y: 8, duration: 120, easing: cubicIn }}>
|
||||
<div class="header">
|
||||
<span class="title">Keyboard shortcuts</span>
|
||||
</div>
|
||||
<div class="rows">
|
||||
{#each shortcuts as shortcut (shortcut.description)}
|
||||
<div class="keys">
|
||||
{#each shortcut.keys as key, index (key)}
|
||||
{#if index > 0}
|
||||
<span class="plus">+</span>
|
||||
{/if}
|
||||
<span class="key">{key}</span>
|
||||
{/each}
|
||||
</div>
|
||||
<span class="description">{shortcut.description}</span>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
@@ -6,7 +6,6 @@
|
||||
import { diffOptions } from "@app/lib/diffOptions.svelte";
|
||||
import { hints } from "@app/lib/hints";
|
||||
import { invoke } from "@app/lib/invoke";
|
||||
import { hide } from "@app/lib/modal";
|
||||
import { updateChecker } from "@app/lib/updateChecker.svelte";
|
||||
import { pluralize } from "@app/lib/utils";
|
||||
|
||||
@@ -77,7 +76,6 @@
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 1.5rem;
|
||||
height: 3.25rem;
|
||||
flex-shrink: 0;
|
||||
@@ -129,11 +127,6 @@
|
||||
<div class="modal">
|
||||
<div class="header">
|
||||
<span class="title">Settings</span>
|
||||
<Button variant="naked" onclick={hide}>
|
||||
<span style:color="var(--color-text-tertiary)">
|
||||
<Icon name="close" />
|
||||
</span>
|
||||
</Button>
|
||||
</div>
|
||||
<div class="rows">
|
||||
<div class="row">
|
||||
|
||||
@@ -236,8 +236,8 @@
|
||||
<div class="global-flex" style:margin-left="auto" style:gap="0.5rem">
|
||||
<FuzzySearch
|
||||
hasItems={list.items.length > 0}
|
||||
placeholder={`Fuzzy filter issues ${modifierKey()} + f`}
|
||||
icon={loading ? "clock" : "filter"}
|
||||
placeholder={`Search issues ${modifierKey()} + f`}
|
||||
icon={loading ? "clock" : "search"}
|
||||
onFocus={async () => {
|
||||
try {
|
||||
loading = true;
|
||||
|
||||
@@ -272,8 +272,8 @@
|
||||
<div class="global-flex" style:margin-left="auto" style:gap="0.5rem">
|
||||
<FuzzySearch
|
||||
hasItems={list.items.length > 0}
|
||||
placeholder={`Fuzzy filter patches ${modifierKey()} + f`}
|
||||
icon={loading ? "clock" : "filter"}
|
||||
placeholder={`Search patches ${modifierKey()} + f`}
|
||||
icon={loading ? "clock" : "search"}
|
||||
onFocus={async () => {
|
||||
try {
|
||||
loading = true;
|
||||
|
||||
@@ -224,9 +224,9 @@
|
||||
{#snippet extra()}
|
||||
<FuzzySearch
|
||||
hasItems={list.items.length > 0}
|
||||
placeholder={`Fuzzy filter commits ${modifierKey()} + f`}
|
||||
placeholder={`Search commits ${modifierKey()} + f`}
|
||||
styleHeight="1.75rem"
|
||||
icon={loading ? "clock" : "filter"}
|
||||
icon={loading ? "clock" : "search"}
|
||||
onFocus={async () => {
|
||||
try {
|
||||
loading = true;
|
||||
|
||||
Reference in New Issue
Block a user