fix: redesign and fix command palette

This commit is contained in:
James Xylight committed 2025-02-08 15:30:47 -08:00
1 parent cef63faf93
commit 75bf706d33
4 files changed
+48 -50

No files matched your search

@@ -21,6 +21,16 @@
let { open = $bindable(false), groups = $bindable([]) }: Props = $props()
$effect(() => {
groups = getGroups(
$resumables,
profile.data,
profileData.profiles,
$themeData,
page.data.contextual?.actions,
)
})
let search = $state('')
let container: HTMLElement | undefined = $state()
const dispatch = createEventDispatcher()
@@ -226,18 +236,11 @@
$effect(() => {
if (open) search = ''
})
$effect(() => {
groups = getGroups(
$resumables,
profile.data,
profileData.profiles,
$themeData,
page.data.contextual?.actions,
)
})
let flattenedActions = $derived(
filteredGroups.flatMap((group) => group.actions),
)
$effect(() => {
debouncedSearch(search)
})
@@ -245,8 +248,14 @@
<svelte:window onkeydown={handleKeydown} />
<TextInput bind:value={search} autofocus class="sticky font-mono" />
<div class="h-96 overflow-auto border-slate-200 dark:border-zinc-800">
<TextInput
bind:value={search}
autofocus
class="sticky rounded-none border-t-0 border-x-0 focus-within:dark:border-zinc-800"
size="lg"
placeholder={$t('nav.commands.prompt')}
/>
<div class="h-[32rem] overflow-auto border-slate-200 dark:border-zinc-800 p-5">
{#if breadcrumbs.length > 0}
<div class="flex items-center gap-2 my-1">
<button
@@ -24,31 +24,15 @@
<svelte:window onkeydown={handleKeydown} />
{#if open}
<Modal bind:open>
{#snippet customTitle()}
<span class="flex items-center gap-1">
<svg
width="24"
height="24"
fill="currentColor"
viewBox="15 15 70 70"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M45 20.8868C48.094 19.1004 51.906 19.1004 55 20.8868L72.7128 31.1132C75.8068 32.8996 77.7128 36.2008 77.7128 39.7735V60.2265C77.7128 63.7992 75.8068 67.1004 72.7128 68.8867L55 79.1133C51.906 80.8996 48.094 80.8996 45 79.1133L27.2872 68.8867C24.1932 67.1004 22.2872 63.7992 22.2872 60.2265V39.7735C22.2872 36.2008 24.1932 32.8996 27.2872 31.1132L45 20.8868Z"
/>
</svg>
{$t('nav.commands.prompt')}
</span>
{/snippet}
<Modal bind:open title={null} class="!p-0 !gap-0">
{#await import('./Commands.svelte')}
<div class="h-96 flex flex-col gap-2 items-center justify-center">
<div class="h-[32rem] flex flex-col gap-2 items-center justify-center">
<Spinner width={32} />
<span class="font-medium text-lg">
{$t('nav.commands.downloading')}
</span>
</div>
{:then {default: Commands }}
{:then { default: Commands }}
<Commands bind:open />
{/await}
</Modal>
@@ -92,7 +92,7 @@ export function getGroups(
name: t.get('nav.communities'),
icon: GlobeAlt,
},
...(amModOfAny(profile.data.user)
...(amModOfAny(profile.user)
? [
{
href: '/moderation',
@@ -101,7 +101,7 @@ export function getGroups(
},
]
: []),
...(profile.data.user && isAdmin(profile.data.user)
...(profile.user && isAdmin(profile.user)
? [
{
href: '/admin',
@@ -236,23 +236,23 @@ export function getGroups(
],
},
{
name: t.get('profile.data.profile'),
actions: profile.data.jwt
name: t.get('profile.profile'),
actions: profile.jwt
? [
{
href: '/profile/user',
name: t.get('profile.data.profile'),
name: t.get('profile.profile'),
icon: UserCircle,
},
{
href: '/inbox',
name: t.get('profile.data.inbox'),
name: t.get('profile.inbox'),
icon: Inbox,
shortcut: 'i',
},
{
href: '/saved',
name: t.get('profile.data.saved'),
name: t.get('profile.saved'),
icon: Bookmark,
},
{
@@ -311,11 +311,11 @@ export function getGroups(
icon: p.avatar ?? UserCircle,
detail: p.instance,
handle: async () => {
if (profile.data.id != p.id) {
if (profile.id != p.id) {
await setUserID(p.id)
}
await goto(get(page).url, {
await goto(page.url, {
invalidateAll: true,
})
},
@@ -407,9 +407,9 @@ export function getGroups(
],
},
{
name: t.get('profile.data.subscribed'),
name: t.get('profile.subscribed'),
actions:
profile.data?.user?.follows.map((f) => ({
profile.user?.follows.map((f) => ({
icon: f.community.icon,
name: f.community.title,
href: `/c/${fullCommunityName(
+14 -9
View File
@@ -6,12 +6,14 @@
import { fade, scale } from 'svelte/transition'
import { focusTrap } from 'svelte-focus-trap'
import Portal from '../popover/Portal.svelte'
import type { ClassValue } from 'svelte/elements'
interface Props {
action?: string | undefined
open?: boolean
title?: string | undefined
title?: string | undefined | null
dismissable?: boolean
class?: ClassValue
customTitle?: import('svelte').Snippet
children?: import('svelte').Snippet
actions?: import('svelte').Snippet<[any]>
@@ -29,6 +31,7 @@
actions,
ondismissed,
onaction,
class: clazz = '',
}: Props = $props()
let el: any = $state()
@@ -65,7 +68,7 @@ bg-white/50 dark:bg-black/50 box-border p-4"
dark:border-zinc-900 dark:border-t-zinc-800 dark:border-b-zinc-900
rounded-2xl max-w-lg box-border mx-auto overscroll-contain shadow-lg overflow-auto
p-5 flex flex-col gap-2 dark:bg-zinc-925
bg-white relative"
bg-white relative {clazz}"
>
{#if dismissable}
<Button
@@ -82,13 +85,15 @@ bg-white/50 dark:bg-black/50 box-border p-4"
{/snippet}
</Button>
{/if}
<h1 class="font-semibold text-xl max-w-full">
{#if customTitle}
{@render customTitle?.()}
{:else if title}
{title}
{/if}
</h1>
{#if title !== null}
<h1 class="font-semibold text-xl max-w-full">
{#if customTitle}
{@render customTitle?.()}
{:else if title}
{title}
{/if}
</h1>
{/if}
{@render children?.()}
{#if action}
<div class="mt-2 flex w-full">