1
0
mirror of https://github.com/elk-zone/elk synced 2024-11-27 22:38:11 +09:00
elk/components/user/UserPicker.vue

31 lines
794 B
Vue
Raw Normal View History

<script setup lang="ts">
import type { UserLogin } from '~/types'
const all = useUsers()
const router = useRouter()
const switchUser = (user: UserLogin) => {
if (user.account.id === currentUser.value?.account.id)
router.push(getAccountRoute(user.account))
else
loginTo(user)
}
</script>
<template>
<div flex="~ col" pb8 px4 gap-6 w-20 h-full justify-end>
<template v-for="user of all" :key="user.id">
<button
flex rounded
cursor-pointer
aria-label="Switch user"
:class="user.account.id === currentUser?.account.id ? '' : 'grayscale'"
hover:filter-none
@click="switchUser(user)"
>
<AccountAvatar w-12 h-12 :account="user.account" :hover-card="false" />
</button>
</template>
</div>
</template>