2024-06-10 05:24:55 +02:00
|
|
|
<template>
|
2024-06-21 04:09:09 +02:00
|
|
|
<AdaptiveDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
<template #button>
|
|
|
|
|
<slot>
|
2024-07-22 01:23:29 +02:00
|
|
|
<div class="rounded text-left flex flex-row gap-x-2 hover:scale-[95%] duration-100"
|
|
|
|
|
v-if="identity">
|
2024-06-10 05:24:55 +02:00
|
|
|
<div class="shrink-0">
|
2024-07-21 15:33:32 +02:00
|
|
|
<Avatar class="size-12 rounded ring-1 ring-white/5" :src="identity.account.avatar"
|
|
|
|
|
:alt="`${identity.account.acct}'s avatar'`" />
|
2024-06-10 05:24:55 +02:00
|
|
|
</div>
|
|
|
|
|
<div class="flex flex-col items-start p-1 justify-around grow overflow-hidden">
|
|
|
|
|
<div class="flex flex-row items-center justify-between w-full">
|
2024-07-22 01:23:29 +02:00
|
|
|
<div class="font-semibold text-gray-200 text-sm line-clamp-1 break-all">
|
2024-06-10 05:24:55 +02:00
|
|
|
{{
|
2024-07-21 15:33:32 +02:00
|
|
|
identity.account.display_name }}
|
2024-06-10 05:24:55 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-07-22 01:23:29 +02:00
|
|
|
<span class="text-gray-400 text-xs line-clamp-1 break-all w-full">
|
2024-06-10 05:24:55 +02:00
|
|
|
Change account
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-06-28 02:09:05 +02:00
|
|
|
<ButtonBase theme="secondary" v-else class="w-full !justify-start overflow-hidden">
|
2024-06-27 15:03:03 +02:00
|
|
|
<Icon icon="tabler:login" class="!size-6" />
|
|
|
|
|
<span class="shrink-0 line-clamp-1">Sign In</span>
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonBase>
|
2024-06-10 05:24:55 +02:00
|
|
|
</slot>
|
|
|
|
|
</template>
|
|
|
|
|
<template #items>
|
|
|
|
|
<div class="p-2">
|
2024-07-22 01:23:29 +02:00
|
|
|
<h3 class="text-gray-400 text-xs text-center md:text-left uppercase font-semibold">Switch to account
|
2024-06-10 05:24:55 +02:00
|
|
|
</h3>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="px-2 py-4 md:py-2 flex flex-col gap-3 max-w-[100vw]">
|
|
|
|
|
<Menu.Item value="" v-for="identity of identities" class="hover:scale-[95%] duration-100">
|
|
|
|
|
<div class="flex flex-row gap-x-4">
|
|
|
|
|
<div class="shrink-0" data-part="item" @click="useEvent('identity:change', identity)">
|
2024-06-21 04:09:09 +02:00
|
|
|
<Avatar class="h-12 w-12 rounded ring-1 ring-white/5" :src="identity.account.avatar"
|
|
|
|
|
:alt="`${identity.account.acct}'s avatar'`" />
|
2024-06-10 05:24:55 +02:00
|
|
|
</div>
|
|
|
|
|
<div data-part="item" class="flex flex-col items-start justify-around grow overflow-hidden"
|
|
|
|
|
@click="useEvent('identity:change', identity)">
|
|
|
|
|
<div class="flex flex-row items-center justify-between w-full">
|
2024-07-22 01:23:29 +02:00
|
|
|
<div class="font-semibold text-gray-200 line-clamp-1 break-all">
|
2024-06-10 05:24:55 +02:00
|
|
|
{{
|
2024-06-19 08:16:28 +02:00
|
|
|
identity.account.display_name }}
|
2024-06-10 05:24:55 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-07-22 01:23:29 +02:00
|
|
|
<span class="text-gray-400 text-sm line-clamp-1 break-all w-full">
|
2024-06-10 05:24:55 +02:00
|
|
|
@{{
|
2024-06-19 08:16:28 +02:00
|
|
|
identity.account.acct
|
|
|
|
|
}}
|
2024-06-10 05:24:55 +02:00
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<button data-part="item"
|
|
|
|
|
class="shrink-0 ml-6 size-12 ring-white/5 ring-1 flex items-center justify-center rounded"
|
|
|
|
|
@click="$emit('signOut', identity.id)">
|
2024-07-22 01:23:29 +02:00
|
|
|
<iconify-icon icon="tabler:logout" class="size-6 text-gray-200" width="none" />
|
2024-06-10 05:24:55 +02:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</Menu.Item>
|
2024-07-21 15:33:32 +02:00
|
|
|
<Menu.Item value="" v-if="identity">
|
2024-06-19 08:16:28 +02:00
|
|
|
<NuxtLink href="/settings" class="w-full">
|
2024-11-29 22:29:43 +01:00
|
|
|
<ButtonBase theme="ghost" class="w-full !justify-start">
|
2024-06-27 15:03:03 +02:00
|
|
|
<Icon icon="tabler:adjustments" class="!size-6" />
|
|
|
|
|
<span class="shrink-0 line-clamp-1">Settings</span>
|
|
|
|
|
</ButtonBase>
|
2024-06-19 08:16:28 +02:00
|
|
|
</NuxtLink>
|
|
|
|
|
</Menu.Item>
|
2024-06-10 05:24:55 +02:00
|
|
|
<Menu.Item value="">
|
2024-11-29 22:29:43 +01:00
|
|
|
<ButtonBase @click="$emit('signIn')" theme="ghost" class="w-full !justify-start">
|
2024-06-27 15:03:03 +02:00
|
|
|
<Icon icon="tabler:user-plus" class="!size-6" />
|
|
|
|
|
<span class="shrink-0 line-clamp-1">Add new account</span>
|
|
|
|
|
</ButtonBase>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
2024-07-21 15:33:32 +02:00
|
|
|
<Menu.Item value="" v-if="!identity">
|
2024-06-16 02:04:17 +02:00
|
|
|
<NuxtLink href="/register" class="w-full">
|
2024-06-28 02:09:05 +02:00
|
|
|
<ButtonBase theme="outline" class="w-full !justify-start">
|
2024-06-27 15:03:03 +02:00
|
|
|
<Icon icon="tabler:certificate" class="!size-6" />
|
|
|
|
|
<span class="shrink-0 line-clamp-1">Create new account</span>
|
|
|
|
|
</ButtonBase>
|
2024-06-16 02:04:17 +02:00
|
|
|
</NuxtLink>
|
|
|
|
|
</Menu.Item>
|
2024-06-10 05:24:55 +02:00
|
|
|
</div>
|
|
|
|
|
</template>
|
2024-06-21 04:09:09 +02:00
|
|
|
</AdaptiveDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { Menu } from "@ark-ui/vue";
|
2024-06-27 15:03:03 +02:00
|
|
|
import ButtonBase from "~/packages/ui/components/buttons/button.vue";
|
|
|
|
|
import Icon from "~/packages/ui/components/icons/icon.vue";
|
2024-06-21 04:09:09 +02:00
|
|
|
import Avatar from "../avatars/avatar.vue";
|
|
|
|
|
import AdaptiveDropdown from "../dropdowns/AdaptiveDropdown.vue";
|
2024-06-10 05:24:55 +02:00
|
|
|
|
|
|
|
|
defineEmits<{
|
|
|
|
|
signIn: [];
|
|
|
|
|
signOut: [identityId: string];
|
|
|
|
|
}>();
|
|
|
|
|
</script>
|