misc: make command palette more obvious

This commit is contained in:
Xylight committed 2025-12-18 17:42:47 -08:00
1 parent f3a773c31e
commit 19e7bea811
6 files changed
+54 -20

No files matched your search

+3 -4
View File
@@ -17,10 +17,9 @@
import type { ClassValue } from 'svelte/elements'
import Avatar from '../generic/Avatar.svelte'
import Logo from '../generic/Logo.svelte'
import CommandsWrapper from './commands/CommandsHost.svelte'
import CommandsWrapper, { chords } from './commands/CommandsHost.svelte'
import NavButton from './NavButton.svelte'
let promptOpen: boolean = $state(false)
interface Props {
style?: string
class?: ClassValue
@@ -29,12 +28,12 @@
let { style = '', class: clazz = '' }: Props = $props()
</script>
<CommandsWrapper bind:open={promptOpen} />
<CommandsWrapper />
<nav class={['navbar @container', clazz]} {style} data-sveltekit-preload-data>
<NavButton
oncontextmenu={(e: Event) => {
e.preventDefault()
promptOpen = true
chords.commands = true
return true
}}
icon={Home}
+19
View File
@@ -23,6 +23,7 @@
BugAnt,
CodeBracketSquare,
Cog6Tooth,
CommandLine,
ComputerDesktop,
Icon,
Identification,
@@ -35,6 +36,7 @@
UserCircle,
UserGroup,
} from 'svelte-hero-icons/dist'
import { chords } from './commands/CommandsHost.svelte'
</script>
{#snippet siteSnippet()}
@@ -136,6 +138,23 @@
<MenuButton href="/theme" icon={Swatch}>
{$t('nav.menu.theme')}
</MenuButton>
{#snippet key(label: string)}
<span
class="text-[12px] rounded-md border border-slate-300 dark:border-zinc-700 border-b-2 px-2 py-0.5"
>
{label}
</span>
{/snippet}
<MenuButton
onclick={() => (chords.commands = !chords.commands)}
icon={CommandLine}
>
{$t('nav.commands.prompt')}
<div class="text-slate-600 dark:text-zinc-400 text-xs ml-auto max-sm:hidden">
{@render key('Ctrl')}
{@render key('K')}
</div>
</MenuButton>
{#if settings.debugInfo}
<MenuButton href="/util" icon={BugAnt}>Debug</MenuButton>
{/if}
+1 -1
View File
@@ -256,7 +256,7 @@
{/if}
<div class="space-y-1" bind:this={container}>
{#each filteredGroups as group, groupIndex}
<div class="space-y-1">
<div class={['space-y-1', group.actions.length == 0 && 'hidden']}>
<EndPlaceholder margin="md" size="sm">{group.name}</EndPlaceholder>
<CommonList size="xs" class="p-0! sm:p-0! lg:p-0!">
{#each group.actions as action, actionIndex}
+10 -10
View File
@@ -1,28 +1,28 @@
<script lang="ts" module>
export let chords = $state({
commands: false,
})
</script>
<script lang="ts">
import { t } from '$lib/app/i18n'
import { Modal, TextLoader } from 'mono-svelte'
interface Props {
open?: boolean
}
let { open = $bindable(false) }: Props = $props()
function handleKeydown(event: KeyboardEvent) {
if (
(event.ctrlKey && (event.key === 'k' || event.key == 'p')) ||
(event.key == '/' && document.activeElement == document.body)
) {
event.preventDefault()
open = !open
chords.commands = !chords.commands
}
}
</script>
<svelte:window onkeydown={handleKeydown} />
{#if open}
<Modal bind:open title={null} class="p-0! gap-0!">
{#if chords.commands}
<Modal bind:open={chords.commands} title={null} class="p-0! gap-0!">
{#await import('./Commands.svelte')}
<div class="h-128 flex flex-col gap-2 items-center justify-center">
<TextLoader>
@@ -30,7 +30,7 @@
</TextLoader>
</div>
{:then { default: Commands }}
<Commands bind:open />
<Commands bind:open={chords.commands} />
{/await}
</Modal>
{/if}
+8 -2
View File
@@ -20,6 +20,7 @@ import {
Clock,
Cog6Tooth,
ComputerDesktop,
Envelope,
Fire,
GlobeAlt,
GlobeAmericas,
@@ -275,6 +276,11 @@ export function getGroups(
name: t.get('account.addGuest'),
icon: Plus,
},
{
href: '/inbox/messages',
name: t.get('filter.inbox.messages'),
icon: Envelope,
},
]
: [
{
@@ -413,12 +419,12 @@ export function getGroups(
export function dynamicActions(query: string): Group {
const actions = [
{
name: t.get('nav.commands.search', { default: query }),
name: t.get('nav.commands.search', { default: query.trim() }),
icon: MagnifyingGlass,
href: `/search?q=${query}`,
},
{
name: t.get('nav.commands.communities', { default: query }),
name: t.get('nav.commands.communities', { default: query.trim() }),
icon: Newspaper,
href: `/explore/communities?q=${query}`,
},