elk/components/nav/button/Notification.vue
2025-01-01 19:28:07 +01:00

32 lines
1.2 KiB
Vue

<script setup lang="ts">
import { useHideBottomNavigationLabel } from '~/composables/settings'
import { STORAGE_KEY_LAST_ACCESSED_NOTIFICATION_ROUTE } from '~/constants'
defineProps<{
activeClass: string
}>()
const { notifications } = useNotifications()
const lastAccessedNotificationRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_NOTIFICATION_ROUTE, '')
const hideLabel = useHideBottomNavigationLabel()
</script>
<template>
<NuxtLink
:to="`/notifications/${lastAccessedNotificationRoute}`"
:aria-label="$t('nav.notifications')"
:active-class="activeClass"
flex flex-col items-center place-content-center h-full flex-1
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div flex relative>
<div aria-hidden="true" class="i-ri:notification-4-line" text-xl />
<div v-if="notifications" class="top-[-0.3rem] right-[-0.3rem]" absolute font-bold rounded-full h-4 w-4 text-xs bg-primary text-inverted flex items-center justify-center>
{{ notifications < 10 ? notifications : '•' }}
</div>
</div>
<span v-if="!hideLabel" text-xs>{{ $t('nav.notifications') }}</span>
</NuxtLink>
</template>