Spaces:
Running

notification / index.html
LoicUX's picture
Notification du header : Le bouton de notifications affichent le nombre de notifications arrivées depuis la denière ouverture du menu. La pastille du nombre est très visible. Au clic sur le bouton, un menu s’affichent listant les notifications par ordre chronologiques avec les plus récentes en haut et les plus anciennes en bas. Afficher une dizaine de notifications. Distinguer visuellement les notifications lues des non lues chaque notifications à un nom, un contexte, une date d'émission, un bouton permettant de l’effacer Via un lien “voir toutes” permettre d’accèder à un écran qui répertorie l’ensemble des notifications - Initial Deployment
cfe806b verified
Raw History Blame Contribute Delete
14.2 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Notification Header</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.notification-badge {
position: absolute;
top: -5px;
right: -5px;
min-width: 20px;
height: 20px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
.notification-dropdown {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease-out;
}
.notification-dropdown.open {
max-height: 500px;
transition: max-height 0.3s ease-in;
}
.notification-item.unread {
background-color: #f0f9ff;
border-left: 3px solid #3b82f6;
}
.notification-item:hover {
background-color: #f8fafc;
}
</style>
</head>
<body class="bg-gray-50">
<header class="bg-white shadow-sm">
<div class="max-w-7xl mx-auto px-4 py-4 sm:px-6 lg:px-8 flex justify-between items-center">
<div class="flex items-center">
<h1 class="text-xl font-bold text-gray-900">My App</h1>
</div>
<div class="flex items-center space-x-4">
<!-- Notification Button -->
<div class="relative">
<button id="notification-btn" class="p-2 rounded-full text-gray-600 hover:text-gray-900 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500">
<i class="fas fa-bell text-xl"></i>
<span id="notification-count" class="notification-badge bg-red-500 text-white text-xs font-bold px-1.5">5</span>
</button>
<!-- Notification Dropdown -->
<div id="notification-dropdown" class="notification-dropdown absolute right-0 mt-2 w-80 bg-white rounded-md shadow-lg overflow-hidden z-10">
<div class="border-b border-gray-200 px-4 py-3 flex justify-between items-center">
<h3 class="text-lg font-medium text-gray-900">Notifications</h3>
<a href="#" class="text-sm text-blue-600 hover:text-blue-800">View All</a>
</div>
<div class="divide-y divide-gray-200 max-h-96 overflow-y-auto">
<!-- Notification Items -->
<div class="notification-item unread px-4 py-3">
<div class="flex justify-between items-start">
<div>
<p class="font-medium text-gray-900">New Message</p>
<p class="text-sm text-gray-600">You have received a new message from John Doe</p>
<p class="text-xs text-gray-500 mt-1">2 minutes ago</p>
</div>
<button class="text-gray-400 hover:text-gray-600">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div class="notification-item unread px-4 py-3">
<div class="flex justify-between items-start">
<div>
<p class="font-medium text-gray-900">System Update</p>
<p class="text-sm text-gray-600">A new version of the app is available</p>
<p class="text-xs text-gray-500 mt-1">15 minutes ago</p>
</div>
<button class="text-gray-400 hover:text-gray-600">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div class="notification-item px-4 py-3">
<div class="flex justify-between items-start">
<div>
<p class="font-medium text-gray-900">Payment Received</p>
<p class="text-sm text-gray-600">Your payment of $29.99 has been processed</p>
<p class="text-xs text-gray-500 mt-1">1 hour ago</p>
</div>
<button class="text-gray-400 hover:text-gray-600">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div class="notification-item px-4 py-3">
<div class="flex justify-between items-start">
<div>
<p class="font-medium text-gray-900">New Follower</p>
<p class="text-sm text-gray-600">Sarah Johnson started following you</p>
<p class="text-xs text-gray-500 mt-1">3 hours ago</p>
</div>
<button class="text-gray-400 hover:text-gray-600">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div class="notification-item px-4 py-3">
<div class="flex justify-between items-start">
<div>
<p class="font-medium text-gray-900">Event Reminder</p>
<p class="text-sm text-gray-600">Your meeting starts in 30 minutes</p>
<p class="text-xs text-gray-500 mt-1">5 hours ago</p>
</div>
<button class="text-gray-400 hover:text-gray-600">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div class="notification-item px-4 py-3">
<div class="flex justify-between items-start">
<div>
<p class="font-medium text-gray-900">New Comment</p>
<p class="text-sm text-gray-600">Alex commented on your post</p>
<p class="text-xs text-gray-500 mt-1">1 day ago</p>
</div>
<button class="text-gray-400 hover:text-gray-600">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div class="notification-item px-4 py-3">
<div class="flex justify-between items-start">
<div>
<p class="font-medium text-gray-900">Account Activity</p>
<p class="text-sm text-gray-600">New login from Chrome on Windows</p>
<p class="text-xs text-gray-500 mt-1">2 days ago</p>
</div>
<button class="text-gray-400 hover:text-gray-600">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div class="notification-item px-4 py-3">
<div class="flex justify-between items-start">
<div>
<p class="font-medium text-gray-900">Weekly Report</p>
<p class="text-sm text-gray-600">Your weekly activity report is ready</p>
<p class="text-xs text-gray-500 mt-1">3 days ago</p>
</div>
<button class="text-gray-400 hover:text-gray-600">
<i class="fas fa-times"></i>
</button>
</div>
</div>
</div>
<div class="bg-gray-50 px-4 py-3 text-center">
<a href="#" class="text-sm font-medium text-blue-600 hover:text-blue-800">Mark all as read</a>
</div>
</div>
</div>
<!-- User Profile -->
<div class="relative">
<button class="flex items-center space-x-2 focus:outline-none">
<img class="h-8 w-8 rounded-full" src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" alt="">
<span class="text-gray-700">John Doe</span>
</button>
</div>
</div>
</div>
</header>
<main class="max-w-7xl mx-auto px-4 py-8 sm:px-6 lg:px-8">
<h2 class="text-2xl font-bold text-gray-900 mb-6">Dashboard</h2>
<div class="bg-white shadow rounded-lg p-6">
<p class="text-gray-700">Welcome to your dashboard. Here you can see your recent activity and notifications.</p>
</div>
</main>
<script>
document.addEventListener('DOMContentLoaded', function() {
const notificationBtn = document.getElementById('notification-btn');
const notificationDropdown = document.getElementById('notification-dropdown');
const notificationCount = document.getElementById('notification-count');
let isOpen = false;
let unreadCount = 2; // Initial unread count based on the sample data
// Toggle notification dropdown
notificationBtn.addEventListener('click', function(e) {
e.stopPropagation();
isOpen = !isOpen;
if (isOpen) {
notificationDropdown.classList.add('open');
// Mark notifications as read when opened
unreadCount = 0;
updateNotificationCount();
} else {
notificationDropdown.classList.remove('open');
}
});
// Close dropdown when clicking outside
document.addEventListener('click', function() {
if (isOpen) {
notificationDropdown.classList.remove('open');
isOpen = false;
}
});
// Prevent dropdown from closing when clicking inside
notificationDropdown.addEventListener('click', function(e) {
e.stopPropagation();
});
// Delete notification
document.querySelectorAll('.notification-item button').forEach(button => {
button.addEventListener('click', function(e) {
e.stopPropagation();
this.closest('.notification-item').remove();
});
});
// Update notification count
function updateNotificationCount() {
if (unreadCount > 0) {
notificationCount.textContent = unreadCount;
notificationCount.classList.remove('hidden');
} else {
notificationCount.classList.add('hidden');
}
}
// Initial update
updateNotificationCount();
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=LoicUX/notification" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>