mirror of
https://github.com/elk-zone/elk.git
synced 2025-05-06 07:15:04 +03:00
feat: account switcher sidebar (#460)
* feat: account switcher sidebar * fix: defer loading sidebar until masto initialised * fix: only show user switcher for 2 or more accounts * chore: use `ofetch` (newer version of `ohymfetch`) * chore: early alpha warning * fix: handle missing user in github preview * refactor: avoid circular auto-import Co-authored-by: Daniel Roe <daniel@roe.dev>
This commit is contained in:
parent
15b59ae9b9
commit
cd85871d01
11 changed files with 78 additions and 25 deletions
components/user
30
components/user/UserPicker.vue
Normal file
30
components/user/UserPicker.vue
Normal file
|
@ -0,0 +1,30 @@
|
|||
<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>
|
Loading…
Add table
Add a link
Reference in a new issue