-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathnotifications.html
More file actions
235 lines (210 loc) · 10.6 KB
/
notifications.html
File metadata and controls
235 lines (210 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
{{> head}}
<style>
/* Notification Demo Styles */
.notification-demo-card {
background: white;
border-radius: 12px;
padding: 30px;
margin-bottom: 24px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.toast-container-demo {
position: fixed;
top: 20px;
right: 20px;
z-index: 9999;
}
.demo-buttons {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
/* Alert Styles */
.alert-dismissible {
position: relative;
padding-right: 3rem;
}
</style>
{{> sidebar}}
<!-- Main Content Wrapper -->
<div class="main-wrapper" id="mainWrapper">
{{> header}}
<!-- Main Content -->
<main class="dashboard-content" id="main-content">
<div class="container-fluid">
<!-- Page Header -->
<div class="mb-4">
<h1 class="h3 mb-0 text-gray-800">Notifications & Toasts</h1>
<p class="text-muted">Bootstrap 5 notification and toast components (100% jQuery-free)</p>
</div>
<!-- Bootstrap 5 Alerts -->
<div class="notification-demo-card">
<h5 class="mb-3">Bootstrap 5 Alerts</h5>
<div class="alert alert-primary" role="alert">
<i class="bi bi-info-circle me-2"></i>
A simple primary alert - check it out!
</div>
<div class="alert alert-secondary" role="alert">
<i class="bi bi-info-circle me-2"></i>
A simple secondary alert - check it out!
</div>
<div class="alert alert-success" role="alert">
<i class="bi bi-check-circle me-2"></i>
A simple success alert - check it out!
</div>
<div class="alert alert-danger" role="alert">
<i class="bi bi-x-circle me-2"></i>
A simple danger alert - check it out!
</div>
<div class="alert alert-warning" role="alert">
<i class="bi bi-exclamation-triangle me-2"></i>
A simple warning alert - check it out!
</div>
<div class="alert alert-info" role="alert">
<i class="bi bi-info-circle me-2"></i>
A simple info alert - check it out!
</div>
</div>
<!-- Dismissible Alerts -->
<div class="notification-demo-card">
<h5 class="mb-3">Dismissible Alerts</h5>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<i class="bi bi-check-circle me-2"></i>
<strong>Well done!</strong> You successfully read this important alert message.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<i class="bi bi-exclamation-triangle me-2"></i>
<strong>Warning!</strong> Better check yourself, you're not looking too good.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<i class="bi bi-x-circle me-2"></i>
<strong>Oh snap!</strong> Change a few things up and try submitting again.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
</div>
<!-- Alert with Additional Content -->
<div class="notification-demo-card">
<h5 class="mb-3">Alert with Additional Content</h5>
<div class="alert alert-success" role="alert">
<h4 class="alert-heading">Well done!</h4>
<p>Aww yeah, you successfully completed the course module. This alert has additional content to give you more details about the achievement.</p>
<hr>
<p class="mb-0">You can now proceed to the next module and continue your learning journey.</p>
</div>
</div>
<!-- Bootstrap 5 Toasts Demo -->
<div class="notification-demo-card">
<h5 class="mb-3">Bootstrap 5 Toasts</h5>
<p class="text-muted">Click the buttons below to trigger toast notifications:</p>
<div class="demo-buttons">
<button type="button" class="btn btn-primary" id="showToast1">
<i class="bi bi-bell me-2"></i>Show Basic Toast
</button>
<button type="button" class="btn btn-success" id="showToast2">
<i class="bi bi-check-circle me-2"></i>Show Success Toast
</button>
<button type="button" class="btn btn-warning" id="showToast3">
<i class="bi bi-exclamation-triangle me-2"></i>Show Warning Toast
</button>
<button type="button" class="btn btn-danger" id="showToast4">
<i class="bi bi-x-circle me-2"></i>Show Error Toast
</button>
<button type="button" class="btn btn-info" id="showToast5">
<i class="bi bi-info-circle me-2"></i>Show Info Toast
</button>
</div>
</div>
<!-- Notification Examples -->
<div class="notification-demo-card">
<h5 class="mb-3">Notification List</h5>
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h6 class="mb-1"><i class="bi bi-envelope text-primary me-2"></i>New message received</h6>
<small>3 mins ago</small>
</div>
<p class="mb-1 text-muted">You have a new message from John Doe</p>
</a>
<a href="#" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h6 class="mb-1"><i class="bi bi-check-circle text-success me-2"></i>Course completed</h6>
<small class="text-muted">1 hour ago</small>
</div>
<p class="mb-1 text-muted">You have successfully completed the Data Structures course</p>
</a>
<a href="#" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h6 class="mb-1"><i class="bi bi-exclamation-triangle text-warning me-2"></i>Assignment due soon</h6>
<small class="text-muted">2 hours ago</small>
</div>
<p class="mb-1 text-muted">Your assignment is due in 2 days</p>
</a>
<a href="#" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h6 class="mb-1"><i class="bi bi-calendar text-info me-2"></i>Upcoming event</h6>
<small class="text-muted">5 hours ago</small>
</div>
<p class="mb-1 text-muted">Don't forget about tomorrow's lecture at 10:00 AM</p>
</a>
</div>
</div>
</div>
</main>
{{> footer}}
</div>
<!-- Toast Container -->
<div class="toast-container-demo" id="toastContainer"></div>
{{> scripts}}
<script>
// Toast Notifications (Vanilla JavaScript)
document.addEventListener('DOMContentLoaded', function() {
const toastContainer = document.getElementById('toastContainer');
// Function to create and show toast
function showToast(message, type, icon) {
const toastId = 'toast_' + Date.now();
const bgClass = type === 'success' ? 'bg-success' :
type === 'warning' ? 'bg-warning' :
type === 'danger' ? 'bg-danger' :
type === 'info' ? 'bg-info' : 'bg-primary';
const toastHTML = `
<div id="${toastId}" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header ${bgClass} text-white">
<i class="bi ${icon} me-2"></i>
<strong class="me-auto">Notification</strong>
<small>Just now</small>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
${message}
</div>
</div>
`;
toastContainer.insertAdjacentHTML('beforeend', toastHTML);
const toastElement = document.getElementById(toastId);
const toast = new bootstrap.Toast(toastElement);
toast.show();
// Remove toast element after it's hidden
toastElement.addEventListener('hidden.bs.toast', function() {
toastElement.remove();
});
}
// Toast button handlers
document.getElementById('showToast1').addEventListener('click', function() {
showToast('This is a basic toast notification. It will automatically dismiss after a few seconds.', 'primary', 'bi-bell');
});
document.getElementById('showToast2').addEventListener('click', function() {
showToast('Success! Your changes have been saved successfully.', 'success', 'bi-check-circle');
});
document.getElementById('showToast3').addEventListener('click', function() {
showToast('Warning! Please review your input before submitting.', 'warning', 'bi-exclamation-triangle');
});
document.getElementById('showToast4').addEventListener('click', function() {
showToast('Error! Something went wrong. Please try again.', 'danger', 'bi-x-circle');
});
document.getElementById('showToast5').addEventListener('click', function() {
showToast('Info: You have 3 new notifications waiting for you.', 'info', 'bi-info-circle');
});
});
</script>