This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-15 04:52:06 -04:00
1 parent 1760b073c7
commit 343eb1d659
22 files changed
+572 -308

No files matched your search

+12 -5
View File
@@ -1,19 +1,17 @@
<script lang="ts">
import { onMount } from 'svelte';
import { shortcuts } from '$lib/shortcuts';
import { settings } from '$lib/stores';
import { formatChord, isConfigurableShortcut, keybindings, shortcuts } from '$lib/shortcuts';
import type { Shortcut } from '$lib/shortcuts';
export let name: string;
export let className = '';
let isMac = false;
let mounted = false;
let keys: string[] = [];
let isVisible = true;
onMount(() => {
isMac = /Mac/i.test(navigator.userAgent);
keys = shortcuts[name]?.keys ?? [];
mounted = true;
});
@@ -26,12 +24,21 @@
return key;
}
function displayKeys(): string {
const id = name as Shortcut;
if (isConfigurableShortcut(id)) {
return formatChord($keybindings[id]);
}
const keys = shortcuts[id]?.keys ?? [];
return keys.map(formatKey).join(isMac ? '' : '+');
}
</script>
{#if mounted && isVisible}
<div
class="hidden md:flex items-center self-center text-xs text-gray-400 dark:text-gray-600 {className}"
>
<span>{keys.map(formatKey).join(isMac ? '' : '+')}</span>
<span>{displayKeys()}</span>
</div>
{/if}