1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-07-03 04:56:48 +01:00

feat: display status meta over card (#325)

This commit is contained in:
patak 2022-12-06 12:07:17 +01:00 committed by GitHub
parent 22a82bca22
commit 8537f9e0ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 115 additions and 82 deletions

View file

@ -1,9 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Account } from 'masto' import type { Account } from 'masto'
const { link = true } = defineProps<{ const { link = true, avatar = true } = defineProps<{
account: Account account: Account
link?: boolean link?: boolean
avatar?: boolean
}>() }>()
</script> </script>
@ -14,7 +15,7 @@ const { link = true } = defineProps<{
:class="link ? 'text-link-rounded ml-0 pl-0' : ''" :class="link ? 'text-link-rounded ml-0 pl-0' : ''"
min-w-0 flex gap-1 items-center min-w-0 flex gap-1 items-center
> >
<AccountAvatar :account="account" w-5 h-5 /> <AccountAvatar v-if="avatar" :account="account" w-5 h-5 />
<ContentRich ws-nowrap :content="getDisplayName(account, { rich: true })" :emojis="account.emojis" /> <ContentRich ws-nowrap :content="getDisplayName(account, { rich: true })" :emojis="account.emojis" />
</NuxtLink> </NuxtLink>
</AccountHoverWrapper> </AccountHoverWrapper>

View file

@ -0,0 +1,5 @@
<template>
<div flex="~ wrap" gap-1 items-center absolute top-0 pt-2 left-0 px-3>
<slot />
</div>
</template>

View file

@ -12,6 +12,12 @@ const featureFlags = useFeatureFlags()
> >
{{ $t('feature_flag.virtual_scroll') }} {{ $t('feature_flag.virtual_scroll') }}
</CommonDropdownItem> </CommonDropdownItem>
<CommonDropdownItem
:checked="featureFlags.experimentalAvatarOnAvatar"
@click="toggleFeatureFlag('experimentalAvatarOnAvatar')"
>
{{ $t('feature_flag.avatar_on_avatar') }}
</CommonDropdownItem>
</template> </template>
</CommonDropdown> </CommonDropdown>
</template> </template>

View file

@ -7,50 +7,47 @@ const { notification } = defineProps<{
</script> </script>
<template> <template>
<article flex flex-col> <article flex flex-col relative>
<template v-if="notification.type === 'follow'"> <template v-if="notification.type === 'follow'">
<div flex ml-4 items-center> <div flex ml-4 items-center absolute class="-top-2.5" right-2 px-2>
<div i-ri:user-follow-fill mr-3 color-primary /> <div i-ri:user-follow-fill mr-1 color-primary />
<AccountInlineInfo :account="notification.account" mr1 /> <AccountInlineInfo :account="notification.account" mr1 />
{{ $t('notification.followed_you') }} {{ $t('notification.followed_you') }}
</div> </div>
<AccountCard :account="notification.account" p3 /> <AccountCard :account="notification.account" />
</template> </template>
<template v-else-if="notification.type === 'follow_request'"> <template v-else-if="notification.type === 'follow_request'">
<div flex ml-4 items-center> <div flex ml-4 items-center class="-top-2.5" absolute right-2 px-2>
<div i-ri:user-follow-fill mr-3 /> <div i-ri:user-follow-fill mr-1 />
<AccountInlineInfo :account="notification.account" mr1 /> <AccountInlineInfo :account="notification.account" mr1 />
{{ $t('notification.request_to_follow') }}
</div> </div>
<!-- TODO: accept request --> <!-- TODO: accept request -->
<AccountCard :account="notification.account" p3 /> <AccountCard :account="notification.account" />
</template> </template>
<template v-else-if="notification.type === 'favourite'"> <template v-else-if="notification.type === 'favourite'">
<div flex ml-4 items-center> <CommonMetaWrapper>
<div i-ri:heart-fill mr-3 color-red /> <div i-ri:heart-fill mr-1 color-red />
<AccountInlineInfo :account="notification.account" mr1 /> <AccountInlineInfo :account="notification.account" mr1 />
{{ $t('notification.favourited_post') }} </CommonMetaWrapper>
</div> <StatusCard :status="notification.status!" :decorated="true" />
<StatusCard :status="notification.status!" context="notifications" p3 />
</template> </template>
<template v-else-if="notification.type === 'reblog'"> <template v-else-if="notification.type === 'reblog'">
<div flex ml-4 items-center> <CommonMetaWrapper>
<div i-ri:repeat-fill mr-3 color-green /> <div i-ri:repeat-fill mr-1 color-green />
<AccountInlineInfo :account="notification.account" mr1 /> <AccountInlineInfo :account="notification.account" mr1 />
{{ $t('notification.reblogged_post') }} </CommonMetaWrapper>
</div> <StatusCard :status="notification.status!" :decorated="true" />
<StatusCard :status="notification.status!" context="notifications" p3 />
</template> </template>
<template v-else-if="notification.type === 'update'"> <template v-else-if="notification.type === 'update'">
<div flex ml-4 items-center> <CommonMetaWrapper>
<div i-ri:edit-2-fill mr-3 text-secondary /> <div i-ri:edit-2-fill mr-1 text-secondary />
<AccountInlineInfo :account="notification.account" mr1 /> <AccountInlineInfo :account="notification.account" mr1 />
{{ $t('notification.update_status') }} {{ $t('notification.update_status') }}
</div> </CommonMetaWrapper>
<StatusCard :status="notification.status!" context="notifications" p3 /> <StatusCard :status="notification.status!" :decorated="true" />
</template> </template>
<template v-else-if="notification.type === 'mention' || notification.type === 'poll' || notification.type === 'status'"> <template v-else-if="notification.type === 'mention' || notification.type === 'poll' || notification.type === 'status'">
<StatusCard :status="notification.status!" context="notifications" p3 /> <StatusCard :status="notification.status!" />
</template> </template>
<template v-else> <template v-else>
<div text-red font-bold> <div text-red font-bold>

View file

@ -13,8 +13,8 @@ const isExpanded = ref(false)
</script> </script>
<template> <template>
<article flex flex-col> <article flex flex-col relative>
<div flex ml-4 items-center> <div flex items-center top-0 left-2 pt-2 px-3>
<div i-ri:user-follow-fill mr-3 color-primary aria-hidden="true" /> <div i-ri:user-follow-fill mr-3 color-primary aria-hidden="true" />
<template v-if="addSR"> <template v-if="addSR">
<span <span
@ -30,24 +30,26 @@ const isExpanded = ref(false)
{{ $t('notification.followed_you_count', count, { named: { followers: count } }) }} {{ $t('notification.followed_you_count', count, { named: { followers: count } }) }}
</span> </span>
</div> </div>
<div v-if="isExpanded"> <div pt-1 pb-2>
<AccountCard <div v-if="isExpanded">
v-for="item in items.items" <AccountCard
:key="item.id" v-for="item in items.items"
:account="item.account" :key="item.id"
p3 :account="item.account"
/> p3
</div> />
<div v-else flex="~ wrap gap-1" p4> </div>
<AccountHoverWrapper <div v-else flex="~ wrap gap-1" p4>
v-for="item in items.items" <AccountHoverWrapper
:key="item.id" v-for="item in items.items"
:account="item.account" :key="item.id"
> :account="item.account"
<NuxtLink :to="getAccountRoute(item.account)"> >
<AccountAvatar :account="item.account" w-8 h-8 /> <NuxtLink :to="getAccountRoute(item.account)">
</NuxtLink> <AccountAvatar :account="item.account" w-12 h-12 />
</AccountHoverWrapper> </NuxtLink>
</AccountHoverWrapper>
</div>
</div> </div>
</article> </article>
</template> </template>

View file

@ -14,7 +14,8 @@ function groupItems(items: Notification[]): (Notification | GroupedNotifications
let followGroup: Notification[] = [] let followGroup: Notification[] = []
const bump = () => { const bump = () => {
if (followGroup.length === 1) { const alwaysGroup = true
if (!alwaysGroup && followGroup.length === 1) {
results.push(followGroup[0]) results.push(followGroup[0])
followGroup = [] followGroup = []
} }
@ -58,13 +59,13 @@ const { clearNotifications } = useNotifications()
<NotificationGroupedFollow <NotificationGroupedFollow
v-if="item.type === 'grouped-follow'" v-if="item.type === 'grouped-follow'"
:items="item" :items="item"
border="b base" pt-4 border="b base"
/> />
<NotificationCard <NotificationCard
v-else v-else
:notification="item" :notification="item"
hover:bg-active hover:bg-active
border="b base" pt-4 border="b base"
/> />
</template> </template>
</template> </template>

View file

@ -7,8 +7,10 @@ const props = withDefaults(
actions?: boolean actions?: boolean
context?: FilterContext context?: FilterContext
hover?: boolean hover?: boolean
decorated?: boolean
showReplyTo?: boolean
}>(), }>(),
{ actions: true }, { actions: true, showReplyTo: true },
) )
const status = $computed(() => { const status = $computed(() => {
@ -53,25 +55,28 @@ const filter = $computed(() => filterResult?.filter)
// clean up when masto.js supports explicit versions: https://github.com/neet/masto.js/issues/722 // clean up when masto.js supports explicit versions: https://github.com/neet/masto.js/issues/722
const filterPhrase = $computed(() => filter?.phrase || (filter as any)?.title) const filterPhrase = $computed(() => filter?.phrase || (filter as any)?.title)
const isFiltered = $computed(() => filterPhrase && (props.context ? filter?.context.includes(props.context) : false)) const isFiltered = $computed(() => filterPhrase && (props.context ? filter?.context.includes(props.context) : false))
const avatarOnAvatar = $(computedEager(() => useFeatureFlags().experimentalAvatarOnAvatar))
</script> </script>
<template> <template>
<div v-if="filter?.filterAction !== 'hide'" :id="`status-${status.id}`" ref="el" flex flex-col gap-2 px-4 transition-100 :class="{ 'hover:bg-active': hover }" tabindex="0" focus:outline-none focus-visible:ring="2 primary" @click="onclick" @keydown.enter="onclick"> <div v-if="filter?.filterAction !== 'hide'" :id="`status-${status.id}`" ref="el" relative flex flex-col gap-2 px-4 pt-3 pb-4 transition-100 :class="{ 'hover:bg-active': hover }" tabindex="0" focus:outline-none focus-visible:ring="2 primary" @click="onclick" @keydown.enter="onclick">
<div v-if="rebloggedBy" pl8> <StatusReplyingTo v-if="showReplyTo" :status="status" />
<div flex="~ wrap" gap-1 items-center text-secondary text-sm> <CommonMetaWrapper v-if="rebloggedBy" text-secondary text-sm>
<div i-ri:repeat-fill mr-1 /> <div i-ri:repeat-fill mr-1 text-primary />
<i18n-t keypath="status.reblogged"> <AccountInlineInfo font-bold :account="rebloggedBy" :avatar="!avatarOnAvatar" />
<AccountInlineInfo font-bold :account="rebloggedBy" /> </CommonMetaWrapper>
</i18n-t> <div v-if="decorated || rebloggedBy || (showReplyTo && status.inReplyToAccountId)" h-4 />
</div>
</div>
<div flex gap-4> <div flex gap-4>
<div> <div relative>
<AccountHoverWrapper :account="status.account"> <AccountHoverWrapper :account="status.account" :class="rebloggedBy && avatarOnAvatar ? 'mt-4' : 'mt-1'">
<NuxtLink :to="getAccountRoute(status.account)" rounded-full> <NuxtLink :to="getAccountRoute(status.account)" rounded-full>
<AccountAvatar w-12 h-12 :account="status.account" /> <AccountAvatar w-12 h-12 :account="status.account" />
</NuxtLink> </NuxtLink>
</AccountHoverWrapper> </AccountHoverWrapper>
<div v-if="(rebloggedBy && avatarOnAvatar && rebloggedBy.id !== status.account.id)" absolute class="-top-1 -left-2" w-8 h-8 border-bg-base border-3 rounded-full>
<AccountAvatar :account="rebloggedBy" />
</div>
</div> </div>
<div flex="~ col 1" min-w-0> <div flex="~ col 1" min-w-0>
<div flex items-center> <div flex items-center>
@ -91,7 +96,6 @@ const isFiltered = $computed(() => filterPhrase && (props.context ? filter?.cont
</div> </div>
<StatusActionsMore :status="status" mr--2 /> <StatusActionsMore :status="status" mr--2 />
</div> </div>
<StatusReplyingTo v-if="status.inReplyToAccountId" :status="status" pt1 />
<div :class="status.visibility === 'direct' ? 'my3 p2 px5 br2 bg-fade rounded-3 rounded-tl-none' : ''"> <div :class="status.visibility === 'direct' ? 'my3 p2 px5 br2 bg-fade rounded-3 rounded-tl-none' : ''">
<StatusSpoiler :enabled="status.sensitive || isFiltered" :filter="filter?.filterAction"> <StatusSpoiler :enabled="status.sensitive || isFiltered" :filter="filter?.filterAction">
<template #spoiler> <template #spoiler>

View file

@ -1,5 +1,5 @@
<template> <template>
<div flex flex-col gap-2 px-4> <div flex flex-col gap-2 px-4 py-3>
<div flex gap-4> <div flex gap-4>
<div> <div>
<div w-12 h-12 rounded-full class="skeleton-loading-bg" /> <div w-12 h-12 rounded-full class="skeleton-loading-bg" />

View file

@ -25,7 +25,6 @@ const visibility = $computed(() => STATUS_VISIBILITIES.find(v => v.value === sta
<AccountInfo :account="status.account" /> <AccountInfo :account="status.account" />
</AccountHoverWrapper> </AccountHoverWrapper>
</NuxtLink> </NuxtLink>
<StatusReplyingTo v-if="status.inReplyToAccountId" :status="status" />
<div <div
:class="status.visibility === 'direct' ? 'my3 p2 px5 br2 bg-fade rounded-3 rounded-tl-none' : ''" :class="status.visibility === 'direct' ? 'my3 p2 px5 br2 bg-fade rounded-3 rounded-tl-none' : ''"
> >

View file

@ -9,14 +9,20 @@ const account = useAccountById(status.inReplyToAccountId!)
</script> </script>
<template> <template>
<NuxtLink <div v-if="status.inReplyToAccountId" absolute top-0 pt-2 right-0 px-4 flex="~ wrap" gap-1>
v-if="status.inReplyToId" <NuxtLink
flex="~ wrap" items-center text-sm text-secondary v-if="status.inReplyToId"
:to="getStatusInReplyToRoute(status)" flex="~ wrap" items-center font-bold text-sm text-secondary gap-1
:title="account ? `Replying to ${getDisplayName(account)}` : 'Replying to someone'" :to="getStatusInReplyToRoute(status)"
> :title="account ? `Replying to ${getDisplayName(account)}` : 'Replying to someone'"
<div i-ri:reply-fill rotate-180 text-secondary-light class="mr-1.5" /> >
<AccountInlineInfo v-if="account" :account="account" :link="false" /> <div i-ri:reply-fill class="scale-x-[-1]" text-secondary-light />
<span v-else>Someone</span> <template v-if="account?.id !== status.account.id">
</NuxtLink> <AccountInlineInfo v-if="account" :account="account" :link="false" />
<span v-else>Someone</span>
</template>
<span v-else>Thread</span>
<div i-ph:chats-fill text-primary text-lg />
</NuxtLink>
</div>
</template> </template>

View file

@ -8,6 +8,6 @@ defineProps<{
<template> <template>
<template v-for="status of timelines" :key="status.id"> <template v-for="status of timelines" :key="status.id">
<StatusCard :status="status" border="t base" pt-4 /> <StatusCard :status="status" border="t base" />
</template> </template>
</template> </template>

View file

@ -22,17 +22,17 @@ const virtualScroller = $(computedEager(() => useFeatureFlags().experimentalVirt
<template #default="{ item, active }"> <template #default="{ item, active }">
<template v-if="virtualScroller"> <template v-if="virtualScroller">
<DynamicScrollerItem :item="item" :active="active" tag="article"> <DynamicScrollerItem :item="item" :active="active" tag="article">
<StatusCard :status="item" border="b base" :context="context" py-3 /> <StatusCard :status="item" border="b base" :context="context" />
</DynamicScrollerItem> </DynamicScrollerItem>
</template> </template>
<template v-else> <template v-else>
<StatusCard :status="item" border="b base" :context="context" py-3 /> <StatusCard :status="item" border="b base" :context="context" />
</template> </template>
</template> </template>
<template #loading> <template #loading>
<StatusCardSkeleton border="b base" py-3 /> <StatusCardSkeleton border="b base" />
<StatusCardSkeleton border="b base" py-3 op50 /> <StatusCardSkeleton border="b base" op50 />
<StatusCardSkeleton border="b base" py-3 op25 /> <StatusCardSkeleton border="b base" op25 />
</template> </template>
</CommonPaginator> </CommonPaginator>
</template> </template>

View file

@ -3,6 +3,7 @@ import { STORAGE_KEY_FEATURE_FLAGS } from '~/constants'
export interface FeatureFlags { export interface FeatureFlags {
experimentalVirtualScroll: boolean experimentalVirtualScroll: boolean
experimentalAvatarOnAvatar: boolean
} }
export type FeatureFlagsMap = Record<string, FeatureFlags> export type FeatureFlagsMap = Record<string, FeatureFlags>
@ -11,6 +12,7 @@ export const allFeatureFlags = useLocalStorage<FeatureFlagsMap>(STORAGE_KEY_FEAT
export function getDefaultFeatureFlags(): FeatureFlags { export function getDefaultFeatureFlags(): FeatureFlags {
return { return {
experimentalVirtualScroll: false, experimentalVirtualScroll: false,
experimentalAvatarOnAvatar: true,
} }
} }

View file

@ -72,6 +72,7 @@
"status_not_found": "Status not found" "status_not_found": "Status not found"
}, },
"feature_flag": { "feature_flag": {
"avatar_on_avatar": "Avatar on Avatar",
"virtual_scroll": "Virtual Scrolling" "virtual_scroll": "Virtual Scrolling"
}, },
"help": { "help": {

View file

@ -23,6 +23,7 @@
"@iconify-json/carbon": "^1.1.11", "@iconify-json/carbon": "^1.1.11",
"@iconify-json/logos": "^1.1.19", "@iconify-json/logos": "^1.1.19",
"@iconify-json/material-symbols": "^1.1.25", "@iconify-json/material-symbols": "^1.1.25",
"@iconify-json/ph": "^1.1.3",
"@iconify-json/ri": "^1.1.4", "@iconify-json/ri": "^1.1.4",
"@iconify-json/twemoji": "^1.1.7", "@iconify-json/twemoji": "^1.1.7",
"@nuxtjs/i18n": "^8.0.0-beta.6", "@nuxtjs/i18n": "^8.0.0-beta.6",

View file

@ -52,7 +52,7 @@ onReactivated(() => {
<div v-if="status" min-h-100vh> <div v-if="status" min-h-100vh>
<template v-if="context"> <template v-if="context">
<template v-for="comment of context?.ancestors" :key="comment.id"> <template v-for="comment of context?.ancestors" :key="comment.id">
<StatusCard :status="comment" context="account" border="t base" py3 /> <StatusCard :status="comment" context="account" border="t base" :show-reply-to="false" />
</template> </template>
</template> </template>
@ -73,7 +73,7 @@ onReactivated(() => {
<template v-if="context"> <template v-if="context">
<template v-for="comment of context?.descendants" :key="comment.id"> <template v-for="comment of context?.descendants" :key="comment.id">
<StatusCard :status="comment" context="account" border="t base" py3 /> <StatusCard :status="comment" context="account" border="t base" />
</template> </template>
</template> </template>
@ -83,6 +83,6 @@ onReactivated(() => {
<StatusNotFound v-else :account="$route.params.account" :status="id" /> <StatusNotFound v-else :account="$route.params.account" :status="id" />
</template> </template>
<StatusCardSkeleton v-else border="b base" py-3 /> <StatusCardSkeleton v-else border="b base" />
</MainContent> </MainContent>
</template> </template>

View file

@ -6,6 +6,7 @@ specifiers:
'@iconify-json/carbon': ^1.1.11 '@iconify-json/carbon': ^1.1.11
'@iconify-json/logos': ^1.1.19 '@iconify-json/logos': ^1.1.19
'@iconify-json/material-symbols': ^1.1.25 '@iconify-json/material-symbols': ^1.1.25
'@iconify-json/ph': ^1.1.3
'@iconify-json/ri': ^1.1.4 '@iconify-json/ri': ^1.1.4
'@iconify-json/twemoji': ^1.1.7 '@iconify-json/twemoji': ^1.1.7
'@nuxtjs/i18n': ^8.0.0-beta.6 '@nuxtjs/i18n': ^8.0.0-beta.6
@ -71,6 +72,7 @@ devDependencies:
'@iconify-json/carbon': 1.1.11 '@iconify-json/carbon': 1.1.11
'@iconify-json/logos': 1.1.19 '@iconify-json/logos': 1.1.19
'@iconify-json/material-symbols': 1.1.25 '@iconify-json/material-symbols': 1.1.25
'@iconify-json/ph': 1.1.3
'@iconify-json/ri': 1.1.4 '@iconify-json/ri': 1.1.4
'@iconify-json/twemoji': 1.1.7 '@iconify-json/twemoji': 1.1.7
'@nuxtjs/i18n': 8.0.0-beta.6 '@nuxtjs/i18n': 8.0.0-beta.6
@ -662,6 +664,12 @@ packages:
'@iconify/types': 2.0.0 '@iconify/types': 2.0.0
dev: true dev: true
/@iconify-json/ph/1.1.3:
resolution: {integrity: sha512-QSzWMGF8GiBPW89RpQ3bEwEjuRWTv/xxskStUpK7tsXlz3qoPTEM5CQxDUpzUmc9luAWViqD/shIUiuNhUeolw==}
dependencies:
'@iconify/types': 2.0.0
dev: true
/@iconify-json/ri/1.1.4: /@iconify-json/ri/1.1.4:
resolution: {integrity: sha512-gAk2gQBVghgbMLOmbUCc3l4COMMH5sR3HhBqpjaPUFBbC4WsNNRyOD4RZgjlanU7DTgFrj4NarY5K2EkXaVxuw==} resolution: {integrity: sha512-gAk2gQBVghgbMLOmbUCc3l4COMMH5sR3HhBqpjaPUFBbC4WsNNRyOD4RZgjlanU7DTgFrj4NarY5K2EkXaVxuw==}
dependencies: dependencies: