ui: improve account switcher

This commit is contained in:
Anthony Fu 2022-11-30 15:30:17 +08:00
parent b150d6d65e
commit 9ee51a5831
5 changed files with 20 additions and 17 deletions

View file

@ -21,7 +21,7 @@ defineProps<{
</div>
<div flex items-center>
<slot name="actions" />
<NavUser v-if="isSmallScreen" />
<NavUser v-if="isMediumScreen" />
</div>
</div>
<slot name="header" />

View file

@ -16,6 +16,7 @@ const { t } = useI18n()
<NavSideItem :text="t('nav_side.favourites')" to="/favourites" icon="i-ri:heart-3-line" />
<NavSideItem :text="t('nav_side.bookmarks')" to="/bookmarks" icon="i-ri:bookmark-line " />
<NavSideItem
v-if="isMediumScreen"
:text="currentUser.account.displayName"
:to="getAccountPath(currentUser.account)"
icon="i-ri:account-circle-line"

View file

@ -28,7 +28,7 @@ const switchUser = (user: UserLogin) => {
aria-label="Switch user"
@click="switchUser(user)"
>
<AccountInfo :account="user.account" />
<AccountInfo :account="user.account" :hover-card="false" />
<div flex-auto />
<div v-if="user.token === currentUser?.token" i-ri:check-line text-primary mya text-2xl />
</button>

View file

@ -3,3 +3,4 @@ import { breakpointsTailwind } from '@vueuse/core'
export const breakpoints = useBreakpoints(breakpointsTailwind)
export const isSmallScreen = breakpoints.smallerOrEqual('md')
export const isMediumScreen = breakpoints.smallerOrEqual('lg')

View file

@ -21,23 +21,24 @@
<div sticky top-0 h-screen flex="~ col">
<slot name="right">
<UserSignInEntry v-if="!currentUser" />
<VDropdown
v-if="currentUser"
:distance="0"
placement="bottom-end"
>
<button
m5 p2 rounded-full text-start w-full
<div v-if="currentUser" py6 px4 w-full flex="~" items-center justify-between>
<NuxtLink
p2 rounded-full text-start w-full
hover:bg-active cursor-pointer transition-100
class="md:(w-7.5/10 rounded-5)"
aria-label="Switch account"
:to="getAccountPath(currentUser.account)"
>
<AccountInfo :account="currentUser.account" md:flex="col" md:break-words />
</button>
<template #popper>
<UserSwitcher />
</template>
</VDropdown>
<AccountInfo :account="currentUser.account" md:break-words />
</NuxtLink>
<VDropdown :distance="0" placement="bottom-end">
<button btn-action-icon aria-label="Switch account">
<div i-ri:more-2-line />
</button>
<template #popper>
<UserSwitcher />
</template>
</VDropdown>
</div>
<div flex-auto />
<NavFooter />
</slot>