feat: restructure app.html to support custom icon svg
This commit is contained in:
10 files changed
+148
-135
No files matched your search
@@ -0,0 +1,94 @@
|
||||
<script lang="ts">
|
||||
import { Badge, Button, Menu, MenuButton } from 'mono-svelte'
|
||||
import {
|
||||
CheckCircle,
|
||||
ChevronUpDown,
|
||||
Icon,
|
||||
QuestionMarkCircle,
|
||||
UserGroup,
|
||||
} from 'svelte-hero-icons'
|
||||
import Avatar from '../Avatar.svelte'
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/state'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
|
||||
function switchTo(id: number) {
|
||||
profile.meta.profile = id
|
||||
|
||||
goto(page.url, {
|
||||
invalidateAll: true,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<Menu placement="bottom">
|
||||
{#snippet target()}
|
||||
<Button
|
||||
color="tertiary"
|
||||
alignment="left"
|
||||
size="md"
|
||||
rounding="xl"
|
||||
class="flex flex-row gap-2 items-center"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Avatar
|
||||
url={profile.current.avatar}
|
||||
alt={profile.current.username}
|
||||
width={24}
|
||||
/>
|
||||
{/snippet}
|
||||
<div class="flex-1">
|
||||
<div class="font-medium">{profile.current.username}</div>
|
||||
<div class="text-xs text-slate-500 dark:text-zinc-500">
|
||||
{profile.current.instance}
|
||||
</div>
|
||||
</div>
|
||||
{#snippet suffix()}
|
||||
<Icon
|
||||
src={ChevronUpDown}
|
||||
size="16"
|
||||
micro
|
||||
class="block justify-self-end"
|
||||
/>
|
||||
{/snippet}
|
||||
</Button>
|
||||
{/snippet}
|
||||
{#each profile.meta.profiles as p}
|
||||
{@const selected = profile.meta.profile == p.id}
|
||||
<MenuButton
|
||||
onclick={() => switchTo(p.id)}
|
||||
class={[selected && 'bg-slate-100! dark:bg-zinc-800!']}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Avatar url={p.avatar} alt={p.username} width={24} />
|
||||
{/snippet}
|
||||
<div>
|
||||
<div class="font-medium text-sm">{p.username}</div>
|
||||
<div class="text-xs text-slate-500 dark:text-zinc-500">
|
||||
{p.instance}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-1"></div>
|
||||
{#if !p.jwt}
|
||||
<Badge color="gray-subtle" class="p-1!">
|
||||
<Icon src={QuestionMarkCircle} size="16" micro />
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if selected}
|
||||
<Icon
|
||||
src={CheckCircle}
|
||||
class="text-primary-900 dark:text-primary-100"
|
||||
size="16"
|
||||
micro
|
||||
/>
|
||||
{/if}
|
||||
</MenuButton>
|
||||
{/each}
|
||||
<MenuButton href="/accounts">
|
||||
{#snippet prefix()}
|
||||
<Icon src={UserGroup} size="16" micro />
|
||||
{/snippet}
|
||||
{$t('account.accounts')}
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
Reference in new issue
Block a user