feat: show hover card in more places

This commit is contained in:
三咲智子 2022-11-25 18:54:49 +08:00
parent 569ae00284
commit bb05003fa3
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E
7 changed files with 32 additions and 19 deletions

View file

@ -3,9 +3,25 @@ import type { Account } from 'masto'
defineProps<{ defineProps<{
account: Account account: Account
hover?: boolean
}>() }>()
defineOptions({
inheritAttrs: false,
})
</script> </script>
<template> <template>
<img :src="account.avatar" :alt="account.username" loading="lazy" rounded-full bg-gray:10> <div relative flex-shrink-0>
<div group>
<AccountHoverCard v-if="hover" top="-3.2" left="-4.4" absolute :account="account" op0 pointer-events-none group-hover="pointer-events-auto op100 scale-100" delay-250 transition transform scale-20 class="ease-[cubic-bezier(0.4, 0.0, 0.2, 1)]" />
<img
:src="account.avatar"
:alt="account.username"
loading="lazy"
rounded-full bg-gray:10
v-bind="$attrs"
>
</div>
</div>
</template> </template>

View file

@ -10,7 +10,7 @@ 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" p1 /> <AccountInfo :account="account" hover p1 />
<div h-full p1> <div h-full p1>
<AccountFollowButton :account="account" /> <AccountFollowButton :account="account" />
</div> </div>

View file

@ -5,6 +5,7 @@ const { account, link = true, fullServer = false } = defineProps<{
account: Account account: Account
link?: boolean link?: boolean
fullServer?: boolean fullServer?: boolean
hover?: boolean
}>() }>()
const accountHandle = $(useAccountHandle(account, fullServer)) const accountHandle = $(useAccountHandle(account, fullServer))
@ -14,7 +15,7 @@ const accountHandle = $(useAccountHandle(account, fullServer))
<div flex gap-3> <div flex gap-3>
<div> <div>
<NuxtLink :to="link ? getAccountPath(account) : null"> <NuxtLink :to="link ? getAccountPath(account) : null">
<AccountAvatar :account="account" w-12 h-12 /> <AccountAvatar :account="account" :hover="hover" w-12 h-12 />
</NuxtLink> </NuxtLink>
</div> </div>
<NuxtLink flex flex-col :to="link ? getAccountPath(account) : null"> <NuxtLink flex flex-col :to="link ? getAccountPath(account) : null">

View file

@ -9,7 +9,7 @@ const { link = true } = defineProps<{
<template> <template>
<NuxtLink :to="link ? getAccountPath(account) : undefined" min-w-0 flex gap-1 items-center> <NuxtLink :to="link ? getAccountPath(account) : undefined" min-w-0 flex gap-1 items-center>
<AccountAvatar :account="account" w-5 h-5 /> <AccountAvatar :account="account" w-5 h-5 hover />
<ContentRichSetup :content="getDisplayName(account)" :emojis="account.emojis" /> <ContentRichSetup :content="getDisplayName(account)" :emojis="account.emojis" />
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -11,14 +11,16 @@ const { notification } = defineProps<{
<template v-if="notification.type === 'follow'"> <template v-if="notification.type === 'follow'">
<div flex ml-4 items-center> <div flex ml-4 items-center>
<div i-ri:user-follow-fill mr-3 color-primary /> <div i-ri:user-follow-fill mr-3 color-primary />
<AccountLink :account="notification.account" mr1 /> followed you <AccountInlineInfo :account="notification.account" mr1 />
followed you
</div> </div>
<AccountCard :account="notification.account" p3 /> <AccountCard :account="notification.account" p3 />
</template> </template>
<template v-if="notification.type === 'follow_request'"> <template v-if="notification.type === 'follow_request'">
<div flex ml-4 items-center> <div flex ml-4 items-center>
<div i-ri:user-follow-fill mr-3 /> <div i-ri:user-follow-fill mr-3 />
<AccountLink :account="notification.account" mr1 /> requested to follow you <AccountInlineInfo :account="notification.account" mr1 />
requested to follow you
</div> </div>
<!-- TODO: accept request --> <!-- TODO: accept request -->
<AccountCard :account="notification.account" p3 /> <AccountCard :account="notification.account" p3 />
@ -26,14 +28,16 @@ const { notification } = defineProps<{
<template v-if="notification.type === 'favourite'"> <template v-if="notification.type === 'favourite'">
<div flex ml-4 items-center> <div flex ml-4 items-center>
<div i-ri:heart-fill mr-3 color-red /> <div i-ri:heart-fill mr-3 color-red />
<AccountLink :account="notification.account" mr1 /> favourited your post <AccountInlineInfo :account="notification.account" mr1 />
favourited your post
</div> </div>
<StatusCard :status="notification.status!" p3 /> <StatusCard :status="notification.status!" p3 />
</template> </template>
<template v-if="notification.type === 'reblog'"> <template v-if="notification.type === 'reblog'">
<div flex ml-4 items-center> <div flex ml-4 items-center>
<div i-ri:repeat-fill mr-3 color-green /> <div i-ri:repeat-fill mr-3 color-green />
<AccountLink :account="notification.account" mr1 /> reblogged your post <AccountInlineInfo :account="notification.account" mr1 />
reblogged your post
</div> </div>
<StatusCard :status="notification.status!" p3 /> <StatusCard :status="notification.status!" p3 />
</template> </template>

View file

@ -12,7 +12,7 @@ const accountHandle = $(useAccountHandle(account))
<template> <template>
<NuxtLink <NuxtLink
:to="link ? getAccountPath(account) : undefined" :to="link ? getAccountPath(account) : undefined"
flex="col 1" min-w-0 md:flex="~ gap-2" md:items-center flex="~ col" min-w-0 md:flex="~ row gap-2" md:items-center
> >
<ContentRichSetup font-bold break-words :content="getDisplayName(account)" :emojis="account.emojis" /> <ContentRichSetup font-bold break-words :content="getDisplayName(account)" :emojis="account.emojis" />
<p op35 text-sm> <p op35 text-sm>

View file

@ -7,10 +7,7 @@ const props = withDefaults(
actions?: boolean actions?: boolean
hover?: boolean hover?: boolean
}>(), }>(),
{ { actions: true },
actions: true,
hover: true,
},
) )
const status = $computed(() => { const status = $computed(() => {
@ -80,12 +77,7 @@ const timeago = useTimeAgo(() => status.createdAt, {
</div> </div>
</div> </div>
<div flex gap-4> <div flex gap-4>
<div relative flex-shrink-0> <AccountAvatar mt1 w-12 h-12 :account="status.account" hover />
<div group>
<AccountHoverCard top="-3.2" left="-4.4" absolute :account="status.account" op0 pointer-events-none group-hover="pointer-events-auto op100 scale-100" delay-250 transition transform scale-20 class="ease-[cubic-bezier(0.4, 0.0, 0.2, 1)]" />
<AccountAvatar mt1 w-12 h-12 :account="status.account" />
</div>
</div>
<div flex="~ col 1" min-w-0> <div flex="~ col 1" min-w-0>
<div flex> <div flex>
<StatusAccountDetails :account="status.account" /> <StatusAccountDetails :account="status.account" />