feat: Toggle "Mark as Read" and "Mark as Unread" buttons

This commit is contained in:
Kerby Martino (aider) committed 2025-05-05 12:12:34 +08:00
1 parent 987b76019f
commit 16ebdc1098
1 file changed
+27 -9
+27 -9
View File
@@ -3,7 +3,7 @@
<div class="notification-list space-y-4"> <div class="notification-list space-y-4">
<!-- Example Notification: Reply to Post --> <!-- Example Notification: Reply to Post -->
<div class="pb-4 mb-4 border-b border-border-light"> <div class="pb-4 mb-4 border-b border-border-light" data-read="false">
<small class="text-sm mb-1 block"> <small class="text-sm mb-1 block">
<a href="/user/user123" class="text-primary font-action hover:underline">user123</a> <a href="/user/user123" class="text-primary font-action hover:underline">user123</a>
<span class="text-text-muted opacity-75">replied to your post:</span> <span class="text-text-muted opacity-75">replied to your post:</span>
@@ -11,13 +11,12 @@
<span class="text-text-muted text-xs opacity-75 ml-1">2 hours ago</span> <span class="text-text-muted text-xs opacity-75 ml-1">2 hours ago</span>
</small> </small>
<div class="mt-2 flex space-x-2"> <div class="mt-2 flex space-x-2">
<button class="px-3 py-1 bg-primary text-white text-xs font-action rounded hover:bg-primary-dark">Mark as Read</button> <button class="toggle-read px-3 py-1 bg-primary text-white text-xs font-action rounded hover:bg-primary-dark">Mark as Read</button>
<button class="px-3 py-1 bg-primary text-white text-xs font-action rounded hover:bg-primary-dark">Mark as Unread</button>
</div> </div>
</div> </div>
<!-- Example Notification: Upvote on Comment --> <!-- Example Notification: Upvote on Comment -->
<div class="pb-4 mb-4 border-b border-border-light"> <div class="pb-4 mb-4 border-b border-border-light" data-read="false">
<small class="text-sm mb-1 block"> <small class="text-sm mb-1 block">
<a href="/user/anotherUser" class="text-primary font-action hover:underline">anotherUser</a> <a href="/user/anotherUser" class="text-primary font-action hover:underline">anotherUser</a>
<span class="text-text-muted opacity-75">upvoted your comment on:</span> <span class="text-text-muted opacity-75">upvoted your comment on:</span>
@@ -25,13 +24,12 @@
<span class="text-text-muted text-xs opacity-75 ml-1">5 hours ago</span> <span class="text-text-muted text-xs opacity-75 ml-1">5 hours ago</span>
</small> </small>
<div class="mt-2 flex space-x-2"> <div class="mt-2 flex space-x-2">
<button class="px-3 py-1 bg-primary text-white text-xs rounded hover:bg-primary-dark">Mark as Read</button> <button class="toggle-read px-3 py-1 bg-primary text-white text-xs font-action rounded hover:bg-primary-dark">Mark as Read</button>
<button class="px-3 py-1 bg-primary text-white text-xs rounded hover:bg-primary-dark">Mark as Unread</button>
</div> </div>
</div> </div>
<!-- Example Notification: Reply to Comment --> <!-- Example Notification: Reply to Comment -->
<div class="pb-4 mb-4 border-b border-border-light"> <div class="pb-4 mb-4 border-b border-border-light" data-read="false">
<small class="text-sm mb-1 block"> <small class="text-sm mb-1 block">
<a href="/user/helpfulHannah" class="text-primary font-action hover:underline">helpfulHannah</a> <a href="/user/helpfulHannah" class="text-primary font-action hover:underline">helpfulHannah</a>
<span class="text-text-muted font-action opacity-75">replied to your comment on:</span> <span class="text-text-muted font-action opacity-75">replied to your comment on:</span>
@@ -39,8 +37,7 @@
<span class="text-text-muted text-xs font-action opacity-75 ml-1">1 day ago</span> <span class="text-text-muted text-xs font-action opacity-75 ml-1">1 day ago</span>
</small> </small>
<div class="mt-2 flex space-x-2"> <div class="mt-2 flex space-x-2">
<button class="px-3 py-1 bg-primary text-white text-xs rounded hover:bg-primary-dark">Mark as Read</button> <button class="toggle-read px-3 py-1 bg-primary text-white text-xs font-action rounded hover:bg-primary-dark">Mark as Read</button>
<button class="px-3 py-1 bg-primary text-white text-xs rounded hover:bg-primary-dark">Mark as Unread</button>
</div> </div>
</div> </div>
@@ -49,3 +46,24 @@
<p class="text-text-muted text-center pt-4">No more notifications.</p> <p class="text-text-muted text-center pt-4">No more notifications.</p>
</div> </div>
</div> </div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const toggleButtons = document.querySelectorAll('.toggle-read');
toggleButtons.forEach(button => {
button.addEventListener('click', function() {
const notification = button.closest('.pb-4');
const isRead = notification.getAttribute('data-read') === 'true';
if (isRead) {
button.textContent = 'Mark as Read';
notification.setAttribute('data-read', 'false');
} else {
button.textContent = 'Mark as Unread';
notification.setAttribute('data-read', 'true');
}
});
});
});
</script>