Refactor notification menu button

This commit is contained in:
Ramon Wenger 2024-10-17 16:52:49 +02:00
parent b833fa34b1
commit a01d058227
2 changed files with 33 additions and 24 deletions

View File

@ -1,8 +1,5 @@
<script setup lang="ts">
import NotificationPopover from "@/components/notifications/NotificationPopover.vue";
import NotificationPopoverContent from "@/components/notifications/NotificationPopoverContent.vue";
import { useCourseSessionsStore } from "@/stores/courseSessions";
import { useNotificationsStore } from "@/stores/notifications";
import { useNavigationAttributes } from "@/utils/navigation";
import { useRouteLookups } from "@/utils/route";
import {
@ -17,12 +14,12 @@ import log from "loglevel";
import { computed, onMounted } from "vue";
import DefaultNavigation from "./DefaultNavigation.vue";
import MobileMenuButton from "./MobileMenuButton.vue";
import NotificationButton from "./NotificationButton.vue";
import ProfileMenuButton from "./ProfileMenuButton.vue";
log.debug("MainNavigationBar created");
const courseSessionsStore = useCourseSessionsStore();
const notificationsStore = useNotificationsStore();
const {
inCockpit,
inCompetenceProfile,
@ -38,7 +35,6 @@ const {
hasCockpitMenu,
hasPreviewMenu,
hasAppointmentsMenu,
hasNotificationsMenu,
hasLearningMentor,
hasSessionTitle,
} = useNavigationAttributes();
@ -177,25 +173,7 @@ const mentorTabTitle = computed(() =>
</router-link>
<!-- Notification Bell & Menu -->
<div v-if="hasNotificationsMenu" class="nav-item leading-none">
<NotificationPopover>
<template #toggleButtonContent>
<div class="relative h-8 w-8">
<div>
<it-icon-notification class="h-8 w-8" />
<div
v-if="notificationsStore.hasUnread"
aria-label="unread notifications"
class="absolute inset-y-0 right-0 h-1.5 w-1.5 rounded-full bg-sky-500"
/>
</div>
</div>
</template>
<template #popoverContent>
<NotificationPopoverContent />
</template>
</NotificationPopover>
</div>
<NotificationButton />
<div
v-if="hasSessionTitle"

View File

@ -0,0 +1,31 @@
<script setup lang="ts">
import NotificationPopover from "@/components/notifications/NotificationPopover.vue";
import NotificationPopoverContent from "@/components/notifications/NotificationPopoverContent.vue";
import { useNotificationsStore } from "@/stores/notifications";
import { useNavigationAttributes } from "@/utils/navigation";
const notificationsStore = useNotificationsStore();
const { hasNotificationsMenu } = useNavigationAttributes();
</script>
<template>
<div v-if="hasNotificationsMenu" class="nav-item leading-none">
<NotificationPopover>
<template #toggleButtonContent>
<div class="relative h-8 w-8">
<div>
<it-icon-notification class="h-8 w-8" />
<div
v-if="notificationsStore.hasUnread"
aria-label="unread notifications"
class="absolute inset-y-0 right-0 h-1.5 w-1.5 rounded-full bg-sky-500"
/>
</div>
</div>
</template>
<template #popoverContent>
<NotificationPopoverContent />
</template>
</NotificationPopover>
</div>
</template>