Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/Components/IconNotification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
-->

<template>
<span v-if="showDot || showWarning" class="notifications-button__icon">
<!-- Modified IconBell from material design icons -->
<span class="notifications-button__icon">
<!-- Bell with SVG dot: warning state or pending-permission state (showDot but no count) -->
<svg
v-if="showWarning || (showDot && count === 0)"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
Expand All @@ -23,8 +24,17 @@
}"
d="M 21,6.5 C 21,8.43 19.43,10 17.5,10 15.57,10 14,8.43 14,6.5 14,4.57 15.57,3 17.5,3 19.43,3 21,4.57 21,6.5" />
</svg>
<!-- Plain bell for all other states (count badge handles the indicator) -->
<IconBell v-else :size="size" />
<!-- Numeric count badge (replaces the dot when there are real notifications) -->
<span
v-if="count > 0 && !showWarning"
:key="count"
class="notification__badge"
aria-hidden="true">
{{ count > 99 ? '99+' : count }}
</span>
</span>
<IconBell v-else class="notifications-button__icon" :size="size" />
</template>

<script setup>
Expand All @@ -41,6 +51,10 @@ defineProps({
type: Boolean,
default: false,
},
count: {
type: Number,
default: 0,
},
size: {
type: Number,
default: 20,
Expand Down
1 change: 1 addition & 0 deletions src/NotificationsApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<template #trigger>
<IconNotification
:size="20"
:count="notifications.length"
:showDot="notifications.length !== 0 || webNotificationsGranted === null"
:showWarning="hasThrottledPushNotifications" />
</template>
Expand Down Expand Up @@ -404,7 +405,7 @@
this._fetch(true)
},

/**

Check warning on line 408 in src/NotificationsApp.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "force" declaration
* Performs the AJAX request to retrieve the notifications
*/
async _fetch(force = false) {
Expand Down
29 changes: 29 additions & 0 deletions src/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

.notifications-button {
.notifications-button__icon {
position: relative;
display: inline-flex;
height: 20px;
}

Expand All @@ -18,6 +20,33 @@
}
}

// Numeric count badge — replaces the dot when count > 0
.notification__badge {
position: absolute;
top: -5px;
inset-inline-end: -8px;
min-width: 16px;
height: 16px;
padding: 0 3px;
border-radius: 8px;
background: #ff4402;
color: #fff;
font-size: 9px;
font-weight: 700;
line-height: 16px;
text-align: center;
pointer-events: none;
box-sizing: border-box;
// :key="count" forces remount on every change → animation re-fires automatically
animation: badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes badge-pop {
0% { transform: scale(0.5); }
70% { transform: scale(1.35); }
100% { transform: scale(1); }
}

&.hasNotifications {
animation-name: pulse;
animation-duration: 1600ms;
Expand Down
Loading