feat: add hover card for user list

This commit is contained in:
三咲智子 2022-11-29 01:24:39 +08:00
parent fd3e758336
commit d2c4d62cf5
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E
4 changed files with 14 additions and 3 deletions

View file

@ -3,6 +3,7 @@ import type { Account } from 'masto'
const { account } = defineProps<{ const { account } = defineProps<{
account: Account account: Account
hoverCard?: boolean
}>() }>()
cacheAccount(account) cacheAccount(account)
@ -10,7 +11,11 @@ cacheAccount(account)
<template> <template>
<div flex justify-between hover:bg-active transition-100> <div flex justify-between hover:bg-active transition-100>
<AccountInfo :account="account" hover p1 as="router-link" :to="getAccountPath(account)" /> <AccountInfo
:account="account" hover p1 as="router-link"
:hover-card="hoverCard"
:to="getAccountPath(account)"
/>
<div h-full p1> <div h-full p1>
<AccountFollowButton :account="account" /> <AccountFollowButton :account="account" />
</div> </div>

View file

@ -3,14 +3,16 @@ import type { Account } from 'masto'
defineProps<{ defineProps<{
account: Account account: Account
disabled?: boolean
}>() }>()
</script> </script>
<template> <template>
<VMenu placement="bottom-start" :delay="{ show: 500, hide: 100 }"> <VMenu v-if="!disabled" placement="bottom-start" :delay="{ show: 500, hide: 100 }">
<slot /> <slot />
<template #popper> <template #popper>
<AccountHoverCard :account="account" /> <AccountHoverCard :account="account" />
</template> </template>
</VMenu> </VMenu>
<slot v-else />
</template> </template>

View file

@ -4,6 +4,7 @@ import type { Account } from 'masto'
const { account, as = 'div' } = defineProps<{ const { account, as = 'div' } = defineProps<{
account: Account account: Account
as?: string as?: string
hoverCard?: boolean
}>() }>()
defineOptions({ defineOptions({
@ -15,7 +16,9 @@ defineOptions({
<!-- This is sometimes (like in the sidebar) used directly as a button, and sometimes, like in follow notifications, as a link. I think this component may need a second refactor that either lets an implementation pass in a link or an action and adapt to what's passed in, or the implementations need to be updated to wrap in the action they want to take and this be just the layout for these items --> <!-- This is sometimes (like in the sidebar) used directly as a button, and sometimes, like in follow notifications, as a link. I think this component may need a second refactor that either lets an implementation pass in a link or an action and adapt to what's passed in, or the implementations need to be updated to wrap in the action they want to take and this be just the layout for these items -->
<template> <template>
<component :is="as" flex gap-3 v-bind="$attrs"> <component :is="as" flex gap-3 v-bind="$attrs">
<AccountHoverWrapper :disabled="!hoverCard" :account="account">
<AccountAvatar :account="account" w-12 h-12 /> <AccountAvatar :account="account" w-12 h-12 />
</AccountHoverWrapper>
<div flex="~ col"> <div flex="~ col">
<ContentRich font-bold :content="getDisplayName(account, { rich: true })" :emojis="account.emojis" /> <ContentRich font-bold :content="getDisplayName(account, { rich: true })" :emojis="account.emojis" />
<AccountHandle :account="account" text-sm /> <AccountHandle :account="account" text-sm />

View file

@ -11,6 +11,7 @@ const { paginator } = defineProps<{
<template #default="{ item }"> <template #default="{ item }">
<AccountCard <AccountCard
:account="item" :account="item"
hover-card
border="b base" py2 px4 border="b base" py2 px4
/> />
</template> </template>