Skip to content

Commit dddd3c4

Browse files
Animated Badge Notification (#2279)
* Create README.md Creation of the README, containing: - Introduction - Demonstration - Files - How to use * Create notification-badge.html Component HTML using AngularJS and the necessary classes for styling * Create notification-badge.css CSS component with the necessary classes for creating notification elements, styling and animation * Create notification-badge.js Number of notifications and definition of the badge display rule * Animated Badge Gif - Demo Demonstration of how the component works
1 parent 6ec39d4 commit dddd3c4

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 🔔 Animated Notification Badge
2+
3+
This snippet demonstrates how to create an animated notification badge using native ServiceNow client-side capabilities, without relying on direct DOM manipulation or inline styles.
4+
It uses AngularJS and CSS to apply a pulsating animation to the badge, ideal for Portal widgets that require attention-grabbing indicators.
5+
6+
![Demo of animated badge](./animated-badge.gif)
7+
8+
## 📦 Files
9+
10+
- `notification-badge.html` – Badge markup with conditional visibility
11+
- `notification-badge.css` – Keyframe animation and badge styling
12+
- `notification-badge.js` – Logic to trigger or reset badge visibility
13+
14+
## 🚀 How to Use
15+
16+
1. Copy the HTML, CSS, and client script into your custom Portal widget.
17+
2. Bind the badge visibility to a condition (e.g., number of unread messages).
18+
3. Use the `animate__pulse` class to trigger attention-grabbing animations.
259 KB
Loading
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.notification-wrapper {
2+
position: relative;
3+
display: inline-block;
4+
}
5+
6+
.notification-icon {
7+
font-size: 24px;
8+
color: #333;
9+
}
10+
11+
.notification-badge {
12+
position: absolute;
13+
top: -6px;
14+
right: -6px;
15+
background-color: #e74c3c;
16+
color: white;
17+
font-size: 12px;
18+
padding: 2px 6px;
19+
border-radius: 50%;
20+
font-weight: bold;
21+
animation-duration: 0.6s;
22+
animation-fill-mode: both;
23+
}
24+
25+
.notification-pulse {
26+
animation-name: pulseScale;
27+
animation-iteration-count: infinite;
28+
animation-timing-function: ease-in-out;
29+
}
30+
31+
@keyframes pulseScale {
32+
0% { transform: scale(1); }
33+
50% { transform: scale(1.2); }
34+
100% { transform: scale(1); }
35+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class="notification-wrapper">
2+
<i class="fa fa-bell notification-icon" aria-hidden="true"></i>
3+
<span
4+
class="notification-badge"
5+
ng-class="{'notification-pulse': c.hasNewNotification}"
6+
ng-if="c.hasNewNotification">
7+
{{ c.badgeCount }}
8+
</span>
9+
</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
api.controller=function($scope) {
2+
var c = this;
3+
4+
c.badgeCount = 3;
5+
c.hasNewNotification = c.badgeCount > 0;
6+
};

0 commit comments

Comments
 (0)