-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ New notifications view, refactor all composables
- Loading branch information
1 parent
7b8a02d
commit e0c41bb
Showing
23 changed files
with
641 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<template> | ||
<div v-if="small" class="flex flex-row"> | ||
<Skeleton :enabled="!note" shape="rect" class="!h-6 w-6"> | ||
<NuxtLink :href="accountUrl"> | ||
<img class="h-6 w-6 rounded ring-1 ring-white/5" :src="note?.account.avatar" | ||
:alt="`${note?.account.acct}'s avatar`" /> | ||
</NuxtLink> | ||
</Skeleton> | ||
<div class="flex flex-col items-start justify-around ml-4 grow overflow-hidden"> | ||
<div class="flex flex-row text-sm items-center justify-between w-full"> | ||
<NuxtLink :href="accountUrl" class="font-semibold text-gray-200 line-clamp-1 break-all"> | ||
<Skeleton :enabled="!note" :min-width="90" :max-width="170" shape="rect"> | ||
{{ | ||
note?.account.display_name }} | ||
</Skeleton> | ||
</NuxtLink> | ||
<NuxtLink :href="noteUrl" class="text-gray-400 ml-2 line-clamp-1 break-all shrink-0"> | ||
<Skeleton :enabled="!note" :min-width="50" :max-width="100" shape="rect"> | ||
{{ timeAgo }} | ||
</Skeleton> | ||
</NuxtLink> | ||
</div> | ||
</div> | ||
</div> | ||
<div v-else class="flex flex-row"> | ||
<Skeleton :enabled="!note" shape="rect" class="!h-12 w-12"> | ||
<NuxtLink :href="accountUrl"> | ||
<img class="h-12 w-12 rounded ring-1 ring-white/5" :src="note?.account.avatar" | ||
:alt="`${note?.account.acct}'s avatar`" /> | ||
</NuxtLink> | ||
</Skeleton> | ||
<div class="flex flex-col items-start justify-around ml-4 grow overflow-hidden"> | ||
<div class="flex flex-row items-center justify-between w-full"> | ||
<NuxtLink :href="accountUrl" class="font-semibold text-gray-200 line-clamp-1 break-all"> | ||
<Skeleton :enabled="!note" :min-width="90" :max-width="170" shape="rect"> | ||
{{ | ||
note?.account.display_name }} | ||
</Skeleton> | ||
</NuxtLink> | ||
<NuxtLink :href="noteUrl" class="text-gray-400 text-sm ml-2 line-clamp-1 break-all shrink-0"> | ||
<Skeleton :enabled="!note" :min-width="50" :max-width="100" shape="rect"> | ||
{{ timeAgo }} | ||
</Skeleton> | ||
</NuxtLink> | ||
</div> | ||
<span class="text-gray-400 text-sm line-clamp-1 break-all w-full"> | ||
<Skeleton :enabled="!note" :min-width="130" :max-width="250" shape="rect"> | ||
@{{ | ||
note?.account.acct | ||
}} | ||
</Skeleton> | ||
</span> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import type { Status } from '~/types/mastodon/status'; | ||
const props = defineProps<{ | ||
note?: Status; | ||
small?: boolean; | ||
}>(); | ||
const noteUrl = props.note && `/@${props.note.account.acct}/${props.note.id}`; | ||
const accountUrl = props.note && `/@${props.note.account.acct}`; | ||
const timeAgo = useTimeAgo(props.note?.created_at ?? 0); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<template> | ||
<div class="flex flex-col p-1 bg-dark-400"> | ||
<div class="px-4 pt-2 pb-3 flex flex-row gap-2 items-center"> | ||
<Skeleton :enabled="!notification" shape="rect" class="!h-6" :min-width="40" :max-width="100" | ||
width-unit="%"> | ||
<Icon :name="icon" class="h-6 w-6 text-gray-200" aria-hidden="true" /> | ||
<img v-if="notification?.account?.avatar" :src="notification?.account.avatar" | ||
:alt="`${notification?.account.acct}'s avatar'`" class="h-6 w-6 rounded ring-1 ring-white/10" /> | ||
<span class="text-gray-200"><strong v-html="accountName"></strong> {{ text }}</span> | ||
</Skeleton> | ||
</div> | ||
<div> | ||
<SocialElementsNotesNote v-if="notification?.status || !notification" :note="notification?.status" | ||
:small="true" /> | ||
<div v-else-if="notification.account" class="p-6 ring-1 ring-white/5 bg-dark-800"> | ||
<SocialElementsUsersSmallCard :account="notification.account" /> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import type { Notification } from '~/types/mastodon/notification'; | ||
const props = defineProps<{ | ||
notification?: Notification; | ||
}>(); | ||
const accountName = useParsedContent(props.notification?.account?.display_name ?? '', props.notification?.account?.emojis ?? [], []); | ||
const text = computed(() => { | ||
if (!props.notification) return ''; | ||
switch (props.notification.type) { | ||
case 'mention': | ||
return 'mentioned you'; | ||
case 'reblog': | ||
return 'reblogged your note'; | ||
case 'favourite': | ||
return 'liked your note'; | ||
case 'follow': | ||
return 'followed you'; | ||
case 'follow_request': | ||
return 'requested to follow you'; | ||
default: | ||
console.error('Unknown notification type', props.notification.type) | ||
return ''; | ||
} | ||
}); | ||
const icon = computed(() => { | ||
if (!props.notification) return ''; | ||
switch (props.notification.type) { | ||
case 'mention': | ||
return 'tabler:at'; | ||
case 'reblog': | ||
return 'tabler:repeat'; | ||
case 'favourite': | ||
return 'tabler:heart'; | ||
case 'follow': | ||
return 'tabler:plus'; | ||
case 'follow_request': | ||
return 'tabler:plus'; | ||
default: | ||
return ''; | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.