Files
photon-tbw/src/lib/components/ui/navbar/commands/CommandItem.svelte
T
Xylight 5651ad475d feat: use state based auth instead of store based (#488)
* misc: switch to state for auth

* fix: class based auth not working
2025-02-08 13:49:09 -08:00

55 lines
1.4 KiB
Svelte

<script lang="ts">
import { Button, Material } from 'mono-svelte'
import {
ArrowUturnDown,
Icon,
QuestionMarkCircle,
type IconSource,
} from 'svelte-hero-icons'
import Avatar from '../../Avatar.svelte'
import type { Action } from './actions.svelte'
import type { HTMLButtonAttributes } from 'svelte/elements'
interface Props {
action: Action
class?: string
children?: import('svelte').Snippet
onclick?: HTMLButtonAttributes['onclick']
[key: string]: any
}
let { action, class: clazz = '', children, ...rest }: Props = $props()
</script>
<Button
href={action.href}
alignment="left"
color="tertiary"
size="lg"
class="focus:bg-slate-200 focus:dark:bg-zinc-800 block w-full {clazz}"
data-sveltekit-preload-code="viewport"
data-sveltekit-preload-data="tap"
{...rest}
>
{#if typeof action.icon === 'string'}
<Avatar url={action.icon} width={20} />
{:else}
<Icon src={action.icon ?? QuestionMarkCircle} size="20" />
{/if}
{@render children?.()}
<span class="mr-auto inline-flex flex-col">
<span>{action.name}</span>
{#if action.detail}
<span class="font-normal text-xs">{action.detail}</span>
{/if}
</span>
{#if action.shortcut}
<div class="flex items-center gap-0.5 text-xs font-medium">
⌘ {action.shortcut}
</div>
{/if}
{#if action.subActions}
<Icon src={ArrowUturnDown} size="16" micro />
{/if}
</Button>